Fixing Paypal Problems

This page was written in English, please see the English version for the correct code changes.

The following tips were written for Prestashop 1.2 and 1.3, if you are using any version of Prestashop 1.4, make sure to get the latest version of the paypal module (available free at http://addons.prestashop.com/en/payments-gateways/1748-paypal.html)


1) The most common problem with paypal orders not showing up happens when paypal cannot access your server, your file/folder permissions are incorrect, or if your paypal account is not verified.


Check that the following conditions are correct:

· Your shop is not in maintenance mode (if no-one can access your site, the paypal site won't be able to either).

· There is no password protection on your site (same reason as above).

· Try to open this page from the browser - http://www.yoursite.com/modules/paypal/validation.php, if you get an error (error 500, the page cannot be displayed), than this means you have a file permission problem. Most likely, the paypal directory or the entire modules directory is set to 777 and your host doesn't allow that (it is not secure); try changing it to 755. You can also check your server's error log (from your cPanel) to get the exact error.

· Make sure your paypal account is verified, otherwise transactions don't get automatically approved and prestashop will show a payment error.


2) The most common Sandbox mode problem with the paypal module is that the orders are not showing up on the shop.

The reason for that is the paypal module is currently set up to create orders only if the response it gets from the paypal site is "Completed", however, when running in Sandbox mode, paypal sends a response of "Pending".

We have read some documentation about changing the sandbox account to send a "Completed" response, but even after trying that, payments still appeared as pending.


In order to fix that, make the following change in /modules/paypal/validation.php line #80.

It will allow for an order with a "Pending" status to go through, but only in sandbox mode.


elseif ($_POST['payment_status'] != 'Completed')

Should be changed to

elseif ($_POST['payment_status'] != 'Completed' && (!Configuration::get('PAYPAL_SANDBOX') || $_POST['payment_status'] != 'Pending'))


3) Another common problem is that orders that are placed in live mode do not show up in the backoffice, but the customer still gets charged.


This is often the case because the response from paypal is not "Completed."

There could be many reasons for that, the main ones that we've found are:

a) Your default currency in Prestashop doesn't match your paypal currency.

b) Payment is made using Echeck or other methods that require a longer time to clear.

c) Paypal decides they need to investigate the transaction.


  • You can modify the code to send you an email whenever a transaction like that happens, so you could at least know about it and contact the customer to inform them about the situation.


To do that, change the code in /paypal/validation.php (line #80) From

elseif ($_POST['payment_status'] != 'Completed' && (!Configuration::get('PAYPAL_SANDBOX') || $_POST['payment_status'] != 'Pending'))
$errors .= $paypal->getL('payment').$_POST['payment_status'].'';

To

elseif ($_POST['payment_status'] != 'Completed' && (!Configuration::get('PAYPAL_SANDBOX') || $_POST['payment_status'] != 'Pending'))

{
$errors .= $paypal->getL('payment').$_POST['payment_status'].'';
mail("[email protected]","Email payment error","There was a problem with the payment, below is the return from paypal".print_r($_POST,true));
}