Magento: How to get the values ​​from the fields sent using the payment method?

Ok This is a little frustrating. I am trying to create my own payment module for Magento. The goal is to use Authorize.net CIM, so we don’t need to worry so much about PCI compliance. The problem I am facing is that users must have access to their previous credit cards and use them to purchase. I have previous cards that are stored in the database. They are also displayed on the form during the checkout process.

My problem arises when I click the Continue button after choosing a payment method. How to get the values ​​presented by me in the form? In particular, the value of the stored code switch is tied to?

I'm not sure if I need any code to post, so let me know if you need anything in particular.

Thanks.

+4
source share
2 answers

Having looked at the verification of one page, payment data is extracted from the elements of the payment[] form on the verification page as follows:

 $data = $this->getRequest()->getPost('payment', array()); $result = $this->getOnepage()->savePayment($data); 

This information is stored in the actual payment using:

 $payment->importData($data); 

This means that the fields imported in this way should be accessible to your authorize() module, after which you can get the correct information for authorization.

Hope that made sense. If not, submit the HTML form for the form, as well as your authorize() method in the module.

Thanks Joe

0
source

There are some good places where this message data is available for your payment method.

The best place to access mail data fields is to override the assignData method in your payment method class. It should look something like this:

 /** * Assign data to info model instance */ public function assignData($data) { // Call parent assignData parent::assignData($data); // Get Mage_Payment_Model_Info instance from quote $info = $this->getInfoInstance(); // Add some arbitrary post data to the Mage_Payment_Model_Info instance // so it is saved in the DB in the 'additional_information' field $info->setAdditionalInformation( 'arbitrary_post_field', $data['arbitrary_post_field']; return $this; } 

Alternatively, you can rewrite Mage_Sales_Model_Quote_Payment :: importData () and Mage_Checkout_Model_Type_Onepage :: savePayment, which gives you more flexibility since these methods will be called before Magento chooses your specific payment method based on the payment code.

+1
source

Source: https://habr.com/ru/post/1312253/


All Articles