I have to implement an easy payment scheme for my site. In the checkout frontend i need to display 3 payment options such as 6 months , 12 months and 24 months. Also in the payment gateway you can set only one redirect url for all 3. So without creating 3 separate payment modules i was thinking of handling it using one module as only one parameter differs (installment) from the rest of the code. Is it possible in magento? And if possible how can i achieve it?

  • Yes, it is possible. It can be handled in same way, as card related modules handle different cards. You can take a look at default CC payment method implementation for details of this. – Prateek Jun 30 '16 at 13:14
  • Thanks for the answer. I'll go through the CC payment method and check. – Lakshin Karunaratne Jul 2 '16 at 2:48
  • Don't forget to come back to the question if you get stuck or find the solution. – Prateek Jul 6 '16 at 8:16
  • I would always come back when i find the answer. Anyway thanks for the reminder. – Lakshin Karunaratne Jul 10 '16 at 8:17


class Custom_Pay_Model_paymodel extends Mage_Payment_Model_Method_Abstract {
    protected $_code = 'pay';

    protected $_isInitializeNeeded      = true;
    protected $_canUseInternal          = true;
    protected $_canUseForMultishipping  = false;

    // define variable to add a custom form for payment method in checkout
    protected $_formBlockType = 'pay/form_pay';

    //this is the function to get the data in the custom form
    public function assignData($data)
    public function getOrderPlaceRedirectUrl() {
        return Mage::getUrl('pay/payment/redirect', array('_secure' => true));


class Custom_Pay_Block_Form_Pay extends Mage_Payment_Block_Form
protected function _construct()


<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
    <input type="radio" style="margin-left: 20px;" id="paysix" name="payment[pay_installment]" value="6" checked>
    <label for="paysix" style="float:left">6 Months</label>    

    <input type="radio" style="margin-left: 10px;" id="paytwelve" name="payment[pay_installment]" value="12">
    <label for="paytwelve">12 Months</label>    

Using the above code i showed a custom form for the payment method with 2 radio buttons. Then in the assign data function i added it to the Mage::Registry and took it from the block which i created the request form and created the form according to the selected values.

  • So actually you'd have to use $data->getData("pay_installment") to access the correct information. – Olivier Lance Apr 23 '19 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.