Paddle Billing
Search

Paddle.TransactionPreview()

Generates a transaction preview for prices and location information supplied.

Use Paddle.TransactionPreview() to return a transaction preview object for items and location information supplied.

Transaction previews are previews of transaction entities, holding calculated totals for prices — including discounts, taxes, and currency conversion. They're typically used for building advanced, cart-style pricing pages where users can build their own plans. For simpler pricing pages, consider the Paddle.PricePreview() method instead.

Unlike pricing previews returned when using Paddle.PricePreview(), transaction previews return overall totals for items passed. This means that they have the same validation logic as transactions, too. For example, all items must have the same billing period.

Accepts the same request body as the preview a transaction 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 a transaction operation. Field names are camelCase rather than snake_case.

Requires a client-side token for authentication. If you're passing the older seller parameter to Paddle.Initialize(), replace this with token to use Paddle.TransactionPreview().

Parameters

requestobject

Transaction preview request body. Must include an items array.

Check the preview a transaction 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 and the currency code is USD. One of the items is excluded from the totals using the includeInTotals field. It also passes a discount.

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

Related pages