How do I add PayPal Checkout to my custom shopping cart?

There are two ways to integrate PayPal payment processing with your third-party shopping cart:

  • Pass the aggregate cart amount instead of the price of each item.
  • Pass details of each item.

Note: Posting the necessary variables to PayPal as described will probably require you to implement some scripting on your website.

Method 1: Passing the aggregate cart amount to PayPal

You can pass the total amount of your shopping cart into PayPal's Buy Now Button code as though it were a single-item purchase. Start by incorporating the required variables and image, and then customize your form with any of our additional and extended variables.

Required variables and image

The following table describes the five hidden variables and the form submit image that the code for your PayPal post requires

Name 

Description 

amount 

The total price of all the items in the shopping cart. 

business 

Your PayPal account's email address. 

currency_code 

Defines the currency type (such as "USD" and "EUR") that the monetary variables (amount, shipping, shipping2, handling, tax) are using. 

image 

Indicates the image for the payment button. You can change this by replacing the src attribute with the URL of your chosenimage. 

item_name 

The name of the item or the shopping cart. 

The minimum required code for your post to PayPal should look like the following example:

<input type="hidden" name="cmd" value="_ext-enter">
<form action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_xclick">
  <input type="hidden" name="business" value="you@youremail.com">
  <input type="hidden" name="item_name" value="Item Name">
  <input type="hidden" name="currency_code" value="USD">
  <input type="hidden" name="amount" value="0.00">
  <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

Additional variables

Visit HTML Variables for PayPal Payments Standard for a list of additional variables that can be passed for your button.

Method 2: Passing individual items to PayPal

If you can configure your third-party shopping cart to pass individual items to PayPal, the buyers' and sellers' history logs and notifications include information about those items. To include information about the items, post the HTML form elements to a new shopping cart flow. This process is similar to the one described in Method 1, with the following exceptions:

First, change the "cmd" input from:

<input type="hidden" name="cmd" value="_xclick">

To:

<input type="hidden" name="cmd" value="_cart">


Item-specific variables

For each of the item-specific variables, do the following:

  • Define a new set of values corresponding to each item purchased via your third-party cart.
  • Append "_x" to the variable name, where "x" is the item number.
  • Set the quantity at 1 and increment each time to reflect the increase in the amount of that specific item.
  • Include a set of required variables from the table below for each item in your buyers' cart.
  • Define the first item included in the cart with parameters that end with "_1" (such as item_name_1 and amount_1), the second item with "_2" (such as item_name_2 and amount_2), and so on.
  • Optional variables can be included. See HTML Variables for PayPal Payments Standard.

Note: The "_x" values must increment by one continuously for PayPal to recognize it. If you skip from item #1 to item #3 without defining item #2, item #3 is ignored.

All monetary variables (amount, shipping, shipping2, handling, tax) reflect the currency designated by the currency_code variable posted with the payment. This is not item-specific, so you don't need to append a "_x" to the variable name. If no currency_code variable is posted, the default is US Dollars.

The following table describes the item-specific variables.

Name 

Description 

amount_x 

The price of that specific item (required per item).

item_name_x 

The name (127-alphanumeric character limit) of that specific item (required per item). 

More ways we can help

If you accept cookies, we'll use them to improve and customise your experience and enable our partners to show you personalised PayPal ads when you visit other sites. Manage cookies and learn more