Sunday, October 3, 2010

PrestaShop Tips - How to check Paypal redirect URL and data in the form

If you are using Paypal as payment method and you experience some issues, you may want to check URL and data in the form that redirect (Post) to Paypal server. At PrestaShop, when user select Paypal as payment method, PrestaShop will automatically post order data to Paypal server and redirect user to Paypal payment page. It will help you to identify your issue quickly if you know how to check the data posted to Paypal.

Here I explain in detailed steps on how to check the URL and data in form post to Paypal. You need to have access to your source code.

1. Comment out 3 lines of modules/Paypal/redirect.php by putting two "//" before the line. (Please also see attached screen shot on how to comment out)

//$(document).ready(function() {
// $(\'#paypal_form\').submit();

2. Run a test order, this time, when you select Pyapal Payment method, it will display a white page without going to Paypal.

3. Right click the page and select "see page source" (this may different for different)

4. A HTML source file is opened in a different windows. Now you can check what is post to Paypal.

Here is a sample data(please also note the 3 lines you commented).

<html><head><script type="text/javascript" src="http://YourSite/js/jquery/jquery-1.2.6.pack.js"></script></head><body>
<form action="" method="post" id="paypal_form" class="hidden">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="address_override" value="1" />
<input type="hidden" name="first_name" value="Kinro" />
<input type="hidden" name="last_name" value="SHO" />
<input type="hidden" name="address1" value="123 ABC Avunue" />

<input type="hidden" name="city" value="Toronto" />
<input type="hidden" name="zip" value="M6J 9N4" />
<input type="hidden" name="state" value="ON" />
<input type="hidden" name="country" value="CA" />
<input type="hidden" name="amount" value="29.78" />
<input type="hidden" name="email" value="" />
<input type="hidden" name="item_name_1" value="My cart" />
<input type="hidden" name="amount_1" value="39.78" />
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="business" value="" />
<input type="hidden" name="receiver_email" value="" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="currency_code" value="CAD" />
<input type="hidden" name="payer_id" value="3" />
<input type="hidden" name="payer_email" value="" />
<input type="hidden" name="custom" value="267" />
<input type="hidden" name="return" value="http://YourSite/order-confirmation.php?key=17350b4e7c67f2f03156f49e1e0f192b&id_cart=267&id_module=4" />
<input type="hidden" name="cancel_return" value="http://YourSite/index.php" />
<input type="hidden" name="notify_url" value="http://YourSite/modules/paypal/validation.php" />
<input type="hidden" name="cpp_header_image" value="" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="bn" value="PRESTASHOP_WPS" />
<input type="hidden" name="cbt" value="Return to shop" />
<script type="text/javascript">
//$(document).ready(function() {
// $('#paypal_form').submit();

The URL of Paypal should be something like "", it may be different slightly.
The data in the form should include all data required by Paypal, otherwise an error will occurs.

5. Please don't forget to restore the ./modules/Paypal/redirect.php


Geoff B said...

Do you have updated instructions for this - it seems to be different in the latest releases of the paypal module?

Alvin said...

if you use it in API mode, then it is different, otherwise, it should be the same.

the location of the in new version of Paypal module is