php - Paypal IPN 的 Magento 事件将订单标记为正在处理

标签 php magento magento-1.4 paypal-ipn

我正在为 Magento (1.4 CE) 开发一个扩展,需要在订单付款后触发。我无法找到一个事件来 Hook ,当 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 设置的“处理”阶段时,是否有我可以 Hook 的事件会触发?

干杯

最佳答案

在为此苦苦挣扎了一段时间之后,我最终通过覆盖 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

希望这对某人有帮助!

关于php - Paypal IPN 的 Magento 事件将订单标记为正在处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8263847/

相关文章:

magento - 翻译 Magento 前端

magento-1.4 - Magento : Create an invoice with invoice number = order number?

php - 如何从数据库中获取日期并显示而不重复?

magento - 创建一个全局函数

css - magento - 更改页脚链接文本的颜色

javascript - PHP 多个按钮和 if 语句

php - 如果 PHP 返回 0,则运行 jQuery 模式对话框

javascript - 将隐藏输入添加到 Stripe 表单以用作后变量

web - Magento:设置刚刚创建的网站的配置值?

php - 选择保存文件的文件夹路径