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..

1 Answer 1


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
    Commented Jan 10, 2016 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. Commented Jan 10, 2016 at 10:48
  • @fschmengler thanks for the answer. will this work for paypal processing also ?
    – Shan
    Commented Jan 10, 2016 at 14:08
  • I assume that it does. Try it out. Commented Jan 10, 2016 at 14:17
  • Ya ill try ... :)
    – Shan
    Commented Jan 10, 2016 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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