Magento Custom Payment Gateway does not launch “authorization” or “capture” methods

So, horray - I'm trying to create a new custom payment gateway. It is intended for authentication / capture through a third-party API, but should NOT be redirected to a third-party site.

From my understanding, when an order is placed / finalized in Magento, and the gateway is set to “Authorize and capture”, it should disable the “capture” method from the gateway model. Currently, he does not.

Of course, if I specifically capture from the "Administrator" view, he will try to capture, but this should happen immediately after verification (and again, I understand that he should already).

In my gateway model, I have the following (truncated for readability):

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

- 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>

, , ; , sales_flat_order_payment / (txn id ..)

, CC , .

? - , .

!


UPDATE: , checkout_type_onepage_save_order, capture() , , .

, , Magento capture() , authorize_capture, .?

+5
3

, .
, .

0

! :

protected $_isInitializeNeeded      = false;

, , , magento - . , , , , Payment.php _authorize, isInitializeNeeded true. , , .

+3

, : "authorize_capture", "", config

<payment_action>authorize_capture</payment_action>

:

public function authorize_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.
}

, "authorize" , "authorize_action" . , . "getConfigPaymentAction" .

public function getConfigPaymentAction() {
    return 'authorize';
} 
+2

All Articles