The PayPal JavaScript SDK v6 enables you to accept the following payment methods on your website:
PayPal and Pay Later
Venmo (US only)
Google Pay
Apple Pay
Fastlane guest checkout
Credit and debit cards
The v6 SDK is faster and more secure than previous versions. It also supports standalone button integrations and iframe-based integrations.Before you start, make sure to get your PayPal client ID and secret.
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)
Replace `“YOUR_CLIENT_ID” with your client ID.Example client ID authentication:
Client token authentication is required for PayPal payment vaulting and Fastlane integrations. For all other use cases, use the simpler client ID approach.
A client token is a secure, browser-safe access token generated server-side from your PayPal client ID and secret. This call returns an access_token which you use as the client token when you initialize the v6 SDK. Use expires_in for caching management on the server side.
Use window.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.
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.
string. Your PayPal client ID. Use this for most integrations. Mutually exclusive with clientToken.
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 clientId.
components
no
string[]. An array of SDK components to load for your integration. Each component enables specific payment functionality.
Available components:
paypal-payments — PayPal and Pay Later checkout
venmo-payments — Venmo payments (US only)
googlepay-payments — Google Pay integration
applepay-payments — Apple Pay integration
fastlane — Fastlane guest checkout
paypal-messages — Promotional messaging
Default: [“paypal-payments”]
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:
checkout — Checkout or payment page
product-details — Individual product page
cart — Shopping cart page
mini-cart — Mini cart or side cart
home — Homepage
locale
no
string. The locale for the UI components, specified as a BCP-47 language tag, for example, "en-US", "fr-FR", "de-DE". If not specified, the SDK automatically detects the buyer’s locale from their browser settings.
clientMetadataId
no
string. A unique identifier for tracking and debugging. You can generate this using crypto.randomUUID() or your own ID generation system. This ID helps correlate SDK sessions with your server-side logs.
Returns a promise that resolves to an SDK instance object. This instance provides methods for checking payment eligibility and creating payment sessions.
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:
The createOrder() 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.
// In v6, this must return an object with the shape: { orderId: "YOUR_ORDER_ID" } return fetch("/paypal-api/checkout/orders/create", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(orderPayload), }) .then(response => response.json()) .then(data => ({ orderId: data.id })); // <-- Required return value} // End createOrder
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.