I have tried the following events for invoice creation observer:
sales_order_invoice_save_after
sales_order_invoice_pay
sales_order_invoice_register
sales_order_invoice_save_commit_after
controller_action_postdispatch_sales_order_invoice_save
and in the observer I am calling:
$invoice = $observer->getEvent()->getInvoice();
$invoice_id = $item->getData('entity_id');
For all of the above events, the entity_id is received as null. Also the observer is called before there is a new entry in the database.
What is the correct event to get invoice id after it is saved?
sales_order_invoice_save_commit_after
this saved my life.