2

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? – Beto Castillo Mar 25 '18 at 5:00
2

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');
}

app/code/local/Namespace/Module/controllers/Payment.php:

class Namespace_Module_PaymentController extends Mage_Core_Controller_Varien_Front {
    public function redirectAction() {
        $this->loadLayout();
        $this->renderLayout();
    }
}

app/design/frontent/base/default/layout/module.xml:

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

app/code/local/Namespace/Module/Block/Payment/Redirect.php:

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

app/design/frontend/base/default/templates/module/payment/redirect.tpl:

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

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, privacy policy and cookie policy

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