PayPal Guide

Learn how to work with PayPal in BlueSnap's Extended Payment API
If you have questions after reading this guide, check out our Help & Support.

This guide describes how to use the Extended Payment API to process PayPal transactions. For a general overview of our PayPal offering go here.

See:

Prerequisites

PayPal account

To offer PayPal as a payment option for your shoppers, you must have a PayPal Business or Premier account. If you do not yet have a PayPal account, you can sign up for one on the PayPal website.

Connecting your PayPal account with BlueSnap

To use PayPal with BlueSnap, begin by connecting your PayPal and BlueSnap accounts. For instructions, see Connecting PayPal and BlueSnap.

Processing PayPal transactions

📘

PayPal checkout options

  • Standard Re-direct/One-Step flow: This is the standard PayPal flow that directs your shopper to a PayPal page to confirm the purchase.
  • Two-Step Flow: The objective of the two-step flow is to provide the ability retrieve your shoppers address from their PayPal wallet and then include any necessary taxes and/or fees based on their location.
  • Three-Step Flow: The objective of the three-step flow is to separate the authorization from the capture step. This is beneficial for business who may not have the goods on hand at the time of the sale.

👍

Working with subscriptions?

Check out our Subscriptions Guide to learn more.

Step 1: Build and send the Create Shopping Context request

When the shopper selects the PayPal checkout option, you will use the Create Shopping Context request to process the PayPal payment. The request should be sent to the services/2/shopping-context endpoint. Following is an example request:

Note: The key difference between the two-step and three-step methods is the value entered in the pp-authorize-only parameter

<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>www.merchant.com</remote-host>
    <user-agent>Mozilla/5.0 (Linux; X11)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <shopper-details>
    <shopper>
      <fraud-info>
        <fraud-session-id>1234567890</fraud-session-id>
      </fraud-info>
      <shopper-info>
        <shopper-contact-info>
          <title>Mr</title>
          <first-name>ShopperPPFirst</first-name>
          <last-name>ShopperPPLast</last-name>
          <email>[email protected]</email>
          <company-name>Company PP</company-name>
          <address1>173 Willesden Ln</address1>
          <address2 />
          <city>London</city>
          <zip>NW6</zip>
          <country>UK</country>
          <phone>180098989878</phone>
          <fax>180098989878</fax>
        </shopper-contact-info>
        <store-id>10980</store-id>
        <vat-code />
        <shopper-currency>USD</shopper-currency>
        <locale>en</locale>
      </shopper-info>
    </shopper>
  </shopper-details>
  <order-details>
    <order>
      <ordering-shopper>
        <paypal>
          <pp-cancel-url>http://www.cancel-site.com</pp-cancel-url>
          <pp-return-url>http://www.success-site.com</pp-return-url>
          <pp-req-confirm-shipping>1</pp-req-confirm-shipping>
          <pp-no-shipping>0</pp-no-shipping>
          <pp-in-context>false</pp-in-context>
        </paypal>
      </ordering-shopper>
      <cart>
        <cart-item>
          <sku>
            <sku-id>2188078</sku-id>
            <sku-charge-price>
              <charge-type>initial</charge-type>
              <amount>30.00</amount>
              <currency>USD</currency>
            </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
      </cart>
      <expected-total-price>
        <amount>30.00</amount>
        <currency>USD</currency>
      </expected-total-price>
    </order>
  </order-details>
