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

2021-12-19 00:00:00 php 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).

相关文章