Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the right magento observer event to capture order paid?

I'm trying to send orders to a third-party after and ONLY after an order has been paid and has now been set to 'Processing' as status. What's the best observer to use to set up this to work for all payments types?

After reading several sources it seems like:

sales_order_invoice_pay

Should work for all payment methods but it seems like it has been removed on Magento 1.9: http://rabee.me/codes/magento/cheatsheet/1.9/ (This list is incomplete, please check the updates below )

The other option was:

'sales_order_payment_pay'

But when I test it setting the payment method to "Check / Money order" it is NOT fired after I generate the invoice on backend using Order > Invoice > Submit Invoice

Is this method only called with the other payment methods? (paypal/authorize.net)

UPDATE:

After reading: this other question it seems like the only way to guarantee that I'm exporting the order AFTER a payment (online or offline) has been made is to capture when an invoice is created, and that for Magento 1.9 the right observer is:

sales_order_invoice_register

Are invoices automatically created and sent after payment on online methods paypal/authorize.net? Will this still be true when using them on sandbox/test mode?

UPDATE 2:

After much testing it seems that 'sales_order_invoice_pay' is the right method to use to achieve what I needed.

like image 569
Ox3 Avatar asked Aug 01 '14 00:08

Ox3


People also ask

In which order the observers will get executed which are listening to the same event?

Observers listening to the same event may be invoked in any order when that event is dispatched.

What is event observer in Magento?

Observers are a certain type of Magento class that can influence general behavior, performance, or change business logic. Observers are executed whenever the event they are configured to watch is dispatched by the event manager.

What is difference between observer and plugin in Magento 2?

Observers are less versatile than plugins. Plugins can alter the functionality of any Magento public method (except for virtual and final classes, final, static and non-public methods, constructors, and objects instantiated before bootstrapping Magento\Framework\Interception).


1 Answers

What about checkout_onepage_controller_success_action. This can be used if your order payment is success. There is another event sales_order_payment_capture. It may also use in your case. I didn't use it before.

Check this LINK

EDIT

As per discussion, it seems that sales_order_invoice_pay is the perfect observer for capturing order paid and that event is still available in Magento 1.9. (not deprecated)

For more reference, check out this Link

like image 123
Rajeev K Tomy Avatar answered Oct 04 '22 07:10

Rajeev K Tomy