【问题标题】:Magento event for Paypal IPN marking order as ProcessingPaypal IPN 将订单标记为处理中的 Magento 事件
【发布时间】:2012-01-06 00:33:48
【问题描述】:

我正在开发 Magento (1.4 CE) 的扩展,一旦支付订单就需要触发该扩展。当 Paypal IPN(Paypal 标准)完成它的工作时,我无法找到一个挂钩的事件。

我已尝试使用 sales_order_invoice_save_after 和 sales_order_invoice_register 事件,但这些事件似乎都不是由 Paypal IPN 响应触发的。

我现在正在尝试使用 sales_order_save_after 事件来检测订单何时进入“处理”状态,如下所示:

class Lightbulb_Blastramp_Model_Observer {

    public function sendOrderToBlastramp(Varien_Event_Observer $observer) {

        Mage::log('Start' . "\n\n", null, 'blastramp.log');

        $order = $observer->getEvent()->getOrder(); // get order data

        // make sure the order is in the processing state
        if ($order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING) {
            Mage::log('Not processing, return.' . "\n\n", null, 'blastramp.log');
            return $this;
        }
        // order has reached "processing" state, do stuff...
    }
}

从日志文件中我可以看到,我的代码在最初以“付款待定”状态创建订单时被触发,但在进入“处理”状态时不会被触发。当订单进入 Paypal IPN 设置的“处理”阶段时,我是否可以挂钩某些事件?

干杯

【问题讨论】:

    标签: php magento magento-1.4 paypal-ipn


    【解决方案1】:

    在为此苦苦挣扎了一段时间后,我最终通过覆盖 Mage_Sales_Model_Order_Payment 中的 _isCaptureFinal($amount) 方法取得了成功。

    例如。

    class Lightbulb_Blastramp_Model_Order_Payment extends Mage_Sales_Model_Order_Payment {
        public function _isCaptureFinal($amount) {
            // do things here
            return parent::_isCaptureFinal($amount);
        }
    }
    

    这要感谢另一个问题的答案:https://stackoverflow.com/a/5024475/602734

    希望这对某人有所帮助!

    【讨论】:

      【解决方案2】:

      如果有人像我一样偶然发现了这个问题,请按照最初的要求做一个观察者;

      checkout_onepage_controller_success_action

      这仅返回订单ID,所以;

      $order_id = $observer->getData('order_ids');
      $order = Mage::getModel('sales/order')->load($order_id);
      

      您会看到订单状态为“处理中”并且付款已批准(或未批准)。

      【讨论】:

        猜你喜欢
        • 2012-01-01
        • 2014-06-28
        • 2020-03-19
        • 2010-11-08
        • 2013-11-04
        • 1970-01-01
        • 2017-02-12
        • 1970-01-01
        相关资源
        最近更新 更多