Paddle.PricePreview()
Previews localized prices given location information supplied.
Use Paddle.PricePreview()
to return a pricing preview object for the given items and location parameters.
Pricing preview objects hold calculated totals for prices, including discounts, taxes, and currency conversion. Typically used for building pricing pages. For more advanced pricing pages, consider the Paddle.TransactionPreview()
method instead.
Accepts the same request body as the preview prices operation in the Paddle API, except fields must be formatted as camelCase
rather than snake_case
.
Returns a promise that contains an object that matches the response from the preview prices operation. Field names are camelCase
rather than snake_case
.
Requires a client-side token for authentication. If you're passing the older
seller
parameter toPaddle.Initialize()
, replace this withtoken
to usePaddle.PricePreview()
.
Parameters
Pricing preview request body. Must include an items
array. Include location information to return localized prices.
Check the preview prices operation documentation to learn about the fields you can send in a request. Convert snake_case
field names to camelCase
, as is convention for JavaScript.
Examples
This example includes a request with two items where the country code is the United States.
The request is passed to Paddle.PricePreview()
, which returns a promise. It prints the response to the console.
12345678910111213141516171819201var request = {
2 items: [{
3 quantity: 1,
4 priceId: 'pri_01gsz8ntc6z7npqqp6j4ys0w1w',
5 },
6 {
7 quantity: 1,
8 priceId: 'pri_01gsz8x8sawmvhz1pv30nge1ke',
9 }
10 ],
11 address: {
12 countryCode: 'US'
13 }
14}
15
16Paddle.PricePreview(request)
17 .then((result) => {
18 console.log(result);
19 })
20 .catch((error) => {
To learn more, see Build a pricing page