PayPal Guide

Learn how to work with PayPal in BlueSnap's Payment API

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

See:

📘

Using PayPal for merchant-managed subscriptions

If you are managing subscriptions yourself (or through a third party) and want to offer the PayPal payment method for recurring subscription payments, this option is also available via the Payment API. For a tutorial, see Processing merchant-managed PayPal subscription payments.

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 to 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 step from the capture step. This is beneficial for business who may not have the goods on hand at the time of the sale.

Step 1: Build and send the Create PayPal Transaction request

When the shopper selects the PayPal checkout option, you will use the Create PayPal Transaction request to process the PayPal payment. The transaction-type should be AUTH/CAPTURE or omitted for the standard re-direct, AUTH_ONLY for the two-step flow, and SET_ORDER for the three step flow.

The request should be sent to the services/2/alt-transactions endpoint. Following is an example request:

<?xml version="1.0" encoding="UTF-8"?>
<alt-transaction xmlns="http://ws.plimus.com">
   <merchant-transaction-id>testtransaction1</merchant-transaction-id>
   <soft-descriptor>ABC COMPANY</soft-descriptor>
   <amount>100.00</amount>
   <currency>USD</currency>
   <payer-info>
      <first-name>John</first-name>
      <last-name>Doe</last-name>
   </payer-info>
   <paypal-transaction>
      <transaction-type>AUTH/CAPTURE</transaction-type>     
       <return-url>http://www.returnURL.com</return-url>
      <cancel-url>http://www.cancelURL.com</cancel-url>
      <max-amount>120.00</max-amount>
   </paypal-transaction>
</alt-transaction>
<?xml version="1.0" encoding="UTF-8"?>
<alt-transaction xmlns="http://ws.plimus.com">
   <merchant-transaction-id>testtransaction1</merchant-transaction-id>
   <soft-descriptor>ABC COMPANY</soft-descriptor>
   <amount>100.00</amount>
   <currency>USD</currency>
   <payer-info>
      <first-name>John</first-name>
      <last-name>Doe</last-name>
   </payer-info>
   <paypal-transaction>
      <transaction-type>AUTH_ONLY</transaction-type>     
       <return-url>http://www.returnURL.com</return-url>
      <cancel-url>http://www.cancelURL.com</cancel-url>
      <max-amount>120.00</max-amount>
   </paypal-transaction>
</alt-transaction>
<?xml version="1.0" encoding="UTF-8"?>
<alt-transaction xmlns="http://ws.plimus.com">
   <merchant-transaction-id>testtransaction1</merchant-transaction-id>
   <soft-descriptor>ABC COMPANY</soft-descriptor>
   <amount>100.00</amount>
   <currency>USD</currency>
   <payer-info>
      <first-name>John</first-name>
      <last-name>Doe</last-name>
   </payer-info>
   <paypal-transaction>
      <transaction-type>SET_ORDER</transaction-type>     
       <return-url>http://www.returnURL.com</return-url>
      <cancel-url>http://www.cancelURL.com</cancel-url>
      <max-amount>120.00</max-amount>
   </paypal-transaction>
</alt-transaction>

These are some important properties of the Create PayPal Transaction request:

PayPal URLs

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

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

Shopper information

You can send the request with any of the following:

  • No information about the shopper: For example, if it is a new or guest shopper, you can keep the request simple and not include any shopper details.
  • Some information about the shopper: For example, if you would like to use some of the shopper's info in order to customize the thank you page, then you can include the payer-info resource and send the shopper's name, address or other details in that resource.
  • A vaulted shopper ID: If you have already vaulted the shopper with BlueSnap, you can send the relevant vaulted-shopper-id within the alt-transaction resource. If you collect the shipping info from PayPal, then this will also be automatically updated in the vaulted shopper's profile in BlueSnap.

See Create PayPal Transaction for examples of each of the above options.

Shipping details from PayPal (for vaulted shoppers)

If you send a vaulted shopper in your Create PayPal Transaction request, you can retrieve the shopper's shipping details from PayPal. If you do so, then the vaulted shopper's record in BlueSnap will be automatically updated with the new shipping details from PayPal. To retrieve shipping info from PayPal for a vaulted shopper:

  • In the paypal-transaction resource, set the 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 req-confirm-shipping property, with the value set to 1.

  • Note: 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 in-context property in the paypal-transaction resource to true.

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

Step 2: Response to the Create PayPal Transaction request & possible errors

If successful, the response HTTP status code is 200 OK.
The response contains an alt-transaction resource with the request properties plus these additions:
paypal-transaction is returned with the paypal-url and order-id (see paypal-transaction)
processing-info

HTTP/ 1.1 200 OK

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<alt-transaction xmlns="http://ws.plimus.com">
    <soft-descriptor>ABC COMPANY</soft-descriptor>
    <amount>100.00</amount>
    <currency>USD</currency>
    <vaulted-shopper-id>12345678</vaulted-shopper-id>
    <paypal-transaction>
        <paypal-url>https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_express-checkout&token=EC-9GY47037JY601890L</paypal-url>
        <order-id>9876543</order-id>
    </paypal-transaction>
    <processing-info>
        <processing-status>PENDING</processing-status>
    </processing-info>
