# PayPal Commerce Checkout (Legacy)

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FNGe8MZxCV3Li6SrmMIkA%2FUntitled.png?alt=media&#x26;token=1f5b82a2-c6e1-4a45-bce3-97a36d963816" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
This PayPal implementation should be used if you expect a consumer to checkout without entering any identifiable information. If however you are capturing the consumer’s name prior to checkout (including on a lead page), then you may find it simpler to use this [improved workflow](https://help.checkoutchamp.com/crm/gateway-setup/gateway-integrations/paypal-commerce-checkout/paypal-commerce-checkout-direct-api) to process PayPal transactions.
{% endhint %}

{% hint style="warning" %}
Authorization trials (such as Hold Trial Charge, Authorize and Void, etc.) are not supported through PayPal Seamless Checkout
{% endhint %}

{% hint style="danger" %}
You must use live PayPal credentials. Using sandbox credentials will result in an error reading “Security error: Security header is not valid”
{% endhint %}

{% hint style="danger" %}
If your account requires FraudNet, send the FraudNet data in the paypalClientMetadataId parameter when calling Import Order and Confirm PayPal API.
{% endhint %}

{% hint style="info" %}
PayPal can process direct credit cards if your account is setup properly. Card processing on a PayPal Commerce gateway requires no special handling. Process the card using a normal checkout flow or using [3DS flow](https://help.checkoutchamp.com/crm/gateway-setup/direct-api-3ds-instructions). This document assumes you are processing using PayPal checkout and NOT direct credit cards.
{% endhint %}

{% hint style="info" %}
Use of a Lead Page is recommended but not required. Be sure to note the additional values that must be passed in Step 6 to complete checkout without it.
{% endhint %}

***

EXAMPLE PAYPAL CHECKOUT WORKFLOW

### Presell Page <a href="#paypalcommercecheckout-legacy-presellpage" id="paypalcommercecheckout-legacy-presellpage"></a>

**Step 1:** [**Import Click**](https://apidocs.checkoutchamp.com/?version=latest#e576c9e1-2606-49c2-8ac0-143a35c7add2) **-** [**https://api.checkoutchamp.com/landers/clicks/import/?**](https://api.checkoutchamp.com/landers/clicks/import/)

Customer lands on the ‘presellPage’ of the funnel and a click is imported using the Import Click endpoint.

* Be sure to include pageType=presellPage and the requestUri (include affiliate tracking string for reporting)

*The response from this call will contain a **sessionId** which should be sent on all subsequent API calls for this session.*

**SUCCESS**

```
{
    "result": "SUCCESS",
    "message": {
        "sessionId": "a27dbdf0a6e047dc84c5cc542e7608c3"
    }
}
```

### Lead Page <a href="#paypalcommercecheckout-legacy-leadpage" id="paypalcommercecheckout-legacy-leadpage"></a>

{% hint style="danger" %}
Use of a Lead Page is recommended but not required. Be sure to note the additional values that must be passed in Step 6 to complete checkout without it.
{% endhint %}

**Step 2:** [**Import Click**](https://apidocs.checkoutchamp.com/?version=latest#e576c9e1-2606-49c2-8ac0-143a35c7add2) **-** [**https://api.checkoutchamp.com/leads/import/?**](https://api.checkoutchamp.com/leads/import/?)

Customer proceeds to the next page in the funnel, the 'leadPage', and another click is imported using the Import Click endpoint.

* Be sure to include pageType=leadPage and sessionId

{% hint style="info" %}
If this is the first page of the funnel -

Send requestUri (include affiliate tracking string for reporting) instead of sessionId.

*The response from this call will contain a **sessionId** which should be sent on all subsequent API calls for this session.*
{% endhint %}

**Step 3:** [**Import Lead**](https://apidocs.konnektive.com/?version=latest#05f9224f-913c-4129-95c7-ed078a87e6f0) **-** [**https://api.checkoutchamp.com/leads/import/?**](https://api.checkoutchamp.com/leads/import/?)

Once the customer fills in and submits the lead form, a new lead is created with the Import Lead endpoint.

* Be sure to include the sessionId that was returned from your first Import Click call.

*The response from a properly formed import lead call will contain an **orderId**. Save this value for steps 5, 6, 8, & 10.*

**SUCCESS**

```
{
    "result": "SUCCESS",
    "message": {
        "orderId": "5FFF3B1F5D",
        "orderStatus": "PARTIAL",
        "campaignId": 6,
        "firstName": "Boss",
        "lastName": "Cat",
        "emailAddress": "BossCat@fakeemail.com",
        "phoneNumber": "1231231234",
        "shipAddress1": "100 Alley Cat Lane",
        "billShipSame": true,
        "shipCountry": "US",
        "sessionId": "a27dbdf0a6e047dc84c5cc542e7608c3",
        "userAgent": "Mozilla\/5.0 (X11; Linux i686) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/57.0.2987.98 Safari\/537.36",
        "acceptHeader": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8",
        "ipAddress": "107.142.169.24",
        "httpReferer": "https:\/\/myserver.com\/PAYPAL_TEST\/",
        "orderType": "NEW_SALE",
        "shipFirstName": "Boss",
        "shipLastName": "Cat",
        "customerId": 67,
        "agentUserId": 202,
        "dateUpdated": "2017-07-19 16:40:32"
    }
}
```

### Checkout Page <a href="#paypalcommercecheckout-legacy-checkoutpage" id="paypalcommercecheckout-legacy-checkoutpage"></a>

**Step 4:** [**Import Click**](https://apidocs.checkoutchamp.com/?version=latest#e576c9e1-2606-49c2-8ac0-143a35c7add2) **-** [**https://api.checkoutchamp.com/landers/clicks/import/?**](https://api.checkoutchamp.com/landers/clicks/import/)

After a successful submission of the Lead Page, the customer proceeds to the next page in the funnel, the 'checkoutPage', and another click is imported using the Import Click endpoint.

* Be sure to include pageType=checkoutPage and sessionId

{% hint style="info" %}
If this is the first page of the funnel -

Send requestUri (include affiliate tracking string for reporting) instead of sessionId.

*The response from this call will contain a **sessionId** which should be sent on all subsequent API calls for this session.*
{% endhint %}

**Step 5:** [**Import Order**](https://apidocs.checkoutchamp.com/?version=latest#275a54c6-b4b0-414c-819b-7387e9a81f58) **-** [**https://api.checkoutchamp.com/order/import/?**](https://api.checkoutchamp.com/order/import/?)

This is the part of your funnel that contains the PayPal checkout button. It is important to bind the Import Order call to the button. A successful Import Order response will include a paypalUrl parameter. Redirect the browser to that url.

* Be sure to include the sessionId and orderId from the previous steps.

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

1. **paySource** = 'PAYPAL'
2. **paypalBillerId** = the value assigned to your PayPal gateway, found on your gateway list.
3. **salesUrl** = the url of the page in your funnel that PayPal will redirect to on a successful transaction.

**SUCCESS**

```
{
    "result": "SUCCESS",
    "message": {
        "orderId": "5FFF3B1F5D",
        "ipAddress": "107.142.169.24",
        "sourceId": null,
        "sourceValue1": null,
        "sourceValue2": null,
        "sourceValue3": null,
        "sourceValue4": null,
        "sourceValue5": null,
        "shipCarrier": null,
        "shipMethod": null,
        "profileName": null,
        "dateCreated": "2017-07-19 15:54:23",
        "orderType": "NEW_SALE",
        "orderStatus": "PARTIAL",
        "reviewStatus": null,
        "totalAmount": null,
        "campaignName": "PAYPAL_TEST",
        "orderValue": null,
        "customerId": 67,
        "name": "Boss Cat",
        "emailAddress": "BossCat@fakeemail.com",
        "phoneNumber": "1231231234",
        "firstName": "Boss",
        "lastName": "Cat",
        "companyName": null,
        "address1": "100 Alley Cat  Lane",
        "address2": "Apt 6",
        "shipmentInsured": null,
        "shipmentInsurancePrice": null,
        "insuranceCharged": 0,
        "city": "KittyCity",
        "state": "GA",
        "country": "US",
        "postalCode": "30000",
        "shipFirstName": "Boss",
        "shipLastName": "Cat",
        "shipCompanyName": null,
        "shipAddress1": "100 Alley Cat  Lane",
        "shipAddress2": "Apt 6",
        "shipCity": "KittyCity",
        "shipState": "GA",
        "shipCountry": "US",
        "shipPostalCode": "30000",
        "custom1": null,
        "custom2": null,
        "custom3": null,
        "custom4": null,
        "custom5": null,
        "paySource": null,
        "cardType": null,
        "cardLast4": null,
        "cardExpiryDate": null,
        "achAccountHolderType": null,
        "achAccountType": null,
        "achRoutingNumber": null,
        "achNameOnAccount": null,
        "achAccountNumber": null,
        "couponCode": null,
        "agentUserId": 202,
        "basePrice": null,
        "baseShipping": null,
        "voiceLogNumber": null,
        "discountPrice": "0.00",
        "salesTax": null,
        "shipUpcharge": null,
        "shipProfileId": null,
        "currencySymbol": "$",
        "campaignId": 6,
        "merchantTxnId": null,
        "originalCycleNumber": null,
        "subTotal": null,
        "shipTotal": null,
        "taxTotal": null,
        "totalDiscount": null,
        "amountPaid": null,
        "items": null,
        "paypalUrl": "https:\/\/www.sandbox.paypal.com\/cgi-bin\/webscr?cmd=_express-checkout&token=EC-5BA439844N709200P"
    }
}
```

**Step 6:** [**Confirm PayPal**](https://apidocs.checkoutchamp.com/?version=latest#6d2a3ec0-e1f5-44b3-94a0-101921c28521) **-** [**https://api.checkoutchamp.com/transactions/confirmPaypal/?**](https://api.checkoutchamp.com/transactions/confirmPaypal/?)

Upon successful Import Order response redirect the browser to paypalUrl. This is the PayPal login page (or to PayPal’s guest checkout page if the “guestCheckout” option is enabled on the gateway).

After the transaction in PayPal the customer is redirected by PayPal to your salesUrl (from step 5) with a query string appended containing three parameters: ***paypalAccept**, **token**, and **PayerID***.

(Example: [https://myserver.com/PAYPAL\_TEST/checkout.php?**paypalAccept=1\&token=EC-31442014591217430\&PayerID=GC6MU6RAZE3TW**](https://myserver.com/PAYPAL_TEST/checkout.php?paypalAccept=1\&token=EC-31442014591217430\&PayerID=GC6MU6RAZE3TW) )

Call the Confirm PayPal endpoint to finalize the transaction. Include the token, PayerID, and baToken if returned by PayPal (all values may not be returned in all situations). Also pass the orderId value (if using Import Lead).

* token = token
* payerId = PayerID
* baToken = ba\_token
* orderId = CRM order ID (if using Import Lead)

{% hint style="danger" %}
Also include the following values if they were passed in via Import Order and you are not using Import Lead call:

* emailAddress
* phoneNumber
* couponCode
* shipProfileId
* salesTax
* affId
* sourceValues
* products
  {% endhint %}

SUCCESS

```
{
    "result": "SUCCESS",
    "message": {
        "orderId": "5FFF3B1F5D",
        "ipAddress": "107.142.169.24",
        "sourceId": null,
        "sourceValue1": null,
        "sourceValue2": null,
        "sourceValue3": null,
        "sourceValue4": null,
        "sourceValue5": null,
        "shipCarrier": "Default",
        "shipMethod": "Default",
        "profileName": null,
        "dateCreated": "2017-07-19 16:41:31",
        "orderType": "NEW_SALE",
        "orderStatus": "COMPLETE",
        "reviewStatus": null,
        "totalAmount": "50.00",
        "campaignName": "PAYPAL_TEST",
        "orderValue": "50.00",
        "customerId": 67,
        "name": "Boss Cat",
        "emailAddress": "BossCat@fakeemail.com",
        "phoneNumber": "1231231234",
        "firstName": "Boss",
        "lastName": "Cat",
        "companyName": null,
        "address1": "100 Alley Cat  Lane",
        "address2": "Apt 6",
        "shipmentInsured": null,
        "shipmentInsurancePrice": null,
        "insuranceCharged": 0,
        "city": "KittyCity",
        "state": "GA",
        "country": "US",
        "postalCode": "30000",
        "shipFirstName": "Boss",
        "shipLastName": "Cat",
        "shipCompanyName": null,
        "shipAddress1": "Alley Cat Lane",
        "shipAddress2": "Apt 6",
        "shipCity": "KittyCity",
        "shipState": "GA",
        "shipCountry": "US",
        "shipPostalCode": "30000",
        "custom1": null,
        "custom2": null,
        "custom3": null,
        "custom4": null,
        "custom5": null,
        "paySource": "PAYPAL",
        "cardType": null,
        "cardLast4": null,
        "cardExpiryDate": null,
        "achAccountHolderType": null,
        "achAccountType": null,
        "achRoutingNumber": null,
        "achNameOnAccount": null,
        "achAccountNumber": null,
        "couponCode": "undefined",
        "agentUserId": 202,
        "basePrice": "50.00",
        "baseShipping": "0.00",
        "voiceLogNumber": null,
        "discountPrice": "0.00",
        "salesTax": "0.00",
        "shipUpcharge": "0.00",
        "shipProfileId": null,
        "currencySymbol": "$",
        "campaignId": 6,
        "merchantTxnId": "2XP14303DE482013R",
        "originalCycleNumber": 1,
        "subTotal": "50.00",
        "shipTotal": "0.00",
        "taxTotal": "0.00",
        "totalDiscount": "0.00",
        "amountPaid": "50.00",
        "items": [
            {
                "productId": "6",
                "name": "(1) ORIGIN",
                "qty": "1",
                "shipping": "0.00",
                "price": "50.00",
                "initialSalesTax": "0.00",
                "customSalesTax": "",
                "refundRemaining": "50.00",
                "purchaseStatus": "",
                "billingCycleType": "",
                "finalBillingCycle": "",
                "isPreauthVoid": "0",
                "nextBillDate": "",
                "trialEnabled": "",
                "trialType": "",
                "regularPrice": "",
                "productQty": "1",
                "cycle1_billDelay": "",
                "cycle2_price": "",
                "cycle2_shipPrice": "",
                "cycle2_isShippable": "0",
                "cycle2_billDelay": "",
                "cycle3_price": "",
                "cycle3_shipPrice": "",
                "cycle3_isShippable": "0",
                "cycle3_billDelay": "",
                "lastCustomCycle": "0",
                "purchaseCycle": "",
                "txnType": "SALE",
                "cancellationScheduled": "0",
                "cancelAfterDate": "",
                "billingCycleNumber": "1",
                "staggerIntervalCycles": "",
                "staggerFulfillments": "0"
            }
        ]
    }
}
```

### Upsell Pages <a href="#paypalcommercecheckout-legacy-upsellpages" id="paypalcommercecheckout-legacy-upsellpages"></a>

**Step 7:** [**Import Click**](https://apidocs.checkoutchamp.com/?version=latest#e576c9e1-2606-49c2-8ac0-143a35c7add2) **-** [**https://api.checkoutchamp.com/landers/clicks/import/?**](https://api.checkoutchamp.com/landers/clicks/import/?)

After a successful Confirm Paypal call, 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 8:** [**Import Upsale**](https://apidocs.checkoutchamp.com/?version=latest#46b9bc0a-687a-4a87-a57c-266f9914681f) **-** [**https://api.checkoutchamp.com/upsale/import/**](https://api.checkoutchamp.com/upsale/import/)

{% hint style="danger" %}
**To use PayPal legacy workflow with 1-click upsells you will need to ensure referenceTransactions is enabled on both the gateway inside CRM and also on the backend of PayPal.**
{% endhint %}

One-click upsells are available in the legacy workflow if reference transactions is enabled. If the customer chooses to buy an upsell, submit this product using the Import Upsale endpoint.

Merchants without reference transactions enabled must process upsells using a 2-step process. Follow these [instructions](https://help.checkoutchamp.com/crm/gateway-setup/gateway-integrations/paypal-commerce-checkout/paypal-commerce-checkout-legacy/paypal-seamless-checkout-2-click-upsells-without-reference-transactions).

{% hint style="info" %}
Repeat Step 7 (increment upsellPage#) and Step 8 for each upsell page in your funnel.
{% endhint %}

{% hint style="info" %}
Follow step 9 or 10. It is not necessary to do both.
{% endhint %}

### Thank You Page <a href="#paypalcommercecheckout-legacy-thankyoupage" id="paypalcommercecheckout-legacy-thankyoupage"></a>

**Step 9:** [**Import Click**](https://apidocs.checkoutchamp.com/?version=latest#e576c9e1-2606-49c2-8ac0-143a35c7add2) **-** [**https://api.checkoutchamp.com/landers/clicks/import/?**](https://api.checkoutchamp.com/landers/clicks/import/)

After all upsells the customer finally lands on the 'thankyouPage' and another click is imported using the Import Click endpoint.

* Be sure to include pageType=thankyouPage and sessionId

**Step 10:** [**Confirm Order**](https://apidocs.checkoutchamp.com/?version=latest#c71c6bca-20a0-48af-abd5-75773fdc692f) **-** [**https://api.checkoutchamp.com/order/confirm/**](https://api.checkoutchamp.com/order/confirm/)

Confirm Order is called to send the customer’s their confirmation email immediately.

* Be sure to include the orderId

### Shipment Tracking <a href="#paypalcommercecheckout-legacy-shipmenttracking" id="paypalcommercecheckout-legacy-shipmenttracking"></a>

Tracking Numbers can optionally be sent to PayPal when received. Check the **sendFulfillmentTrackingNumber** box on the gateway.

### Common PayPal Errors <a href="#paypalcommercecheckout-legacy-commonpaypalerrors" id="paypalcommercecheckout-legacy-commonpaypalerrors"></a>

| Error                                                                                                                 | Fix                                                                      |
| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| “Security error: Security header is not valid”                                                                        | Please use Live PayPal credentials (not Sandbox) or enable useTestServer |
| Transaction refused because of an invalid argument. See additional error messages for details.: ReturnURL is invalid. | Please ensure **salesUrl** is included on the Import Order API request.  |
