2

I have created three custom form fields in checkout payment section.

I have followed this link to create form fields (How to add additional field to checkout payment (Magento 2)).

Now want to know how to save these fields data in the database.

Thanks

1 Answer 1

0

You can add getData method in your js file:

getData: function() { return { 'method': "methodcode", 'additional_data': { 'customfield1': $('#'+this.getCode()+'_customfield1').val(), 'customfield2': $('#'+this.getCode()+'_customfield2').val(), } }; }, 

then you can get these fields in additional data param in your payment model:

namespace Namespace\ModuleName\Model; class Payment extends \Magento\Payment\Model\Method\Cc { public function assignData() { $post = $data->getData()['additional_data']; // write your custom code } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.