</alt-transaction>

Otherwise, any of the Alt Transaction Errors related to PayPal may occur.

Step 3: Redirect the shopper to the PayPal URL

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

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

Step 4: Shopper is redirected to a confirmation page

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

Two & Three Step Flows: Upon completion in PayPal, the shopper is automatically sent to the final confirmation page indicated in the return-url field in the Create PayPal Transaction request.

The return URL will contain additional parameters that you can use to display to your shoppers.

PayPal FlowURL ExampleParameters Included
Standard Redirecthttp://www.merchant-site.com/?ERROR=0&INVOICE_ID=1040698351&PAYPAL_TRANSACTION_ID=7D472473PR818573H&SELLER_ORDER_ID=><merchant-transaction-id>

Note: In the event of an error from PayPal there will be an exception included as part of the URL

  • ERROR: PayPal error code – 0 when successful otherwise error code

  • INVOICE_ID: BlueSnap’s Invoice ID

  • PAYPAL_TRANSACTION_ID: Paypal transaction ID

  • SELLER_ORDER_ID: your merchant transaction ID

Two-Step Flow
http://www.merchant-site.com/?ERROR=0&PAYPAL_TRANSACTION_ID=&ACCOUNT_ID=35714051&SELLER_ORDER_ID=><merchant-transaction-id>

  • ERROR: PayPal error code – 0 when successful otherwise error code

  • INVOICE_ID: BlueSnap’s Invoice ID

  • PAYPAL_TRANSACTION_ID: no value passed for 2-step flow

  • ACCOUNT_ID: BlueSnap’s vaulted shopper ID

  • SELLER_ORDER_ID: your merchant transaction ID


Note: You can then use the vaulted shopper ID to perform a Retrieve Vaulted Shopper call, to retrieve the shopper’s information and update the final price accordingly.
Three-Step Flowhttp://www.merchant-site.com/?ERROR=0&PAYPAL_TRANSACTION_ID=BWGL6VEKKCDLY&ACCOUNT_ID=35714091&SELLER_ORDER_ID=><merchant-transaction-id>

Note: PAYPAL_TRANSACTION_ID will hold the PayPal payer ID value

  • ERROR: PayPal error code – 0 when successful otherwise error code

  • INVOICE_ID: BlueSnap’s Invoice ID

  • PAYPAL_TRANSACTION_ID: Paypal transaction ID

  • ACCOUNT_ID: BlueSnap’s vaulted shopper ID

  • SELLER_ORDER_ID: your merchant transaction ID



Note: You can then use the vaulted shopper ID to perform a Retrieve Vaulted Shopper call, to retrieve the shopper’s information and update the final price accordingly.

📘

Note

To secure and validate the PayPal transaction, assign a unique MERCHANT-TRANSACTION-ID to every transaction. Then choose one of the following and code the logic for your return-url page:

  • Call the Retrieve PayPal Transaction API using the merchantTransactionId, 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 merchantTransactionId, date, and amount.

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 PayPal Transaction request with the order-id from the original transaction, the new price (if applicable), and set the parameter transaction-type to capture.

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 PayPal Transaction request, with the order-id from the original transaction, the new price (if applicable), and set the parameter transaction-type to DO_ORDER. This will create a pending authorization on your shopper's PayPal account for the actual amount including a new charges.

Later on, when you are ready to deliver the goods/services, you will need to create a new Update PayPal Transaction request to complete the order.

Note: A pending authorization can be left open several weeks.

If there were additional charges, you will need to modify the amount parameter with the final amount you wish to charge.

<?xml version="1.0" encoding="UTF-8"?>
<alt-transaction xmlns="http://ws.plimus.com">
   <amount>105.00</amount>
   <currency>USD</currency>
   <paypal-transaction>
      <order-id>4006145</order-id>
      <transaction-type>CAPTURE</transaction-type>
   </paypal-transaction>
</alt-transaction>
<?xml version="1.0" encoding="UTF-8"?>
<alt-transaction xmlns="http://ws.plimus.com">
   <amount>105.00</amount>
   <currency>USD</currency>
   <paypal-transaction>
      <order-id>4006145</order-id>
      <transaction-type>DO_ORDER</transaction-type>
   </paypal-transaction>
</alt-transaction>

Step 6: Complete the transaction by sending capture with final amount

Three-Step flow: When the goods/services are ready to be delivered and you have informed your customer you will debiting the final amount from their PayPal account. You now need to send a final Update PayPal Transaction request 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 transaction-type parameter from DO_ORDER to CAPTURE.

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.

<?xml version="1.0" encoding="UTF-8"?>
<alt-transaction xmlns="http://ws.plimus.com">
   <amount>104.00</amount>
   <currency>USD</currency>
   <paypal-transaction>
      <order-id>4006145</order-id>
      <transaction-type>CAPTURE</transaction-type>
   </paypal-transaction>
</alt-transaction>