任何人都可以帮助我使用 Authorize.Net 获取授权和捕获步骤(代码)吗?似乎每个人都知道如何同时使用两者,但是,没有解释如何将其分成单独的步骤,先授权,然后捕获(使用 trasactionID)。
最佳答案
授权后,请按照以下步骤自动捕获您的订单:
将付款方式配置为授权(非直销)
创建一个观察者,使用名为
automaticalyCaptureOrder
的方法处理名为sales_order_ payment_place_end
的事件使用以下观察者方法代码:
public function automaticalyCaptureOrder(Varien_Event_Observer $observer) { $payment = $observer->getEvent()->getPayment(); // Add additional check for payment method instance, // We need to be sure that only Authorize.Net payment will be captured if ($payment->getMethodInstance() instanceof Mage_Paygate_Model_Authorizenet) { $payment->capture(null); // null value tells Magento to create // an invoice automatically } }
坐下来放松一下:)
如果您对此解决方案有任何困难,请告诉我,我会回复您。
更新:
要在一段时间后捕获订单付款,您应该通过其唯一 id 加载订单对象,并执行与以前类似的操作,但您还需要在调用捕获方法后保存订单对象:
$order->load($orderId); // Or $order->loadByIncrementId($incrementId);
$order->getPayment()->capture(null); // Capturing the payment
$order->save(); // Save updated information (transaction ids, order status)
关于magento - 在 Magento 中使用 Authorize.Net 以编程方式进行授权和捕获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3296425/