2014-02-13 44 views
2

我正在開發基於定製API的支付網關。對於需要提交的3D安全驗證支付網關返回編碼格式,以將用戶重定向到第三方網站進行卡驗證。在magento中基於定製API的支付方法中實施3D安全驗證

我正在研究這個代碼中捕獲付款模型的功能。

這裏我的問題是如何使用編碼表單將用戶從付款模式捕獲方法重定向到第三方站點。

我已經使用getOrderPlaceRedirectUrl重定向Hosted form Method中的用戶。

請建議。

+0

任何幫助,請! –

回答

2

我創建了一個新的控制器動作,並將用戶從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'); 
} 

應用程序/代碼/本地/命名空間/模塊/控制器/ Payment.php:

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

應用程序/設計/ frontent /基/默認/佈局/ 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> 

應用程序/代碼/本地/命名空間/模塊/塊/付款/ Redirect.php:

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

應用程序/設計/前端/基/默認/模板/模塊/支付/ redirect.tpl:

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

感謝您的回答。在重新定向控制器之後,我正在檢查捕獲功能中的所有條件,但當重定向訂單狀態已更改爲處理並生成發票時。 ..你可以請幫忙,我可以做任何錯誤 –

+0

@PankajPareek上面的代碼不會帶你一路;你需要擴展它。當你重定向到自定義控制器時,Magento已經調用了'Mage_Sales_Model_Order_Payment :: place()'。這個函數負責調用您的支付方法的'authorize()'和'capture()'函數。你可以根據你的需要來擴展'authorize()'和'capture()'。我自己的解決方案還包括將觀察者附加到事件'checkout_submit_all_after',該事件加載了活動訂單並將其狀態和狀態更新爲「待定3D安全」。 – Pete171

+0

如何控制在捕獲方法中生成發票? –