2

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

4

2 回答 2

5

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

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

  2. 创建一个观察者,它将处理使用调用sales_order_payment_place_end的方法调用的事件automaticalyCaptureOrder

  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)
于 2010-11-04T00:32:17.867 回答
0

CAPTURE 交易需要从您的 AUTH 交易返回的授权码。x_auth_code 键需要设置为来自 AUTH 请求的授权码的值。在 AUTH 事务的分隔响应中,它是字段 #5。

请参阅 AIM 指南的第 13 页。另请参阅附录 B 第 58 页,了解每种交易类型的最少必填字段。

祝你好运。

于 2010-09-03T06:03:17.850 回答