When you enable Paypal payment method in your Magento store for the first time it might not work as expected. Pressing Place Order button redirects you to Paypal, but instead of login form you get error “Unable to process payment. Please contact the merchant as the shipping address provided by the merchant is invalid, and the merchant has requested that your order must be shipped to that address.”. Below you can find solution to your problem.
Here is how this error looks like:
In simple words Paypal doesn’t like shipping address of your customer that you are sending. Hopefully there is an easy way to turn off address validation, the key is in address_override request parameter. By default it is set to 1 and we will change it to 0. The dirty solution would be to change it directly in app/code/core/Mage/Paypal/Model/Api/Standard.php in _importAddress method or copy modified file to local scope (app/code/local/Mage/Paypal/Model/Api/Standard.php). But we don’t want to change core files, we want to make sure that fix will not be overridden by the next Magento update. So we are going to create a simple module. It consist of three files. Module declaration file app/etc/modules/Magebrew_Paypalfix.xml:
<?xml version="1.0"?>
<config>
<modules>
<Magebrew_Paypalfix>
<active>true</active>
<codePool>local</codePool>
</Magebrew_Paypalfix>
</modules>
</config>
A config file app/code/local/Magebrew/Paypalfix/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Magebrew_Paypalfix>
<version>0.0.1</version>
</Magebrew_Paypalfix>
</modules>
<global>
<models>
<magebrew_paypalfix>
<class>Magebrew_Paypalfix_Model</class>
</magebrew_paypalfix>
<paypal>
<rewrite>
<api_standard>Magebrew_Paypalfix_Model_Paypal_Api_Standard</api_standard>
</rewrite>
</paypal>
</models>
</global>
</config>
As you can see above we rewrite Mage_Paypal_Model_Api_Standard class, but we do it carefully in case some new logic come in next update of Paypal module. Here is how our model looks like app/code/local/Magebrew/Paypalfix/Model/Paypal/Api/Standard.php:
class Magebrew_Paypalfix_Model_Paypal_Api_Standard extends Mage_Paypal_Model_Api_Standard
{
/**
* Generate PayPal Standard checkout request fields
* overridden to change address_override parameter
*/
public function getStandardCheckoutRequest()
{
$request = parent::getStandardCheckoutRequest();
$request['address_override'] = 0;
return $request;
}
}
That is it. Hopefully it will work for you.