2

I integrate my website with MIGS payment Gateway.

I have an issue on orders, if customer cancel the payment from payment gateway successfully return to website and show the order as cancelled but from the admin panel order status shows as processing.

How can i update order status as cancelled.

I tried this by magento event observer. But It is not working. Following are my coding.

File Wired_Orderscancel.xml(Path:-/app/etc/modules)

<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
    <Wired_Orderscancel>
        <active>true</active>
        <codePool>local</codePool>
    </Wired_Orderscancel>
</modules>

File config.xml(Path:-\app\code\local\Wired\Orderscancel\etc)

<?xml version="1.0"?>
<config>
<modules>
    <Wired_Orderscancel>
        <version>0.1.0</version>
    </Wired_Orderscancel>
</modules>
<global>
    <models>
        <orders>
            <class>Wired_Orders_Model</class>
        </orders>
    </models>
    <helpers>
        <orders>
            <class>Wired_Orders_Helper</class>
        </orders>
    </helpers>
    <events>
        <sales_order_payment_cancel>
            <observers>
                <change_order_status>
                    <class>orders/observer</class>
                    <method>CodeOrdeStatus</method>
                </change_order_status>
            </observers>
        </sales_order_payment_cancel>
    </events>
 </global>
</config>

File Observer.php (Path:-\app\code\local\Wired\Orderscancel\Model)

class Wired_Orders_Model_Observer extends Varien_Event_Observer
{
public function CodeOrdeStatus($observer){

    $order = $observer->getEvent()->getOrder();
    $order=Mage::getModel('sales/order')->load($order->getId());


    //$order->setData('state', "complete");
    $order->setStatus("canceled");
    $order->save(); 

}
}

How can i fix this issue, Thank you

4

try

$order->cancel();
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Cancel Transaction.');
$order->setStatus("canceled");
$order->save();
  • thank you. how to track the order id? where do i want to add the code in my observer? – Mujahidh Apr 13 '15 at 13:59

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.