Skip to main content
PayPal Fastlane is a streamlined checkout experience that allows returning customers to authenticate and pay quickly using saved payment methods and shipping addresses. New customers can also use it for a smooth guest checkout experience. For more information about Fastlane, see the PayPal Fastlane documentation. This guide provides instructions for integrating PayPal Fastlane into your web application using the v6 web SDK.

Prerequisites

  • PayPal sandbox account with appropriate credentials. For more information about using PayPal’s sandbox for testing, see the PayPal sandbox testing guide.
  • Backend server for API proxy. For more information, see /server/node/README.md.
  • A web browser with ES6 support.
There also are requirements for the backend and your HTML.

Backend endpoints

Your backend must provide these API endpoints:
  • The client token endpoint provides a client token for SDK initialization.
    • URL: GET /paypal-api/auth/browser-safe-client-token
    • Response: { "accessToken": "YOUR-CLIENT-TOKEN" }
  • The order creation endpoint creates a PayPal order using the payment token.
    • URL: POST /paypal-api/checkout/orders/create
    • Headers:
      Content-Type: application/json
      PayPal-Request-Id: <unique-id>

HTML structure

Your HTML must include these elements.

Integration

Fastlane integration consists of three main JavaScript files:
  • fastlaneSdkComponent.js: SDK initialization and client token management
  • fastlane.js: Main integration logic and UI handling
  • fastlane.css: Basic styling for the checkout experience
For examples of these files, see this GitHub repo folder. To complete the integration:
  1. Include the PayPal SDK script in your HTML.
  1. Initialize the SDK and Fastlane (fastlaneSdkComponent.js).
In this example, you see some Fastlane SDK options:
  • pageType: The applicable page type, such as product-details
  • clientMetadataId: Unique session identifier
  • components: Array that includes fastlane

  1. Set up the email-lookup flow (fastlane.js).
The email-lookup process determines whether a user is a Fastlane member.
  1. Set up handling for members (fastlane.js).
Members are authenticated Fastlane members who have saved data.
  1. Set up handling for guests (fastlane.js).
Guests are new or unauthenticated users.
  1. Set up payment processing (fastlane.js).
Payment processing includes generating a payment token and creating an order. In this step, you see these payment component options:
  • options: Additional payment component configuration
  • shippingAddress: Pre-populate with a member’s saved address

Error handling

This integration includes basic error handling, including:
  • If a member’s authentication fails, they get the guest experience.
  • Errors in order creation display user-friendly messages.
  • The console logs error information to help with debugging.

Testing

For testing, use PayPal’s sandbox environment with sandbox credentials. Test member and guest flows with card numbers.

Sample app

To see the sample app, run these commands.
The sample app will run at http://localhost:3000/. The sample requires a backend server at http://localhost:8080.

See also

Examine a full example of a Fastlane integration on GitHub.