2014-05-07 85 views
1

我正在开发支付网关的模块,该模块可以在两个不同的步骤中进行授权和捕获。到目前为止,我可以通过运行下面的代码授权顺序:Magento:发票和获取授权订单

class My_Gateway_Model_Method_Cc extends Mage_Payment_Model_Method_Cc 
{ 
    protected $_code   = 'mycode'; 
    protected $_canSaveCc  = true; 

    protected $_canRefund     = true; 
    protected $_isGateway     = true; 
    protected $_canAuthorize    = true; 
    protected $_canCapture     = true; 
    protected $_canCapturePartial   = false; 


    public function authorize(Varien_Object $payment, $amount){ 
     /* code to call the payment gateway and authorize the charge */ 
    } 


    public function capture(Varien_Object $payment, $amount){ 
     /* some code to capture the payment */ 
    } 
} 

的问题是,当我下订单,然后我进入开票面板我得到这个消息:

没有选项捕获授权支付,也不开发票时,它调用的捕获方法“发票将不与支付网关通信创建”。

+1

我已经通过代码消失了,显然是Magento的设置事务为关闭或在授权上关闭== 1。因此,它禁用了在后端捕获付款的选项。任何想法如何防止这种情况发生,而不硬编码? – awavi

回答

0

您已设置

$_isGateway = true; 

所以你还需要设置网关地址

在你的支付模式,扩展Mage_Payment_Model_Method_Abstract的人,你就需要实现的方法:

function getOrderPlaceRedirectUrl() { 
    return 'http://www.where.should.we.pay.com/pay'; 
} 

通常,您将用户重定向到您网站上的某个页面,例如/ mymodule/payment/redirect,然后处理操作中的重定向逻辑o控制器。这使您的付款模式保持清洁和无状态,同时允许您使用某种“您正在转移到网关以进行付款”消息。

保存您需要的所有内容,以决定在会话变量中重定向到的位置,通常也是Mage::getSingleton('checkout/session')

Magento有一个非常可靠的,如果混乱,这实现了贝宝标准。你可以在app/code/core/Mage/Paypal/{Model/Standard.php,controllers/StandardController.php}结账。

+0

谢谢。我会将$ _isGateway更改为false,因为它实际上不是一个。它在后端处理付款。问题在于它默认关闭付款交易。我会自动解答我的问题,因为我找到了答案。谢谢。 – awavi

0

看一看这blogMagento交易部分在最后。

if($result['status'] == 1){ // on success result from payment gateway 
    $payment->setTransactionId($result['transaction_id']); 
    $payment->setIsTransactionClosed(1); 
    $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('key1'=>'value1','key2'=>'value2')); 
} 
2

好吧,我已经找到了解决办法:

基本上,Magento的默认关闭任何授权的交易,它使捕捉到付款发票时,授权交易是开放的选项。因此,所有你需要做的是配置留双头呆(未封闭)

所以这里的交易是我做过什么:

public function authorize(Varien_Object $payment, $amount) 
{ 
    // Leave the transaction opened so it can later be captured in backend 
    $payment->setIsTransactionClosed(false); 

    /* 
    * Place all the code to connect with your gateway here!!! 
    * 
    */ 

    return $this; 
} 
相关问题