Magento – magento 2 view model set payment additional data before place order

authorizemagento2payment-methodstoken

I am adding a token in payment additional data

 getData: function () {
            return {
                'method': "pay_cc",
                'additional_data': {
                    'token_code': this.getToken(),
                }
            };
        },

setting this 'token_code' with function

            getToken:function(){
            return this.paymentToken;
        },

before place order I am generating token and setting setting this before calling 'self.plcaseOrder()' function

this.paymentToken = response[0];
console.log("TOKEN CODE");
console.log(this.paymentToken);
self.placeOrder();
return true;

When I access this in magento payment method authorize function I am getting null.

How Can I set this token_code??

Best Answer

For security reasons, Magento dev team removed "auto-saving" additional data into payment and you need to set the payment token from additional_data to additional_information. This dev guide describes how to do it.

As an example, Magento Vault uses the publish hash received from the front end to store it in a payment information.

Related Topic