Skip to main content
Include and initialize the v6 SDK with your client token and configuration options. Before you start, make sure to get your PayPal client ID and secret.

Include the SDK script

Include the v6 SDK script on each page of your site that needs to accept payments.
<script src="https://www.paypal.com/web-sdk/v6/core"></script>
For sandbox and testing environments:
<script src="https://www.sandbox.paypal.com/web-sdk/v6/core"></script>

Get client token

Use the returned access_token value as the client token when you initialize the v6 SDK. Use expires_in for any caching management on the server-side.
Endpoint: /v1/oath2/token/
curl -X POST 'https://api-m.sandbox.paypal.com/v1/oauth2/token' \
-u 'PAYPAL_CLIENT_ID:PAYPAL_CLIENT_SECRET' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials' \
-d 'domains[]=YOUR_URL1_FOR_THE_SESSION,YOUR_URL2_FOR_THE_SESSION' \
-d 'response_type=client_token'
{
   "access_token" : "A21AAJrhF-LjFoXzGPJlszGfKg4omnKy5e_eeRXPYzHLb3OdbjtCB3w89nm_6wCCbqn7qSdzjW77VGE7NAJAbXw53ZVpiX5tQ",
   "app_id" : "APP-80W284485P519543T",
   "expires_in" : 32400,
   "nonce" : "2025-10-22T14:32:24ZNpKbSPKuOEA75fCkaNqAcQC_7GbyY1wYSpE1qTeMDaQ",
   "scope" : "https://uri.paypal.com/services/invoicing https://uri.paypal.com/services/payments/futurepayments https://uri.paypal.com/services/vault/payment-tokens/read https://uri.paypal.com/services/disputes/read-buyer https://uri.paypal.com/services/payments/realtimepayment https://uri.paypal.com/services/payments/client-payments-eligibility https://uri.paypal.com/services/identity/activities https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/payments/.* https://uri.paypal.com/services/reporting/search/read https://uri.paypal.com/services/vault/payment-tokens/readwrite https://api.paypal.com/v1/payments/refund https://uri.paypal.com/services/applications/webhooks https://uri.paypal.com/services/credit/client-offer-presentment/read https://uri.paypal.com/services/paypalhere https://uri.paypal.com/services/disputes/update-seller openid https://uri.paypal.com/services/payments/payment/authcapture Braintree:Vault https://uri.paypal.com/services/disputes/read-seller https://uri.paypal.com/services/payments/orders/client_sdk_orders_api https://uri.paypal.com/services/payments/refund https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.* https://uri.paypal.com/services/shipping/trackers/readwrite https://uri.paypal.com/services/subscriptions https://api.paypal.com/v1/payments/sale/.*/refund",
   "token_type" : "Bearer"
}
The following server-side endpoint returns the client token to your client application. Call this endpoint from your frontend:
async function getBrowserSafeClientToken() {
  const response = await fetch("/paypal-api/auth/browser-safe-client-token", {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
    },
  });
  const { accessToken } = await response.json();
  return accessToken;
}

Initialize the v6 SDK

Use window.paypal.createInstance() to initialize the SDK with your server-generated client token and configure components, locale, and page type settings. The method returns an SDK instance that provides access to payment eligibility checking and session creation methods.

window.paypal.createInstance(options)

Use paypal.createInstance to initialize the PayPal SDK with your client token and configuration. This method configures the SDK for your specific integration needs and returns an SDK instance that you’ll use to create payment sessions. The client token authenticates your integration and must be generated server-side. This token is domain-bound for security and expires after 15 minutes.

Parameters

ParameterRequiredDescription
clientTokenyes

string. A secure, browser-safe token generated by your server using your PayPal client ID and secret. This token authenticates all SDK operations and is bound to your domain for security. The token expires after 15 minutes and cannot be refreshed—you must generate a new token when needed.

componentsno

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”]

pageTypeno

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
localeno

string. The locale for the SDK UI components, specified as a BCP-47 language tag (e.g., “en-US”, “fr-FR”, “de-DE”). If not specified, the SDK automatically detects the buyer’s locale from their browser settings.

clientMetadataIdno

string. A unique identifier for tracking and debugging purposes. 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

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 availability
  • createPayPalOneTimePaymentSession() - Create payment sessions
  • createFastlane() - Initialize accelerated checkout

Example

// Basic initialization
const sdkInstance = await window.paypal.createInstance({
  clientToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
});

// Full configuration
const sdkInstance = await window.paypal.createInstance({
  clientToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  components: ["paypal-payments", "venmo-payments"],
  pageType: "checkout",
  locale: "en-US",
  clientMetadataId: crypto.randomUUID(),
});

// With error handling
try {
  const sdkInstance = await window.paypal.createInstance({
    clientToken: clientToken,
  });
  console.log("PayPal SDK initialized successfully");
} catch (error) {
  console.error("Failed to initialize PayPal SDK:", error);
}