我正在开发基于自定义API的支付网关。对于3D安全验证,支付网关返回编码表单,需要提交给第三方站点上的用户重定向进行卡验证。
我是工作在这个代码捕获功能的支付模式。
在这里,我的问题是,我如何使用编码形式重定向用户从支付模式捕获方法到第三方网站。
我使用getOrderPlaceRedirectUrl在宿主表单方法中重定向用户。
请建议一下。
发布于 2014-02-13 15:50:39
我创建了一个新的控制器操作,并将用户从getOrderPlaceRedirectUrl()重定向到它。这个新的控制器动作将显示一个隐藏形式,它将MD、PaReq等显示为隐藏字段。然后,此表单可以自动提交给ACS URL。
下面是一些未经测试的伪代码。您将需要根据您的需要对其进行修改,但希望它能让您了解这个想法。
在您的支付方法实例中:
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>
https://stackoverflow.com/questions/21753859
复制相似问题