Skip to main content
Source Link
rajat kara
  • 1.2k
  • 3
  • 19
  • 28

Saving custom payment field data in magento 2 through plugin not working,

i am trying to save my custom field data through plugin but is 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, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentInformation
) {

// $paymentInformation->getData('extension_attributes');

    $extenstinAttributes = $paymentInformation->getExtensionAttributes();
    $taxCode = $extenstinAttributes->getTaxCode();

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

    return true;

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

}

Can anyone please help me on this.

1
2