# PayPal Fastlane

{% embed url="<https://www.paypal.com/us/fastlane>" %}

<figure><img src="https://1103784913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiAC0G99SjXjSv2GM5PAE%2Fuploads%2F5oQy0kqkzKfbJgUBUPdL%2Fimage.png?alt=media&#x26;token=395ce444-c130-4017-bae0-59bfcd58794f" alt=""><figcaption></figcaption></figure>

### PayPal Commerce Setup <a href="#paypal-commerce-setup" id="paypal-commerce-setup"></a>

Go to Gateways > Gateway List > choose the PayPal Commerce account. Enable **referenceTransactions**. Verify that **vaultEnabled** is enabled. These 2 options are required for Fastlane.

{% hint style="info" %}
Fastlane is available for US customers only.
{% endhint %}

{% hint style="warning" %}
Reference transactions must also be enabled on your PayPal account. Please confirm with PayPal if this is unknown.
{% endhint %}

### Checkout Page Setup

Most of the Fastlane integration is on your checkout page.

#### Step 1

Create a Fastlane session

Call the Konnektive [Import Click API](https://apidocs.konnektive.com/#834b3843-dd86-40b5-82f0-85a3384fbcfd) with standard parameters and:

* **paypalFastlaneBillerId** - the PayPal Commerce gateway id on which to transact
* **requestUri** - the full url of the current page
* **pageType** - checkoutPage

This call will return standard session information along with a Fastlane session token

* retrieve **paypalFastlane.accessToken** from the response

#### Step 2

Implement Fastlane on the checkout page.  Reference this link

{% embed url="<https://developer.paypal.com/studio/checkout/fastlane/integrate?type=flexible&frontend=html&backend=node>" %}

1. Load the PayPal SDK:
   1. Use JavaScript to dynamically load the PayPal SDK script.
   2. Ensure the SDK script URL includes all necessary parameters, such as:
      1. \`components=fastlane\`
      2. Other required PayPal SDK parameters
      3. \`data-sdk-client-token\` should be set using the **accessToken** from Step 1
2. Script Handling
   1. Append the SDK script to the \<head> element.
   2. Once the script is loaded, call the \`initFastlane\` function.
3. Page Setup
   1. Add the necessary classes and IDs to the page to render Fastlane components correctly
   2. Design the checkout UI to support both guest and member checkout flows.
4. Checkout Flow
   1. On "Checkout" button click
      1. For guest checkout (not currently enrolled in Fastlane), gather billing and shipping details from input fields.
      2. For member checkout (enrolled in Fastlane), retrieve billing and shipping details from Fastlane components
      3. Save the billing and shipping details for Step 3
   2. Create a payment token
      1. For guest checkout (not currently enrolled in Fastlane), generate the token using the collected billing details.
      2. For member checkout (enrolled in Fastlane), use the token returned by Fastlane.
      3. Save the token for Step 3

#### Step 3

Import the order when Fastlane is complete on the checkout page

Call the Konnektive [Import Order API](https://apidocs.konnektive.com/#436cbeab-a41a-4f36-bfb9-7b74fd82a0c0) with standard parameters and:

* **paySource** - PAYPAL
* **prepaidType** - PAYPAL\_FASTLANE
* **forceMerchantId** - the PayPal Commerce gateway id on which to transact (same as Step 1)
* **formCardNonce** - the token returned by Fastlane at the end of Step 2
* Pass the billing and shipping details from Step 2

#### Step 4

Upsells are processed using standard upsell handling.  There is no additional code needed for upsell pages.  Reference transactions is required for Fastlane checkout, making all upsells 1-click.
