Use Paddle.Initialize() to initialize Paddle.js and set default checkout settings. This is required when working with pricing pages, checkouts, and Retain workflows.
You can use Paddle.Initialize() to:
- Authenticate with your Paddle account
- Integrate with Retain
- Pass settings that apply to all checkouts opened on a page
- Create event callbacks
You must call Paddle.Initialize() and pass a client-side token to use Paddle Checkout. You can create and manage client-side tokens in Paddle > Developer tools > Authentication.
You can only call Paddle.Initialize() once on a page. You'll get an error if you try to call it more than once. Use Paddle.Update() to update pwCustomer or pass an updated eventCallback.
You can pass settings for opened checkouts using either Paddle.Checkout.open() or Paddle.Initialize(). Settings passed to Paddle.Initialize() are default settings, which means they apply to all checkouts opened on a page.
Paddle.js emits events for key actions as a customer moves through checkout. You can pass an eventCallback to Paddle.Initialize() to call a function for every Paddle.js checkout event. This is typically used as part of an inline checkout integration for updating on-page elements, like items lists or breadcrumbs.
Paddle Retain
Paddle Retain only works on live accounts
Paddle Retain only works with live data. While you can initialize Paddle.js with Retain in sandbox accounts, Retain features aren't loaded there.
Paddle.js integrates with Retain, so you don't have to include a separate Retain script in your app or website. Client-side tokens for live accounts authenticate with both Paddle Billing and Paddle Retain, so there's no need to pass a separate key for Retain.
To use Retain, pass pwCustomer for logged-in customers. You can update pwCustomer after initialization using Paddle.Update().
Parameters
ctm_. Only customer IDs are accepted. Don't pass subscription IDs, other Paddle IDs, or your own internal identifiers for a customer.truetruetrue.alipayAlipay, popular in China.apple_payApple Pay on a supported Apple device.bancontactBancontact, popular in Belgium.blikBLIK, a popular payment method in Poland.cardCredit or debit card.
+ Show all values− Hide values
google_payGoogle Pay on a supported Android device, Chromebook, or Google Chrome browser.idealiDEAL, popular in the Netherlands.kakao_payKakao Pay, a popular payment method in Korea.mb_wayMB WAY, a popular payment method in Portugal.naver_payNaver Pay, a popular payment method in Korea.paycoPayco, a popular payment method in Korea.paypalPayPal.pixPix, popular in Brazil. Available in early access.samsung_paySamsung Pay, a popular payment method in Korea.saved_payment_methodsA customer's existing saved payment methods. RequirescustomerAuthTokento be passed toPaddle.Checkout.open().south_korea_local_cardKorean local credit or debit card.upiUnified Payments Interface (UPI), popular in India. Available in early access.
overlayinlineInline checkout mode. Checkout embedded as a frame in the page. Requiressettings.frameTargetinPaddle.Initialize().overlayOverlay checkout mode. Checkout opens in an overlay.
450Height in pixels of the <div> on load. Do not include px. Recommended 450.
The inline checkout footer includes a message to let customers know that Paddle is the merchant of record for the transaction. For compliance, the inline checkout frame must be sized so that the footer message is visible.
min-width: 286px;background-color:transparent;<div>. min-width must be set to 286px or above with checkout padding off; 312px with checkout padding on. Use frameInitialHeight to set height.checkout-container<div> element where the checkout should be rendered.(browser default)arArabic (العربية)zh-HansChinese (Simplified) (简化字)zh-TWChinese (Traditional) (正體字)daDanish (Dansk)nlDutch (Nederlands)
+ Show all values− Hide values
enEnglishfrFrench (Français)deGerman (Deutsch)itItalian (Italiano)jaJapanese (日本語)koKorean (한국어)noNorwegian (Norsk)plPolish (Polski)ptPortuguese (Português)pt-BRPortuguese (Brazilian) (Português do Brasil)trTurkish (Türkçe)ruRussian (Русский)esSpanish (Español)svSwedish (Svenska)
truetrue.truetrue.http:// or https://.lightlightLight-themed checkout.darkDark-themed checkout.
multi-pagemulti-page.one-pageOne-page checkout experience. Customer information and payment details collected on the same page.multi-pageMulti-page checkout experience. Customer information and payment details collected on separate pages.
Examples
This example passes a client-side token to Paddle.js. This is required.
You can create and manage client-side tokens in Paddle > Developer tools > Authentication.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08",});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08",});To learn more, see Include and initialize Paddle.js
For logged-in users, you should pass pwCustomer.
This example passes the Paddle ID for a customer entity in Paddle to Retain.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08", pwCustomer: { id: "ctm_01gt25aq4b2zcfw12szwtjrbdt", },});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token pwCustomer: { id: "ctm_01gt25aq4b2zcfw12szwtjrbdt", // replace with a customer Paddle ID },});Where you don't know the Paddle ID for a customer, you can pass an empty object to pwCustomer.
To learn more, see Initialize Paddle.js with Retain
This example sets default checkout settings for all checkouts opened on a page. It includes common settings for inline checkouts.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token checkout: { settings: { displayMode: "inline", theme: "light", locale: "en", frameTarget: "checkout-container", frameInitialHeight: "450", frameStyle: "width: 100%; min-width: 312px; background-color: transparent; border: none;", }, },});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token checkout: { settings: { displayMode: "inline", theme: "light", locale: "en", frameTarget: "checkout-container", frameInitialHeight: 450, frameStyle: "width: 100%; min-width: 312px; background-color: transparent; border: none;", }, },});To learn more, see Pass checkout settings
This example sets default checkout settings for all checkouts opened on a page. It includes the required settings to open a one-page inline checkout.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token checkout: { settings: { displayMode: "inline", variant: "one-page", theme: "light", locale: "en", frameTarget: "checkout-container", frameInitialHeight: "450", frameStyle: "width: 100%; min-width: 312px; background-color: transparent; border: none;", }, },});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token checkout: { settings: { displayMode: "inline", variant: "one-page", theme: "light", locale: "en", frameTarget: "checkout-container", frameInitialHeight: 450, frameStyle: "width: 100%; min-width: 312px; background-color: transparent; border: none;", }, },});This example sets default checkout settings for all checkouts opened on a page. It includes common settings for overlay checkouts.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token checkout: { settings: { displayMode: "overlay", theme: "light", locale: "en", }, },});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token checkout: { settings: { displayMode: "overlay", theme: "light", locale: "en", }, },});To learn more, see Paddle.js events
This example logs events emitted by Paddle.js to console.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token eventCallback: function (data) { console.log(data); },});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token eventCallback: (data) => { console.log(data); },});To learn more, see Paddle.js events
This example uses a switch statement to log some text to console based on events emitted by Paddle.js.
Paddle.Initialize({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token eventCallback: function (data) { switch (data.name) { case "checkout.loaded": console.log("Checkout opened"); break; case "checkout.customer.created": console.log("Customer created"); break; case "checkout.completed": console.log("Checkout completed"); break; default: console.log(data); } },});import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({ token: "live_7d279f61a3499fed520f7cd8c08", // replace with a client-side token eventCallback: (data) => { switch (data.name) { case "checkout.loaded": console.log("Checkout opened"); break; case "checkout.customer.created": console.log("Customer created"); break; case "checkout.completed": console.log("Checkout completed"); break; default: console.log(data); } },});To learn more, see Paddle.js events