5

I need to execute some custom code after invoice is created

I have some code working fine, when invoices are created in admin storeview (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?

1
  • 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 Sep 12, 2017 at 21:50

1 Answer 1

6

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

5
  • 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. Apr 23, 2020 at 5:00
  • Yes, when using this event no invoice id or increment id is getting. Any solution for this?
    – amesh
    Jun 25, 2020 at 9:24
  • If you need Invoice ID then you maybe want to observe after_save event: sales_order_invoice_save_after Jun 25, 2020 at 9:57
  • @RaulSanchez i am using sales_order_invoice_save_after but no luck, can you suggest further Aug 3, 2020 at 11:29
  • You'd better create a question for this @vinit Jun 24, 2021 at 11:43

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.