magento - 在 Magento 中使用 Authorize.Net 以编程方式进行授权和捕获

标签 magento authorize.net

任何人都可以帮助我使用 Authorize.Net 获取授权和捕获步骤(代码)吗?似乎每个人都知道如何同时使用两者,但是,没有解释如何将其分成单独的步骤,先授权,然后捕获(使用 trasactionID)。

最佳答案

授权后,请按照以下步骤自动捕获您的订单:

  1. 将付款方式配置为授权(非直销)

  2. 创建一个观察者,使用名为 automaticalyCaptureOrder 的方法处理名为 sales_order_ payment_place_end 的事件

  3. 使用以下观察者方法代码:

     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
         }
     }
    
  4. 坐下来放松一下:)

如果您对此解决方案有任何困难,请告诉我,我会回复您。

更新:

要在一段时间后捕获订单付款,您应该通过其唯一 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/

相关文章:

Magento 定期计费解决方案

grails - E_WC_14 : Accept. js 加密失败?

php - 对于 Authorize.Net 中永无止境的订阅,应为 "setTotalOccurrences"传递什么值?

ruby-on-rails-3 - 使用 Active Merchant 从 Authorize.net 获取 ARB 订阅信息?

ios - IAP或Authorize.net

Magento 选择字段禁用相关产品中的行

magento - 为特定产品启用支付网关 - Magento 2

magento - Paypal Express Checkout 坚持使用电话号码,即使选项已关闭(从 Magento 调用)

javascript - 如果单击具有相似类的元素,则获取元素属性

e-commerce - Authorize.Net Silent Post 如何工作?