- PayPal and Pay Later
- Venmo (US only)
- Google Pay
- Apple Pay
- Fastlane guest checkout
- Credit and debit cards
Prerequisites
Before you start, make sure to get your PayPal client ID and secret. If you’re a partner integrating on behalf of other merchants, follow these additional steps to set up your integration:- Onboard as a partner with PayPal
- Configure your accounts
- Onboard sellers
- Integrate backend with the Orders v2 API
Include the SDK script
Include the v6 SDK script on each page of your site that needs to accept payments.Authenticate the SDK
Authenticate with a client ID or a client token. Most integrations should authenticate with a client ID.Option A: client ID (recommended)
Option A: client ID (recommended)
Option A: client ID (recommended)
For most integrations, use your PayPal client ID to authenticate the SDK. You can think of the client ID as your application’s user name. This static client ID value is safe to include in your front-end code.When to use client ID:- Standard checkout integrations (PayPal, cards, Venmo, digital wallets)
- One-time payments
- Card vaulting (save card payment methods)
- Most payment integrations (this is the default)
- Direct merchants process payments into their own PayPal account.
- Partners process payments on behalf of other merchants.
- Direct merchants
- Partners
"YOUR_CLIENT_ID" with your client ID.Option B: client token (for Fastlane only)
Option B: client token (for Fastlane only)
Option B: client token
A client token is a secure, browser-safe access token generated server-side from your PayPal client ID and secret. This call returns anaccess_token which you use as the client token when you initialize the v6 SDK. Use expires_in for caching management on the server side.PayPal-Auth-Assertion and PayPal-Partner-Attribution-Id headers./v1/oauth2/token/Sample 200 response
Sample 200 response
Initialize the v6 SDK
Usewindow.paypal.createInstance() to initialize the SDK with your client ID or a client token for authentication. Also, use it to define the components you want to load and to manage other configurations like locale and pageType. The method returns an SDK instance that provides access to payment eligibility checking and session creation methods.
window.paypal.createInstance(options)
Use window.paypal.createInstance to initialize the PayPal SDK. This method configures the SDK for your specific integration needs and returns an SDK instance that you’ll use to create payment sessions.
Parameters
| Parameter | Required | Description |
|---|---|---|
clientId | conditional | string. Your PayPal client ID. Use this for most integrations. Mutually exclusive with |
clientToken | conditional | string. A secure, browser-safe token that your server generates using your PayPal client ID and secret. Required for PayPal payment vaulting and Fastlane integrations. This token expires after 15 minutes and is bound to your domain for security. You must generate a new token when needed. Mutually exclusive with |
components | no | string[]. An array of SDK components to load for your integration. Each component enables specific payment functionality. Available components:
Default: |
pageType | no | string. The type of page where the SDK is being initialized. This helps PayPal optimize the payment experience and provide better analytics. Accepted values:
|
locale | no | string. The locale for the UI components, specified as a BCP-47 language tag, for example, |
clientMetadataId | no | string. A unique identifier for tracking and debugging. You can generate this using |
merchantId | yes for partners | string. A unique identifier for the seller you’re processing payments for. |
partnerAttributionId | no | string. PayPal issues this |
Returns
Returns a promise that resolves to an SDK instance object. This instance provides methods for checking payment eligibility and creating payment sessions.findEligibleMethods()- Check payment method availabilitycreatePayPalOneTimePaymentSession()- Create a payment sessioncreateFastlane()- Initialize accelerated guest checkout (Fastlane)
Example
merchantId parameter when initializing the SDK instance. Direct merchants can omit this parameter.Recommended frontend setup
This is the recommended approach for most implementations. It includes all payment methods with eligibility logic and automatic fallback handling. The following are key components of the integration:PayPal SDK instance
- Purpose: Main entry point for PayPal functionality
- Components: Includes
paypal-paymentscomponent - Authentication: Requires client token from server
Eligibility check
- Purpose: Determines payment methods available to the buyer
- Factors: User location, currency, account status, device type
- Implementation: Always check before showing payment buttons
Payment sessions
- PayPal: Standard PayPal payments
- Pay Later: Financing options with specific product codes
- PayPal Credit: Credit-based payments with country-specific configuration
Web components
<paypal-button>: Standard PayPal payment button<paypal-pay-later-button>: Pay Later financing button<paypal-credit-button>: PayPal Credit button
Example
The following is an example of what anapp.js file might look like when implementing the recommended setup.
merchantId parameter when initializing the SDK instance. Direct merchants can omit this parameter.Return order ID to SDK
ThecreateOrder() function must return a promise that resolves to { orderId: "YOUR_ORDER_ID" }. This is a key difference between v6 and previous versions of the SDK.
Best practices
The following are best practices for integrating the v6 SDK. Keep sensitive operations server-side and validate all payment data. Provide clear feedback to users throughout the payment flow.Security
- Obtain client tokens from your secure server
- Never expose PayPal client secrets in frontend code
- All payment processing happens through PayPal’s secure servers
- Never pass up item total from browser - this can be manipulated
- Validate order details on your server before capture
User experience
- Always check eligibility before showing payment buttons
- Provide clear loading states during payment processing
- Handle popup blockers gracefully with
{ presentationMode:auto } - Show appropriate error messages for different failure scenarios
Performance
- Initialize the SDK early, but avoid blocking page load
- Cache client tokens appropriately
- Use presentation mode fallback strategies