Docs

Paddle.PricePreview()

Use to preview 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.

Parameters

requestobject
Pricing preview request body. Must include an items array. Include location information to return localized prices, or omit to let Paddle.js automatically detect location.

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 flagUnited States.

The request is passed to Paddle.PricePreview(), which returns a promise. It prints the response to the console.

JavaScript
var request = {
items: [
{
quantity: 1,
priceId: "pri_01gsz8ntc6z7npqqp6j4ys0w1w",
},
{
quantity: 1,
priceId: "pri_01gsz8x8sawmvhz1pv30nge1ke",
},
],
address: {
countryCode: "US",
},
};
Paddle.PricePreview(request)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
TypeScript
import { initializePaddle } from "@paddle/paddle-js";
const paddle = await initializePaddle({
token: "live_7d279f61a3499fed520f7cd8c08",
});
const request = {
items: [
{
quantity: 1,
priceId: "pri_01gsz8ntc6z7npqqp6j4ys0w1w",
},
{
quantity: 1,
priceId: "pri_01gsz8x8sawmvhz1pv30nge1ke",
},
],
address: {
countryCode: "US",
},
};
paddle
?.PricePreview(request)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});

To learn more, see Build a pricing page

Was this page helpful?