【问题标题】:Authorize and then Capture programmatically using Authorize.Net in Magento在 Magento 中使用 Authorize.Net 以编程方式授权然后捕获
【发布时间】:2011-03-18 19:22:55
【问题描述】:

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

【问题讨论】:

标签: magento authorize.net


【解决方案1】:

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

  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)

【讨论】:

  • Ivan,感谢您提供的信息,但我如何先授权,比如说,10 天后我可以捕获。我需要授权才能将物品发送给客户,一旦运输公司告诉我客户收到了物品,我将捕获。 Magento 将信用卡信息保存在数据库中的什么位置?
  • 好吧,我认为您没有直接解决 Isy 的问题,但您提供的信息非常棒。至少对我真的很有帮助!谢谢。
【解决方案2】:

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

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

祝你好运。

【讨论】:

    猜你喜欢
    • 2015-12-19
    • 2015-01-21
    • 2019-08-16
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 2017-06-23
    相关资源
    最近更新 更多