I am trying to save the payment related custom data in additional_information
column through my custom module.can any one help me on this.
Observer class
namespace Vendor\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Quote\Api\Data\PaymentInterface;
class PaymentAssignData implements ObserverInterface {
protected $_request;
/**
* @var ObjectManagerInterface
*/
protected $_objectManager;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager, \Psr\Log\LoggerInterface $logger, \Magento\Quote\Model\QuoteFactory $quoteFactory, \Magento\Framework\App\RequestInterface $request
) {
//die(__METHOD__);
$this->_objectManager = $objectManager;
$this->logger = $logger;
$this->quoteFactory = $quoteFactory;
$this->_request = $request;
}
/**
* customer register event handler
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer) {
$order = $observer->getEvent()->getOrder();
$addInfo = $order->getPayment()->getData();
var_dump(json_encode($addInfo));
exit;
$quoteRepository = $this->_objectManager->create('Magento\Quote\Model\QuoteRepository');
/** @var \Magento\Quote\Model\Quote $quote */
var_dump(json_encode($observer));
exit;
$quote = $quoteRepository->get($order->getQuoteId());
$order->setDeliveryDate($quote->getDeliveryDate());
$order = $observer->getEvent()->getOrder();
//$quote = $order->getQuote();
$quoteId = $order->getQuoteId();
$payment = $order->getPayment()->getData('additional_data');
$quote = $this->quoteFactory->create()->load($quoteId);
// $postData = $this->_request->getParam();;
var_dump($payment);
exit;
// var_dump($quoteId);exit;
}
}
additional field in payment section.that fields are for all payment method. js file
define(
[
'ko',
'jquery',
'uiComponent'
],
function (ko, $, Component) {
'use strict';
return Component.extend({
defaults: {
template: 'Vendor_Module/checkout/formdata-form',
taxCode: '',
taxState: ''
},
initialize: function () {
this._super()
.observe(
[ 'taxCode',
'taxState'
]
);
return this;
},
getData: function () {
return {
"additional_data": {
'tax_code': this.taxCode(),
'tax_state': this.taxState()
}
};
}
});
}
);