Magento – How to retrieve value from custom payment method in onepage checkout

checkoutmagento-1onepage-checkoutpayment-methods

I have built a new payment method and I added a custom field in the onepage checkout payment select step.

When you select my payment method, you have a choice to select installments. I need to access that value (number of installments) and post it via form to the payment service page.

How can I retrieve that value?

Best Answer

Question, how I understand it

I hope I understand the question correct. You have a payment method and the problem, that in onepage checkout a field is added inside the <dd> and when the method is selected, the field is shown, but the value is not transfered to the controller.

Answer

The problem is, that the "feeled" submit of the form is no submit. It is a call to Payment.save(), defined here: skin/frontend/base/default/js/opcheckout.js:770

Theoretically everything inside of <form action="" id="co-payment-form"> should be transfered: parameters: Form.serialize(this.form), (line 782)

So on this side everything should be done automatically. Now you can just access your parameter with the name as always: Mage::app()->getRequest()->getParam('YOUR_NAME').

This can be done inside a observer, for example while listening to sales_quote_payment_import_data_before or sales_order_payment_save_before

Related Topic