{"id":8,"date":"2015-09-29T20:10:02","date_gmt":"2015-09-29T20:10:02","guid":{"rendered":"http:\/\/magebrew.com\/blog\/?p=8"},"modified":"2015-10-08T22:06:03","modified_gmt":"2015-10-08T22:06:03","slug":"magento-fix-paypal-unable-to-process-payment","status":"publish","type":"post","link":"https:\/\/magebrew.com\/blog\/magento-fix-paypal-unable-to-process-payment\/","title":{"rendered":"Magento. Fix Paypal &#8220;Unable to process payment&#8221;"},"content":{"rendered":"<p>When you enable Paypal payment method in your Magento store for the first time it might not work as expected. Pressing <em>Place Order<\/em> button redirects you to Paypal, but instead of login form you get error <em>&#8220;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.&#8221;<\/em>. Below you can find solution to your problem. <!--more--><br \/>\nHere is how this error looks like:<\/p>\n<p><a href=\"http:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/Error_Return_to_Merchant_PayPal.png\"><img loading=\"lazy\" src=\"http:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/Error_Return_to_Merchant_PayPal-1024x412.png\" alt=\"shipping address provided by the merchant is invalid\" width=\"660\" height=\"266\" class=\"aligncenter size-large wp-image-14\" srcset=\"https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/Error_Return_to_Merchant_PayPal-1024x412.png 1024w, https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/Error_Return_to_Merchant_PayPal-300x121.png 300w, https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/Error_Return_to_Merchant_PayPal.png 1914w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>In simple words Paypal doesn&#8217;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 <strong>address_override<\/strong> 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 <em>app\/code\/core\/Mage\/Paypal\/Model\/Api\/Standard.php<\/em> in <em>_importAddress<\/em> method or copy modified file to local scope (app\/code\/local\/Mage\/Paypal\/Model\/Api\/Standard.php). <a href=\"http:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/magento_paypal_address.png\"><img loading=\"lazy\" src=\"http:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/magento_paypal_address-1024x634.png\" alt=\"magento paypal address\" width=\"660\" height=\"409\" class=\"aligncenter size-large wp-image-19\" srcset=\"https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/magento_paypal_address-1024x634.png 1024w, https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/magento_paypal_address-300x186.png 300w, https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/magento_paypal_address-825x510.png 825w, https:\/\/magebrew.com\/blog\/wp-content\/uploads\/2015\/09\/magento_paypal_address.png 1428w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a> But we don&#8217;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 <em>app\/etc\/modules\/Magebrew_Paypalfix.xml<\/em>:<\/p>\n<pre><code>&lt;?xml version=\"1.0\"?&gt;\n&lt;config&gt;\n    &lt;modules&gt;\n        &lt;Magebrew_Paypalfix&gt;\n            &lt;active&gt;true&lt;\/active&gt;\n            &lt;codePool&gt;local&lt;\/codePool&gt;\n        &lt;\/Magebrew_Paypalfix&gt;\n    &lt;\/modules&gt;\n&lt;\/config&gt;\n<\/code><\/pre>\n<p>A config file <em>app\/code\/local\/Magebrew\/Paypalfix\/etc\/config.xml<\/em>:<\/p>\n<pre><code>&lt;?xml version=\"1.0\"?&gt;\n&lt;config&gt;\n    &lt;modules&gt;\n        &lt;Magebrew_Paypalfix&gt;\n            &lt;version&gt;0.0.1&lt;\/version&gt;\n        &lt;\/Magebrew_Paypalfix&gt;\n    &lt;\/modules&gt;\n    &lt;global&gt;\n        &lt;models&gt;\n            &lt;magebrew_paypalfix&gt;\n                &lt;class&gt;Magebrew_Paypalfix_Model&lt;\/class&gt;\n            &lt;\/magebrew_paypalfix&gt;\n            &lt;paypal&gt;\n                &lt;rewrite&gt;\n                    &lt;api_standard&gt;Magebrew_Paypalfix_Model_Paypal_Api_Standard&lt;\/api_standard&gt;\n                &lt;\/rewrite&gt;\n            &lt;\/paypal&gt;\n        &lt;\/models&gt;\n    &lt;\/global&gt;\n&lt;\/config&gt;\n<\/code><\/pre>\n<p>As you can see above we rewrite <em>Mage_Paypal_Model_Api_Standard<\/em> 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 <em>app\/code\/local\/Magebrew\/Paypalfix\/Model\/Paypal\/Api\/Standard.php<\/em>:<\/p>\n<pre><code>class Magebrew_Paypalfix_Model_Paypal_Api_Standard extends Mage_Paypal_Model_Api_Standard\n{\n    \/**\n     * Generate PayPal Standard checkout request fields\n     * overridden to change address_override parameter\n     *\/\n    public function getStandardCheckoutRequest()\n    {\n        $request = parent::getStandardCheckoutRequest();\n        $request['address_override'] = 0;\n        return $request;\n    }\n}\n<\/code><\/pre>\n<p>That is it. Hopefully it will work for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;Unable to process payment. Please contact the merchant as the shipping address provided by the merchant is invalid, and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/magebrew.com\/blog\/magento-fix-paypal-unable-to-process-payment\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Magento. Fix Paypal &#8220;Unable to process payment&#8221;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[3,4],"_links":{"self":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts\/8"}],"collection":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":26,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":39,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions\/39"}],"wp:attachment":[{"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/magebrew.com\/blog\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}