Tuesday, October 5, 2010

PrestaShop Tips - How to fix address errors with Paypal payment

If you are using Paypal as payment method at PrestaShop 1.3 or lower, you may experience some errors in case you have no configured your shipping countries correctly. Frequently seen errors are as following:

[Error 1]
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.

[Error 2]
This country requires a state selection.

At PrestaShop version 1.3.0 or lower, by default, address does not include "State", if your address from countries like USA/Canada/China with "State", Paypal will returns above error.

Here I explain in detail on how to fxi this problem.
1. Configure your shipping country correctly if you are shipping to those countries use State.

Login to your back office of your PrestaShop
Click Shipping Tab
Click Countries menu on the Shipping tag
Find the country your going to configure, for eaxmple Canada and click "Edit" icon

2. Configure states for the country

Login to your back office of your PrestaShop
Click Shipping Tab
Click States menu on the Shipping tag
Add all states (provinces) into this table for those countries require State.

3. If you using Paypal 1.6 comes with PrestaShop 1.3.1 or lower, you need to make following changes on file /modules/paypal/redirect.php. For higher version, it is fixed already.

Insert following line after line 10 (line # may differ, see screenshot for detail)

$state = new State(intval($address->id_state));

Insert following line after line 45 (line # may differ, see screenshot for detail)

<input type="hidden" name="state" value="’.$state->iso_code.’">

After you make above changes, the errors should disappear.

Please try ot create new account with new address with "State" data for testing.
If you use existing address that does not have "State" data, the same error will occur. You need to fix those address data to make them work.


"Agile Paypal"- A PrestaShop Paypal Express Checkout module, does no have this issue or many other issues that appear in Standard Paypal module. Plus there are many new features.Check it here for more detail


Anonymous said...

Man, you don't say which file to edit...

Alvin said...

It seems that I missed the file name and location on Step 3.

Now I have added it and also get it highlighted.

Thanks for pointing out the error.