Docs

Update pwCustomer and eventCallback after Paddle.js is initialized

Use a new method to update the customer for Paddle Retain and pass an event callback after you've initialized Paddle.js. Plus, a new method for initializing Paddle.js.

Tooling

  • Paddle.js
  • Checkout

Released

March 1, 2024

Status

Released

Action required

Action required

What's new?

We added a new Paddle.Update() method that you can use to update Paddle.js after initialization.

As part of this change, we replaced Paddle.Setup() with Paddle.Initialize(). You don't need to make any changes to your integration immediately.

How it works

Paddle.Update()

When you initialize Paddle.js, you can pass the customer for Paddle Retain engagement using the pwCustomer parameter. You may also pass an eventCallback to handle events emitted by Paddle.js.

Paddle.js can only be initialized once on a page. This means that previously there was no way to update pwCustomer or eventCallback after initialization. This could be a problem when working with single page applications, or when dynamically setting event callbacks based on things like payment flow.

We added a new Paddle.Update() method that you can call after initialization to update values passed to Paddle.js. We support updating pwCustomer and eventCallback.

Paddle.Update() may only be called after initialization. You can use a new Paddle.Initialized flag to determine whether Paddle.js is initialized.

Paddle.Initialize()

To make it clearer that Paddle.js may only be initialized once per page, we replaced Paddle.Setup() with Paddle.Initialize(). It's functionally the same as Paddle.Setup(), supporting all the same parameters.

Paddle.Setup() is now considered deprecated, but you don't need to do anything right away. We still support using Paddle.Setup() to initialize Paddle.js. Existing integrations are not impacted.

Example

This example passes a new pwCustomer to Paddle.js using Paddle.Update().

JavaScript
Paddle.Update({
pwCustomer: {
id: 'ctm_01gt25aq4b2zcfw12szwtjrbdt'
}
});

This example checks if Paddle is initialized using the Paddle.Initialized flag, then calls Paddle.Update() to set pwCustomer if not initialized.

JavaScript
if (Paddle.Initialized) {
Paddle.Update({
pwCustomer: {
id: 'ctm_01gt25aq4b2zcfw12szwtjrbdt'
}
}
);
} else {
Paddle.Initialize({
token: 'live_7d279f61a3499fed520f7cd8c08',
checkout: {
displayMode: "overlay",
theme: "dark",
locale: "en"
},
pwCustomer: { },
}
);
}

Next steps

This change is live in Paddle.js now, so you can start using Paddle.Update() and Paddle.Initialize() when you're ready.

You don't need to do anything to get the latest version of Paddle.js — we serve the latest version automatically.

We recommend that you replace Paddle.Setup() with Paddle.Initialize() and when you're next reviewing your code.

Summary of changes

Entity Field Change Type
Paddle.js Paddle.Update() + Added Paddle.js method
Use to update Paddle.js after initialization.
Paddle.js Paddle.Initialize() + Added Paddle.js method
Use to initialize Paddle.js.
Paddle.js Paddle.Setup() - Deprecated Paddle.js method
Use Paddle.Initialize() instead.

Was this page helpful?