I’m trying onepage checkout. When I'm exiting 2co payment page by clicking on Place order button I'm navigating back to my site and the URL looks like this.


and I got an error on the page as shown below

Fatal error: Call to a member function getMethodInstance() on a non-object in /home/xxx/public_html/store/app/code/core/Mage/Payment/Model/Observer.php on line 46

I have no idea and PHP knowledge to fix it.

Could anyone help me?

  • Have you done any customization, or added any checkout related extension? Commented Aug 7, 2014 at 6:10
  • No use any checkout related extension for this site. Commented Aug 7, 2014 at 7:00
  • Try disabling your other extensions one by one and check if it still exists Commented Aug 7, 2014 at 7:44
  • Reinstall or upgrade your payment module. Commented Jul 15, 2015 at 7:04

6 Answers 6


Even with very little PHP knowledge, you can always diagnose issues thanks to Magento's error reporting mechanism.

This error indicates the exact file & line of code which are responsible for it, so take the following steps:

  1. Navigate through app/code/core/Mage/Payment/Model/ & open Observer.php,
  2. Scroll to line 46

The line of code in 1.7 reads as follows:

if ($order->getPayment()->getMethodInstance()->getCode() != 'free') {

Now, the error message also tells you that the following code is what is causing the issue:

Call to a member function getMethodInstance()

So after you read the line of code on line 46, you'll see that that method is applied to the $order object, this is defined just above line 46 (on line 44):

$order = $observer->getEvent()->getOrder();

Now, knowing PHP you'd know that if the event did not catch the order correctly, the error would have been thrown here, I.E. on line 44, but it wasn't which means that it was caught correctly.

THUS, you can establish that the issue is with your payment method, because $order->getPayment() is a non object according to the error message.

You're likely using a modified payment method of some sorts which needs to be diagnosed.

  • So, how to get payment code?
    – Bojjaiah
    Commented Feb 18, 2016 at 6:20

Please check if the payment module redirects you to an insecure page (http://).

If you're using https in the checkout and the module redirects to a non-secure redirect page, Magento will throw you this error.


If order is loaded by loadByIncrementId($orderId) and orderId is not valid, $order->save() will then cause this exact error. Check anywhere in code where an order is being saved, thus causing the function salesOrderBeforeSave to run in the file the error indicates, breaking at $order->getPayment()->getMethodInstance()->getCode().


I believe you are doing something like this:

$order = Mage::getModel('sales/order')->load(300000112);

i.e trying to load order with increment id. Instead use this:

$order = Mage::getModel('sales/order')->loadByIncrementId(300000112);


I have the same problem with a gateway and resolve it. Review the documentation of payment gateway about the response variables naming. Must be the same with your OK/NOT OK page


Go to system >configuration >advanced >advanced just enable and save your payment method

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.