</shopping-context>
<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>www.merchant.com</remote-host>
    <user-agent>Mozilla/5.0 (Linux; X11)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <shopper-details>
    <shopper>
      <fraud-info>
        <fraud-session-id>1234567890</fraud-session-id>
      </fraud-info>
      <shopper-info>
        <shopper-contact-info>
          <title>Mr</title>
          <first-name>ShopperPPFirst</first-name>
          <last-name>ShopperPPLast</last-name>
          <email>[email protected]</email>
          <company-name>Company PP</company-name>
          <address1>173 Willesden Ln</address1>
          <address2 />
          <city>London</city>
          <zip>NW6</zip>
          <country>UK</country>
          <phone>180098989878</phone>
          <fax>180098989878</fax>
        </shopper-contact-info>
        <store-id>10980</store-id>
        <vat-code />
        <shopper-currency>USD</shopper-currency>
        <locale>en</locale>
      </shopper-info>
    </shopper>
  </shopper-details>
  <order-details>
    <order>
      <ordering-shopper>
        <paypal>
          <pp-cancel-url>http://www.cancel-site.com</pp-cancel-url>
          <pp-return-url>http://www.success-site.com</pp-return-url>
          <pp-req-confirm-shipping>1</pp-req-confirm-shipping>
          <pp-no-shipping>0</pp-no-shipping>
          <pp-in-context>false</pp-in-context>
          <pp-authorize-only>1</pp-authorize-only>
          <pp-authorize-max-amount>55.00</pp-authorize-max-amount>
        </paypal>
      </ordering-shopper>
      <cart>
        <cart-item>
          <sku>
            <sku-id>2188078</sku-id>
            <sku-charge-price>
              <charge-type>initial</charge-type>
              <amount>30.00</amount>
              <currency>USD</currency>
            </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
      </cart>
      <expected-total-price>
        <amount>30.00</amount>
        <currency>USD</currency>
      </expected-total-price>
    </order>
  </order-details>
</shopping-context>
<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>www.merchant.com</remote-host>
    <user-agent>Mozilla/5.0 (Linux; X11)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <shopper-details>
    <shopper>
      <fraud-info>
        <fraud-session-id>1234567890</fraud-session-id>
      </fraud-info>
      <shopper-info>
        <shopper-contact-info>
          <title>Mr</title>
          <first-name>ShopperPPFirst</first-name>
          <last-name>ShopperPPLast</last-name>
          <email>[email protected]</email>
          <company-name>Company PP</company-name>
          <address1>173 Willesden Ln</address1>
          <address2 />
          <city>London</city>
          <zip>NW6</zip>
          <country>UK</country>
          <phone>180098989878</phone>
          <fax>180098989878</fax>
        </shopper-contact-info>
        <store-id>10980</store-id>
        <vat-code />
        <shopper-currency>USD</shopper-currency>
        <locale>en</locale>
      </shopper-info>
    </shopper>
  </shopper-details>
  <order-details>
    <order>
      <ordering-shopper>
        <paypal>
          <pp-cancel-url>http://www.cancel-site.com</pp-cancel-url>
          <pp-return-url>http://www.success-site.com</pp-return-url>
          <pp-req-confirm-shipping>1</pp-req-confirm-shipping>
          <pp-no-shipping>0</pp-no-shipping>
          <pp-in-context>false</pp-in-context>
          <pp-authorize-only>2</pp-authorize-only>
          <pp-authorize-max-amount>55.00</pp-authorize-max-amount>
        </paypal>
      </ordering-shopper>
      <cart>
        <cart-item>
          <sku>
            <sku-id>2188078</sku-id>
            <sku-charge-price>
              <charge-type>initial</charge-type>
              <amount>30.00</amount>
              <currency>USD</currency>
            </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
      </cart>
      <expected-total-price>
        <amount>30.00</amount>
        <currency>USD</currency>
      </expected-total-price>
    </order>
  </order-details>
</shopping-context>

These are some important properties of the request:

PayPal URLs

Within the paypal resource, you will need to specify two different URLs:

  • pp-cancel-url: URL where the shopper will be redirected if cancelling the PayPal purchase.
  • pp-return-url: URL where the shopper will be redirected upon completing the PayPal purchase (i.e. your "thank you" page)

Shopper information

You can send the request with shopper information, as shown in the example above. Alternatively, if this is an existing shopper, you can include the shopper-id in the request.

Shipping details from PayPal (for existing shoppers)

If you send a shopper-id in your request, you can retrieve the shopper's shipping details from PayPal. If you do so, BlueSnap will use the information retrieved from PayPal to automatically populate the shipping-contact-info and shopper-contact-info resources.

To retrieve shipping info from PayPal for a shopper:

  • In the paypal resource, set the pp-no-shipping property to 0
  • If you only want the shipping info to be retrieved if it has been specifically confirmed by the shopper in PayPal, then you should also include the pp-req-confirm-shipping property, with the value set to 1.

If you already have your shopper details, we recommend that you set the pp-no-shipping parameter to 1. In this case, the shopper will not be requested to validate their shipping address and BlueSnap will not retrieve it.

This feature is not available if BlueSnap collects US sales tax or EU VAT for you.

📘

