在付款捕获后调用 Magento 事件观察器

时间:2023-01-20
本文介绍了在付款捕获后调用 Magento 事件观察器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在订单创建后调用观察员,并在付款后被捕获.到目前为止,我已经尝试过;checkout_submit_all_after,sales_order_payment_place_end,sales_order_place_after,sales_order_payment_pay,sales_order_payment_capture,sales_order_payment_transaction_save_after

Im trying to call an Observer after the order has been created, and AFTER payment has been captured. So far I've tried; checkout_submit_all_after, sales_order_payment_place_end, sales_order_place_after, sales_order_payment_pay, sales_order_payment_capture, sales_order_payment_transaction_save_after

只是列举主要的.我还在 dispatchEvent() 中记录了所有事件调度,但没有发现任何突出的东西,只有在我需要它时才会被触发.我遇到的问题是订单的状态始终是付款待处理"或在此之前的状态;这意味着我不知道订单会失败还是成功.

Just to name the main ones. I've also logged all Event Dispaches inside dispatchEvent() but found nothing that stands out and is only fired when i need it. the issue i'm having is that the status of the order is always ether 'Payment Pending' or something that predated this; meaning that i don't know whether the order will fail or succeed.

我的目标是仅在成功的订单上触发一个函数.谢谢.

My aim, is to fire a function only on successful orders. thanks.

推荐答案

经过多次测试,我发现以下 Observer 可以解决问题;

after much more testing i found the following Observer to do the trick;

checkout_onepage_controller_success_action

这仅返回订单 ID,所以;

This returns just the order id, so;

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

并且您看到订单状态为处理中"并且付款已批准(或未批准).

and you see that the order status is 'processing' and the payment is aproved (or not).

这篇关于在付款捕获后调用 Magento 事件观察器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:在另一个页面中获取 magento 会话变量 下一篇:Magento 通过 phtml 文件中的锚标记调用 cms 页面

相关文章

最新文章