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.
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()
.
123451Paddle.Update({
2 pwCustomer: {
3 id: 'ctm_01gt25aq4b2zcfw12szwtjrbdt'
4 }
5});
This example checks if Paddle is initialized using the Paddle.Initialized
flag, then calls Paddle.Update()
to set pwCustomer
if not initialized.
123456789101112131415161718191if (Paddle.Initialized) {
2 Paddle.Update({
3 pwCustomer: {
4 id: 'ctm_01gt25aq4b2zcfw12szwtjrbdt'
5 }
6 }
7 );
8} else {
9 Paddle.Initalize({
10 token: 'live_7d279f61a3499fed520f7cd8c08',
11 checkout: {
12 displayMode: "overlay",
13 theme: "dark",
14 locale: "en"
15 },
16 pwCustomer: { },
17 }
18 );
19}
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.