Retrieving the shopper's phone number

The shopper’s phone number will not be automatically retrieved. If you are specifically interested in retrieving the phone number, please ensure you configure the Contact Telephone Number setting to Off. This setting is in your PayPal account under My Account > Profile > My selling tools > Website Preferences.

In-Context checkout

If you would like to enable In-Context PayPal checkout, set the pp-in-context property in the paypal resource to true.

For more information about the shopper experience with PayPal, click here.

Step 2: Response to the Create Shopping Context request & possible errors

If successful, the response HTTP status code is 201 Created.
The Location response header contains the URI of the newly created shopping-context resource.
The shopping-context resource is also returned in the response body.

Otherwise, any of the Payment & Processor Errors related to PayPal may occur.

HTTP/ 1.1 201 Created

<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <step>CREATED</step>
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>www.merchant.com</remote-host>
    <user-agent>Mozilla/5.0 (Linux; X11)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <order-details>
    <order>
      <order-id>3981977</order-id>
      <seller-order-id>364444</seller-order-id>
      <ordering-shopper>
        <shopper-id>19564900</shopper-id>
      </ordering-shopper>
      <transaction-payment-info>
        <paypal-info>
          <url>https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_express-checkout&token=EC-22562160R8730154V</url>
        </paypal-info>
      </transaction-payment-info>
      <cart>
        <charged-currency>USD</charged-currency>
        <cart-item>
          <sku>
            <sku-id>2186520</sku-id>
            <sku-name>recurring</sku-name>
          </sku>
          <quantity>1</quantity>
          <item-sub-total>30.00</item-sub-total>
        </cart-item>
        <tax>0.00</tax>
        <tax-rate>0</tax-rate>
        <total-cart-cost>30.00</total-cart-cost>
      </cart>
    </order>
  </order-details>
</shopping-context>

Step 3: Redirect the shopper to the PayPal URL

The response includes a url field in paypal-info. This is the URL for the checkout page in PayPal where the shopper can confirm the purchase. In the example response above, the URL is:
https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_express-checkout&token=EC-22562160R8730154VL

When you receive the response, you should redirect the shopper to this URL so that he or she can continue the checkout process in PayPal.

Step 4: Shopper is redirected to the final page

Standard Checkout Flow

Upon completing checkout in PayPal, the shopper is automatically sent to the "thank you" page you indicated in the pp-return-url field in the Create Shopping Context request. On this page, you may wish to display the PayPal order number and other details about the purchase.

URL example:
http://merchant-site.com/paypal-success?ERROR=0&INVOICE_ID=987654&PAYPAL_TRANSACTION_ID=9M8R7X6LYE7P4&SELLER_ORDER_ID=null

📘

Note

  • In the event of an error from PayPal there will be an exception included as part of the URL
  • To secure and validate the PayPal transaction, assign a unique SELLER_ORDER_ID to every transaction. Then choose one of the following and code the logic for your pp-return-url page:
    • Call the Retrieve Order API using the SELLER_ORDER_ID, and validate the date and amount of the transaction.
    • Or enable IPNs and code logic to check that an IPN is received for the PayPal transaction with the same SELLER_ORDER_ID, date, and amount.

