7

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ox3
  • 451
  • 1
  • 6
  • 22

1 Answers1

6

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

Community
  • 1
  • 1
Rajeev K Tomy
  • 2,206
  • 1
  • 18
  • 35
  • Thanks for your reply, it seems like checkout_onepage_controller_success_action is called right after the order has been placed, and it doesn't check if the payment has been made or not, sales_order_payment_capture will not work for offline payments. Seems like there is no event to rule them all =( – Ox3 Aug 01 '14 at 02:21
  • 1
    it may help http://stackoverflow.com/questions/6193054/how-to-get-payment-method-in-an-observer-in-magento – Rajeev K Tomy Aug 01 '14 at 03:07
  • @progtammer_rkt: Thank you, seems like they suggest 'sales_order_invoice_pay' unfortunately that event was removed on Magento 1.9. I think it will be 'sales_order_invoice_register' or 'sales_order_payment_pay' I will do some testing, although it will be very helpful if someone who has successfully achieved what I need confirms which one is better. – Ox3 Aug 01 '14 at 03:17
  • nope. That event exists in magento 1.9. Take a look on `Mage_Sales_Model_Order_Invoice::pay()`. There may be some sort of mistake in your code then – Rajeev K Tomy Aug 01 '14 at 03:53
  • Thank you so much for your help, are you sure that method is still available? I checked at: http://rabee.me/codes/magento/cheatsheet/1.9/ and couldn't find it. – Ox3 Aug 01 '14 at 04:05
  • 2
    The list most probably uncomplete. Here is the file that defines that event https://github.com/speedupmate/Magento-CE-Mirror/blob/master/app/code/core/Mage/Sales/Model/Order/Invoice.php. Take a look on `pay()` method. Also check in your system also and ensure that the code looks same. – Rajeev K Tomy Aug 01 '14 at 04:23
  • Thanks for pointing out that the 'sales_order_invoice_pay' still exists on Magento 1.9, after much testing it seems that's the right event to observe. – Ox3 Aug 02 '14 at 01:09
  • @RajeevKTomy Wher i can find all the events list and their explanation? – Gem Nov 18 '19 at 05:05