PayPal Commerce Checkout (Direct API)

This PayPal implementation should be used if you are capturing the consumer’s name prior to checkout. If you allow a consumer to checkout before entering any identifiable information then use the legacy workflow.

Authorization trials (such as Hold Trial Charge, Authorize and Void, etc.) are not supported through PayPal Checkout

You must use live PayPal credentials. Using sandbox credentials will result in an error reading “Security error: Security header is not valid”


Checkout Page

Step 1: Import Click

The Checkout page contains the PayPal button. Call the Import Click API when the page loads to obtain a session.

  • Be sure to include pageType=checkoutPage and sessionId

 

Step 2: Import Order

It is important that you bind the Import Order call to the PayPal checkout button.

  • Be sure to include the sessionId and orderId from the previous steps, if known

There are five PayPal requirements that must be passed to Import Order:

  1. paySource = 'PAYPAL'

  2. forceMerchantId = the value assigned to your PayPal Commerce gateway, found on your gateway list.

  3. salesUrl = the checkout page url

  4. redirectsTo = the url of the page in your funnel that PayPal will redirect to on a successful transaction.

  5. errorRedirectsTo = the url of the page in your funnel that PayPal will redirect to on a cancelled transaction.

A successful response will return a MERC_REDIRECT exception to the page along with a PayPal url.

{ "result": "MERC_REDIRECT", "message": { "url": "https://www.paypal.com/checkoutnow?token=XXXXXXXXXXXXXXXXXX" } }

 

This example script can be used to redirect the consumer to PayPal

if (result === "MERC_REDIRECT") { if (message && message.url) { window.location.href = message.url; } }

 

Upsell Pages

Step 3: Import Click

After successful checkout, the customer proceeds to the next page in the funnel, 'upsellPage1', and another click is imported using the Import Click endpoint.

  • Be sure to include pageType=upsellPage1 and sessionId

 

Step 4: Import Upsale

One-click Upsells

PayPal supports one-click upsells using Reference Transactions. You must enable referenceTransactions on both the CRM gateway and on the backend of PayPal. You must work with PayPal to get this enabled. In most cases Reference Transactions can be enabled for North American merchants and cannot be enabled for International merchants.

If the customer chooses to buy an upsell, submit the product using standard functionality on the Import Upsale endpoint.

 

Two-click Upsells

PayPal merchants without Reference Transactions must process upsells by sending the consumer through the entire PayPal checkout flow again. The redirect instructions in the Checkout Page section above must be followed on Upsell pages.

If the customer chooses to buy an upsell, submit the product using the Import Upsale endpoint.

There are three PayPal specific requirements that must be passed to Import Upsale:

  1. paySource = 'PAYPAL'

  2. redirectsTo = the url of the page in your funnel that PayPal will redirect to on a successful upsell transaction.

  3. errorRedirectsTo = the url of the page in your funnel that PayPal will redirect to on a cancelled upsell transaction.

 

Thank You Page

Step 5: Import Click

After all upsells the customer finally lands on the Thank You (receipt) page and another click is imported using the Import Click endpoint.

  • Be sure to include pageType=thankyouPage and sessionId

 

Step 6: Confirm Order

Confirm Order is called to send the customer a confirmation email immediately.

  • Be sure to include the orderId

 

Additional Note:

Obtaining the customer’s phone number may require enabling an option on your PayPal account: