4

I need to execute some custom code after invoice is created

I have some code working fine, when invoices are created in backoffice (I am observing sales_order_save_before event & checking for a state change to detect if the invoice has been created), but this does not work when 3rd party payment methods create the invoice during frontend checkout process

I am not sure if I can achieve this with observer / event approach, or maybe a plugin should be the right method. Any tips?

  • 2
    Have you tried using this event on the front end? this shoul give you the result your looking for no matter the gateway sales_order_invoice_save_after – Dava Gordon Sep 12 '17 at 21:50
4

I finally solved this using sales_order_invoice_pay event, which is fired both in adminhtml & frontend scopes

| improve this answer | |
  • Thanks it work. but when use 'sales_order_invoice_pay' event i am not able to get invoice id or increment id can you help how can i get invoice id. – Chandresh Chauhan Apr 23 at 5:00
  • Yes, when using this event no invoice id or increment id is getting. Any solution for this? – amesh Jun 25 at 9:24
  • If you need Invoice ID then you maybe want to observe after_save event: sales_order_invoice_save_after – Raul Sanchez Jun 25 at 9:57
  • @RaulSanchez i am using sales_order_invoice_save_after but no luck, can you suggest further – Vinit Kumar Aug 3 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.