Magento – Change Order status to processing automatically

checkoutorder-statusorders

I'm using a custom payment module Billdesk and I want the order status to be processing automatically when payment is completed using this module. In all other cases order status should be pending which is available in Magento by default.

While using Billdesk module if there is a due amount in that case also, I want order status to be pending by default. Here is my observer function for checkout_onepage_controller_success_action event

 <?php
class Embitel_Billdesk_Model_Observer {
    public function updateStatus($observer){        
        $order_id=Mage::getSingleton('checkout/session')->getLastOrderId(); 
        $order = Mage::getModel('sales/order')->load($order_id);           

        if($order_id){
        $order = Mage::getModel('sales/order')->load($order_id);
        $payment_method_code = $order->getPayment()->getMethodInstance()->getCode();

            if('embitel_billdesk' == $payment_method_code ){
            $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
            }
        }
    }
}

I'm not sure, how I can add the validation that order status will be set to processing when card type is credit and there is no due amount. Is there a way to check the due amount on frontend? If I'm using credit cart, will the order amount be the due amount?

Best Answer

I can give you an example how to add additional status to existed payment method.

Magento by default in system / configuration has such as 'New Order Status'.

Let's look at SavedCC:

enter image description here

Now we change system.xml file.

Original:

                    <order_status translate="label">
                        <label>New Order Status</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_order_status_new</source_model>
                        <sort_order>2</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </order_status>

You need to replace

<source_model>adminhtml/system_config_source_order_status_new</source_model>

with:

<source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>

And you will get:

enter image description here

Related Topic