I'm trying to send orders to a third-party after and ONLY after an order has been paid and has now been set to 'Processing' as status. What's the best observer to use to set up this to work for all payments types?

After reading several sources it seems like:


Should work for all payment methods but it seems like it has been removed on Magento 1.9: http://rabee.me/codes/magento/cheatsheet/1.9/

The other option was:


But when I test it setting the payment method to "Check / Money order" it is NOT fired after I generate the invoice on backend using Order > Invoice > Submit Invoice

Is this method only called with the other payment methods? (paypal/authotize.net)


After reading: this other question it seems like the only way to guarantee that I'm exporting the order AFTER a payment (online or offline) has been made is to capture when an invoice is created, and that for Magento 1.9 the right observer is:


Are invoices automatically created and sent after payment on online methods paypal/authotize.net? Will this still be true when using them on sandbox/test mode?

Thank you so much for your help

1 Answer 1


I use as follows:

1 - app/code/loca/Packagename/Modulename/etc/config.xml

    <!-- here I am listing only major routines  -->
                <cron_expr>12 * * * *</cron_expr>
                <cron_expr>*/5 * * * *</cron_expr>

2 - app/code/loca/Packagename/Modulename/Model/Rewrite/Order.php

class Packagename_Modulename_Model_Rewrite_Order extends Mage_Sales_Model_Order{

public function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false){
    // attempt to set the specified state
    // tenta definir o status especificado
    if ($shouldProtectState) {
        if ($this->isStateProtected($state)) {
                Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state)
    $this->setData('state', $state);

    // add status history
    if ($status) {
        if ($status === true) {
            $status = $this->getConfig()->getStateDefaultStatus($state);
        $history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
        $history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility

    Mage::dispatchEvent('packagename_modulename_order_status_change', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified));              
    Mage::log("Packagename_Modulename_Model_Rewrite_Order Changing order to STATE ".$state." STATUS ".$status);
    return $this;


3 - app/code/loca/Packagename/Modulename/Model/Rewrite/Observer.php

class Packagename_modulename_Model_Rewrite_Observer{

public function implementOrderStatus($event){
    $order = $event->getOrder();
    $state = $event->getState();
    $status = $event->getStatus();
    return $this;

public function changeStateOrder($observer){
    $order = $observer->getEvent()->getOrder();       

    if($order->getStatus() == "processing_paid"){
    else if($order->getStatus() == "processing_shipped"){

    // use your necessary ifs

    return $this;

public function autoShipment(Mage_Sales_Model_Order $order){ 

public function autoInvoicing(Mage_Sales_Model_Order $order){ 
    //return $this;

public function sendTransactionalEmail(Mage_Sales_Model_Order $order){

    switch ($order->getStatus()) {            
        case "processing":
            $templateId = 1;                        
        case "pending_payment":
            $templateId = 0;                        
            $templateId = 0;


public function runSendOrderToERP($schedule){

public function runReceiveERPStatusOrder($schedule){        

//And much more another methods can be used after change state / status order: refund, calcel, etc

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.