Saturday, July 30, 2011

Magento Can’t create Sales Orders in Admin—No Payment Method Available

It basically involves 2 simple changes to 2 files. As well as uploading the template files from the /frontend/ for your payment processor to /adminhtml/.

My payment processors are PayPal Standard and Worldpay (I guess this hack can be applied for other payment processors too)

The 2 files that need changing…

1. app/code/core/Mage/Payment/Block/Form/Container.php

 public function getMethods()
 {
        $methods = $this->getData('methods');
        if (is_null($methods))
        {
            $store = $this->getQuote() ? $this->getQuote()->getStoreId() : null;
            $methods = $this->helper('payment')->getStoreMethods($store, $this->getQuote());
                      
            foreach ($methods as $key => $method)
            {         
                if ($this->_canUseMethod($method)) 
                {
                    $this->_assignMethod($method);
                }
                // HACK
                // commented this out to force Paypal and Worldpay to show when create order in admin
                /* else  {
                   unset($methods[$key]);
                }
                */
            }
            $this->setData('methods', $methods);
        }
       return $methods;
    }

2. app/code/core/Mage/Paypal/Model/Standard.php

/*validate the currency code is avaialable to use for paypal or not*/
    public function validate()
    {
        parent::validate();
         // HACK...
        // commented out line below and set $currency_code = "GBP", to fix error currency not supported by PayPal
        // we only use GBP so this should not cause a problem
        // $currency_code = $this->getQuote()->getBaseCurrencyCode();
        $currency_code = "GBP";
               
        if (!in_array($currency_code,$this->_allowCurrencyCode)) {
            Mage::throwException(Mage::helper('paypal')->__('Selected currency code ('.$currency_code.') is not compatible with PayPal'));
        }
        return $this;
    }

The files that I needed to copy from /frontend/ to /adminhtml/

1. app/design/adminhtml/default/default/template/paypal/standard/form.phtml
2. app/design/adminhtml/default/default/template/worldpay/failure.phtml
3. app/design/adminhtml/default/default/template/worldpay/form.phtml

If you choose to follow these notes you do so at your own risk. Maybe somebody else in these article that know far more than me could comment or improve it!

Tags : Payment method is not available message when taking orders in magento,MagentoAdmin side Payment Method not dispaly, Magento Admin side No Payment Method Available

2 comments:

Thanks a lot, This is exactly what i have been looking for. Thanks again

Great Read! I am impressed on how you make your article easy to understand. I'll come back for more :D

Japs Buidon is a Social Media Specialist and belongs to a team of Magento Developer in Florida. He loves hiking as well as electronics.

Post a Comment