In previous PayPal Buy button article, I used the Auto Return URL to pass some variables. Another simple method with the same result can be achieved by using the item_number parameter of PayPal buy button.

1. Go to PayPal account and create a PayPal buy button as usual.

2. The default PayPal button will not redirect visitors to a page after the payment. We need to add the following line to the button:

<input type=”hidden” name=”return” value=”http://www.returnURL.php″>

The above line will redirect visitors to the return URL after the payment is finished.

This time no variable pass with the returnURL.

3. Add the following line to the button too. This line is used to pass the parameters (item_number) to the Auto Return URL.

<input type="hidden" name="item_number" value="alex|">

4. Prepare a webpage to test the PayPal buy button. The HTML code of the button is:

<form name="_xclick" action="" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="test buy">
<input type="hidden" name="amount" value="0.12">
<input type="hidden" name="item_number" value="alex|">
<input type="hidden" name="return" value="http://www.returnURL.php">
<input type="image" src="" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">

Here’s how the webpage look like.

5.  To demonstrate that the parameters (item_number and amount) embed in PayPal Buy button are passed to the Auto Return URL successfully, the following simple PHP codes are prepared:


$item_number = $_GET["item_number"];
$amount = $_GET["amt"];

if ((!$item_number)) {
    echo "The item_number parameter is empty!";

echo "item_number is: " . $item_number . "<br />";
echo "Amount is: " . $amount;


6.  Upload the returned URL file to my hosting server.

7. Everything is ready. Let’s try to process the payment by clicking on the PayPal button.

8. The PayPal payment screen appear. Note that the item_number parameter appear in the order summary of the checkout screen.

9. Log in the PayPal account.

10. Click on the Pay Now button to settle the payment.

11. The payment finished and redirect to the designed Auto Return URL after 10 seconds.

12. The screen of the return URL page print out the item_number and amt (amount) parameters, as shown below:

We can used this method to pass some variables with the item_number parameter to the Auto Return URL to process.