I am trying to save my custom field data through plugin but it's not working.

Plugin Class

namespace Vendor\Module\Model\Checkout;

class PaymentInformationManagementPlugin {

    protected $paymentMethodManagement;

    public function __construct(
        \Magento\Quote\Model\QuoteFactory $quote, 
        \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement
    ) {
        $this->paymentMethodManagement = $paymentMethodManagement;
        $this->quoteManagement = $quoteManagement;

    public function beforeSavePaymentInformation(
        \Magento\Checkout\Model\PaymentInformationManagement $subject, 
        \Magento\Quote\Api\Data\PaymentInterface $paymentInformation
    ) {
        $extenstinAttributes = $paymentInformation->getExtensionAttributes();
        $taxCode = $extenstinAttributes->getTaxCode();

        $this->paymentMethodManagement->set($cartId, $paymentInformation);

        return true;
//        var_dump($taxCode);exit;
//        $quote=$this->quote->create();
//        $quote->getPayment()->setData('tax_code',$taxCode);
//        return $paymentInformation;



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Quote\Api\Data\PaymentInterface">
        <attribute code="tax_code" type="string"/>


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Checkout\Model\PaymentInformationManagement">
        <plugin name="save-in-quote-payment" type="Vendor\Module\Model\Checkout\PaymentInformationManagementPlugin" sortOrder="12349"/>

Can anyone please help me on this.

  • show more detail with config
    – Sohel Rana
    Nov 25, 2016 at 8:25
  • i am getting the value $taxCode = $extenstinAttributes->getTaxCode(); in this variable but unable to set he data.
    – rajat kara
    Nov 25, 2016 at 8:31
  • please check the update code in question
    – rajat kara
    Nov 25, 2016 at 8:46
  • i am getting the form data in my plugin but unable to save data.
    – rajat kara
    Nov 25, 2016 at 8:56
  • Did you done this? Sep 26, 2017 at 13:32

1 Answer 1


I think that for start you need to set the extension attributes like this:

$extensionAttributes = $paymentInformation->getExtensionAttributes();

You can try this approach and let me know how you get on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.