After 2 years of experiments in Magento, This is my first attempt to create an Observer.I had written everything in place, But iam confused with the events that i should observer for!

What i need is :

if the purchase is invoiced after successful payment
  do something 
if the invoice is from Admin Panel
  do the same thing

Current event is checkout_submit_all_after after referencing mage 1x events: i found lot of other events that can be triggered.

with different modules like :


Somebody please guide me in right direction..


Depending on the payment type, sales_order_invoice_pay is not guaranteed to be called, it's safer to use sales_order_invoice_register which is triggered during invoice creation:

See Mage_Sales_Model_Order_Invoice::register()

So your config.xml should contain:

          <your_module> <!-- any unique identifier -->

In your observer, you have access to the following parameters:

$observer->getOrder();   // the order
$observer->getInvoice(); // the invoice (not yet saved)
  • why you have call sales_order_invoice_register as safe or sales_order_invoice_pay.i guss that that reason is function pay()...Am i right ?.pay() function called depends on payment. – Amit Bera Jan 10 '16 at 10:46
  • Right, invoice->register() should always be called when invoice is created, invoice->pay() depends on the payment method, so it might not be called. – Fabian Schmengler Jan 10 '16 at 10:48
  • @fschmengler thanks for the answer. will this work for paypal processing also ? – Shan Jan 10 '16 at 14:08
  • I assume that it does. Try it out. – Fabian Schmengler Jan 10 '16 at 14:17
  • Ya ill try ... :) – Shan Jan 10 '16 at 14:33

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.