Magento Custom Payment Gateway不会触发'授权'或'捕获'方法

Mor*_*gon 5 php magento

所以,霍瑞 - 我正在尝试创建一个新的自定义支付网关.它旨在通过第三方API进行身份验证/捕获,但不需要重定向到第三方网站.

根据我的理解,当在Magento中下订单/最终确定订单并且网关设置为"授权和捕获"时,它应该从网关模型中触发"捕获"方法.目前,它没有这样做.

当然,如果我从管理订单视图中专门捕获它,它将尝试捕获,但这需要在结账时立即发生(同样,这是我的理解,它已经应该).

在我的网关模型中,我有以下内容(为了便于阅读而被截断):

<?php
class Example_Gateway_Model_Payment extends Mage_Payment_Model_Method_Cc
{
    protected $_code = 'example';

    protected $_isGateway = true;
    protected $_canAuthorize = true;
    protected $_canCapture = true;
    protected $_canUseInternal = true;
    protected $_canUseCheckout = true;

    // This is an empty block class that extends Mage_Payment_Block_Form_Cc
    protected $_formBlockType = 'example/form_example';

    public function authorize(Varien_Object $payment, $amount)
    {
        Mage::log('Authorizing!');
    }

    public function capture(Varien_Object $payment, $amount)
    {
        Mage::log('** Capturing **');
        // Third-party API stuff would go here, with exceptions being thrown if the gateway determines they've provided an invalid card, etc.
    }

    public function assignData($data)
    {
        Mage::log('Assigning Data');
    }
}
Run Code Online (Sandbox Code Playgroud)

这种支付模式本身肯定工程-我得到日志输出assignData()validate(),以及__construct()如果我添加它.但无论我做什么,捕获或授权方法在实际下订单时都不会触发.

我的config.xml读起来有点像这样:

<?xml version="1.0"?>
<config>
    <modules>
        <Example_Gateway>
            <version>0.0.5</version>
        </Example_Gateway>
    </modules>
    <global>
        <blocks>
            <gateway>
                <class>Example_Gateway_Block</class>
            </gateway>
        </blocks>
        <models>
            <gateway>
                <class>Example_Gateway_Model</class>
            </gateway>
        </models>
        <helpers>
            <gateway>
                <class>Example_Gateway_Helper</class>
            </gateway>
        </helpers>
    </global>
    <frontend>
      <!-- Snip.. Nothing special here -->
    </frontend>
    <default>
        <payment>
            <gateway>
                <sort_order>0</sort_order>
                <model>gateway/payment</model>
                <enabled>1</enabled>
                <order_staus>processing</order_status>
                <payment_action>authorize_capture</payment_action>
                <cctypes>VI,MC,AE,DI</cctypes>
                <useccv>1</useccv>
            </gateway>
        </payment>
    </default>
</config>
Run Code Online (Sandbox Code Playgroud)

我不相信需要资源模型,因为我不需要任何额外的表; 我的期望是它只会使用sales_flat_order_payment和相关的表来存储任何与网关相关的/提供的数据(txn id等)

同样,我只是扩展默认CC块以获得标准支付表格.

我错过了什么?它必须是一个小而简单的东西,我忽略了.

提前致谢!


更新: 到目前为止,我已经实现了一个解决方法,它使用一个观察者来手动调用capture()方法的checkout_type_onepage_save_order事件 - 但我很确定这不是正确的方法.

我认为Magento应该自动调用capture()初始订单保存,如果网关设置为authorize_capture,那么我没错.

Mor*_*gon 0

好吧,我使用了观察者来手动调用捕获方法。
这不是最优雅的解决方案,但它工作得足够好。