Parameters included:

  • PayPal error (success or error code)
  • Invoice_ID (BlueSnap's transaction ID)
  • PayPal Transaction ID
  • Seller Order ID (your own transaction ID)

Two- & Three-Step Flows:

Upon completion in PayPal, the shopper is automatically sent to the final confirmation page indicated in the pp-return-url field in the Create Shopping Context request.

URL example:
http://merchant-site.com/paypal-success?ERROR=0&PAYPAL_TRANSACTION_ID=9M8R7X6LYE7P4&ACCOUNT_ID=19598172&SELLER_ORDER_ID=null

Parameters included:

  • PayPal error (success or error code)
  • Account_ID (BlueSnap’s Shopper ID)
  • Seller Order ID (your own transaction ID)

Step 5: Complete the process or Create Pending Authorization

  • Standard Checkout Flow: Step 5 is not applicable when using the PayPal standard flow.
  • Two-Step Flow: To finalize this order and have the payment processed, you must send an Update Shopping Context request and change the value of the step parameter from CREATED to PLACED. You can now redirect your shopper to a final thank you page confirming transaction details.
  • Three-Step flow: In the previous step you presented your shopper with the final amount including any additional charges. You now need to create an Update Create Shopping Context call, to create a pending authorization on your shopper’s PayPal account, for the final amount including charges. Please change the value of the step parameter from CREATED to PAYPAL_ORDER.

Later, when you are ready to deliver the goods/services, you need to create a new Update Shopping Context call, to complete the order.

📘

Note

A pending authorization can be left open several weeks.

If there were additional charges, you can create this call with two different SKUs (your main product, and the additional charges) so your shopper is able to see the two charges separately.

<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <step>PLACED</step>
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>  </remote-host>
    <user-agent>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.3; .NET CLR 2.0.50727)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <order-details>
    <order>
      <ordering-shopper>
        <shopper-id>19587614</shopper-id>
      </ordering-shopper>
      <cart>
        <cart-item>
          <sku>
            <sku-id>2176834</sku-id>
            <sku-charge-price>
              <charge-type>initial</charge-type>
              <amount>49.99</amount>
              <currency>USD</currency>
            </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
        <cart-item>
          <sku>
            <sku-id>2176874</sku-id>
            <sku-charge-price>
             <charge-type>initial</charge-type>
             <amount>4.21</amount>
             <currency>USD</currency>
          </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
      </cart>
      <expected-total-price>
        <amount>54.20</amount>
        <currency>USD</currency>
      </expected-total-price>
    </order>
  </order-details>
</shopping-context>
<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <step>PAYPAL_ORDER</step>
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>  </remote-host>
    <user-agent>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.3; .NET CLR 2.0.50727)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <order-details>
    <order>
      <ordering-shopper>
        <shopper-id>19587614</shopper-id>
      </ordering-shopper>
      <cart>
        <cart-item>
          <sku>
            <sku-id>2176834</sku-id>
            <sku-charge-price>
              <charge-type>initial</charge-type>
              <amount>49.99</amount>
              <currency>USD</currency>
            </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
        <cart-item>
          <sku>
            <sku-id>2176874</sku-id>
            <sku-charge-price>
             <charge-type>initial</charge-type>
             <amount>4.21</amount>
             <currency>USD</currency>
          </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
      </cart>
      <expected-total-price>
        <amount>54.20</amount>
        <currency>USD</currency>
      </expected-total-price>
    </order>
  </order-details>
</shopping-context>

Step 6: Complete the transaction by creating Update Shopping Context with final amount

The goods/ services are ready to be delivered. You have informed your customer that you will debit the final amount from their PayPal account.

You'll need to perform an Update Shopping Context call to complete the transaction and move it from a pending authorization to a captured charge. To accomplish this you will need to change the value of the step parameter from PAYPAL_ORDER to PLACED.

It is still possible to modify this final amount once more, but please make sure the shopper is aware of the final amount being charged and that they have received an updated receipt/invoice.

📘

Note

The final amount can (and will most likely) be higher than the one originally approved by your shopper on step #3, but it cannot exceed the pp-authorize-max-amount parameter passed in the Create Shopping Context.

<?xml version="1.0" encoding="UTF-8"?>
<shopping-context xmlns="http://ws.plimus.com">
  <step>PAYPAL_ORDER</step>
  <web-info>
    <ip>62.219.121.253</ip>
    <remote-host>  </remote-host>
    <user-agent>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.3; .NET CLR 2.0.50727)</user-agent>
    <accept-language>en-us</accept-language>
  </web-info>
  <order-details>
    <order>
      <ordering-shopper>
        <shopper-id>19587614</shopper-id>
      </ordering-shopper>
      <cart>
        <cart-item>
          <sku>
            <sku-id>2176834</sku-id>
            <sku-charge-price>
              <charge-type>initial</charge-type>
              <amount>49.99</amount>
              <currency>USD</currency>
            </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
        <cart-item>
          <sku>
            <sku-id>2176874</sku-id>
            <sku-charge-price>
             <charge-type>initial</charge-type>
             <amount>4.21</amount>
             <currency>USD</currency>
          </sku-charge-price>
          </sku>
          <quantity>1</quantity>
        </cart-item>
      </cart>
      <expected-total-price>
        <amount>54.20</amount>
        <currency>USD</currency>
      </expected-total-price>
    </order>
  </order-details>
</shopping-context>