Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento Custom Payment Gateway not firing 'authorize' or 'capture' methods
    primarykey
    data
    text
    <p>So, horray - I'm attempting to create a new custom Payment Gateway. It's designed to do auth/capture via a third-party API, but does NOT need to redirect to the third-party site.</p> <p>From my understanding, when an order is placed/finalized in Magento, and the gateway is set to "Authorize and Capture", it should be firing off the 'capture' method from the gateway model. Currently, it's not doing this.</p> <p>Of course, if I specifically capture from the Admin Order view, it'll attempt to capture, but this needs to happen immediately upon checkout (and again, it's my understanding that it already should).</p> <p>In my gateway Model, I have the following (truncated for readability):</p> <pre><code>&lt;?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'); } } </code></pre> <p>This Payment model itself definitely works - I get logging output for <code>assignData()</code> and <code>validate()</code>, as well as <code>__construct()</code> if I add it. But no matter what I do, neither the capture or authorize methods fire when actually placing the order.</p> <p>My config.xml reads somewhat like this:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;config&gt; &lt;modules&gt; &lt;Example_Gateway&gt; &lt;version&gt;0.0.5&lt;/version&gt; &lt;/Example_Gateway&gt; &lt;/modules&gt; &lt;global&gt; &lt;blocks&gt; &lt;gateway&gt; &lt;class&gt;Example_Gateway_Block&lt;/class&gt; &lt;/gateway&gt; &lt;/blocks&gt; &lt;models&gt; &lt;gateway&gt; &lt;class&gt;Example_Gateway_Model&lt;/class&gt; &lt;/gateway&gt; &lt;/models&gt; &lt;helpers&gt; &lt;gateway&gt; &lt;class&gt;Example_Gateway_Helper&lt;/class&gt; &lt;/gateway&gt; &lt;/helpers&gt; &lt;/global&gt; &lt;frontend&gt; &lt;!-- Snip.. Nothing special here --&gt; &lt;/frontend&gt; &lt;default&gt; &lt;payment&gt; &lt;gateway&gt; &lt;sort_order&gt;0&lt;/sort_order&gt; &lt;model&gt;gateway/payment&lt;/model&gt; &lt;enabled&gt;1&lt;/enabled&gt; &lt;order_staus&gt;processing&lt;/order_status&gt; &lt;payment_action&gt;authorize_capture&lt;/payment_action&gt; &lt;cctypes&gt;VI,MC,AE,DI&lt;/cctypes&gt; &lt;useccv&gt;1&lt;/useccv&gt; &lt;/gateway&gt; &lt;/payment&gt; &lt;/default&gt; &lt;/config&gt; </code></pre> <p>I don't believe there's a need for a resource model as I don't need any additional tables; my expectation is that it will simply use <code>sales_flat_order_payment</code> and related tables to store any gateway-related/-provided data (txn id, etc)</p> <p>Similarly, I'm simply extending the default CC block to get the standard payment form.</p> <p>What am I missing? It has to be something small and simple that I'm overlooking.</p> <p>Thanks in advance!</p> <hr> <p><strong>UPDATE:</strong> So far, I have implemented a workaround that uses an observer to the checkout_type_onepage_save_order event that calls the capture() method manually - but I'm pretty sure this is not the right way to go.</p> <p>I'm not wrong in thinking that Magento should automatically call <code>capture()</code> upon the initial order save, if the gateway is set to authorize_capture, right..?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload