I am working on custom API based payment gateway. For 3D secure verification payment gateway return encoded form that need to submit to redirect user on third party site for card verification.

I am working on this code in capture function of payment model.

Here My question is How can I use encoded form to redirect user from payment model capture method to third party site.

I have used getOrderPlaceRedirectUrl to redirect user in Hosted form Method.

Please suggest.

  • Hi @Pankaj I Would like to know at the end, how do you solved this? Commented Mar 25, 2018 at 5:00

1 Answer 1


I created a new controller action and redirected users to it from getOrderPlaceRedirectUrl(). This new controller action will show a hidden form that displays the MD, PaReq etc as hidden fields. This form can then auto submit to the ACS URL.

Some untested pseudo-code is below. You'll need to modify it according to your needs but hopefully it gets the idea across.

Inside your payment method instance:

function getOrderPlaceUrl() {
    Mage::getModel('core/session')->setMd('valuehere'); //  Set all the 3DS params into the session by the time this function call finished.  Don't set them here in actual code - bad style.  This is just for demonstration.
    return Mage::getUrl('module/payment/action');


class Namespace_Module_PaymentController extends Mage_Core_Controller_Varien_Front {
    public function redirectAction() {


    <reference name="content">
        <block type="namespace_module/payment_redirect</block" name="namespace.module.payment.redirect" template="namespace/module/payment/redirect.tpl" />


class Namespace_Module_Block_Payment_Redirect extends Mage_Core_Block_Abstract
    public function getMd() {
        return Mage::getModel('core/session')->getMd();


<form action="payment_gateway_url_here" method="post">
    <input type="hidden" name="MD" value="<?php print $this->getMd(); ?>" />

Note: I first saw and answered this question on SO. Unsure of the protocol for handling duplicate questions across SE sites. Perhaps someone will advise?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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