preview_prices
Preview price calculations with tax and currency localization by providing location details like customer IP, address, or existing customer data.
Instructions
This tool will preview price calculations for one or more prices.
Consider using the preview_transaction_create tool for more advanced and accurate pricing calculations or for all manually-collected invoiced transactions.
Providing location information when previewing prices allows Paddle to calculate tax or automatically localize prices. Provide one of the following:
customer_ip_address: Paddle fetches location using the IP address to calculate totals.
address: Paddle uses the country and ZIP code (where supplied) to calculate totals.
customerId, addressId, businessId: Paddle uses existing customer data to calculate totals. Typically used for logged-in customers.
Each line item includes formattedUnitTotals and formattedTotals objects that return totals formatted for the country or region being worked with, including the currency symbol.
If successful, the response includes the data sent with a details object that includes totals for the supplied prices.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | No | Paddle ID of the customer that this preview is for, prefixed with `ctm_`. | |
| addressId | No | Paddle ID of the address that this preview is for, prefixed with `add_`. Send one of `addressId`, `customerIpAddress`, or the `address` object when previewing. | |
| businessId | No | Paddle ID of the business that this preview is for, prefixed with `biz_`. | |
| currencyCode | No | Supported three-letter ISO 4217 currency code. | |
| discountId | No | Paddle ID of the discount applied to this preview, prefixed with `dsc_`. | |
| address | No | Address for this preview. Send one of `addressId`, `customerIpAddress`, or the `address` object when previewing. | |
| customerIpAddress | No | IP address for this transaction preview. Send one of `addressId`, `customerIpAddress`, or the `address` object when previewing. | |
| items | Yes | List of items to preview price calculations for. |
Implementation Reference
- src/functions.ts:148-155 (handler)The async handler function that executes the preview_prices tool by calling paddle.pricingPreview.preview(params) and handling errors.export const previewPrices = async (paddle: Paddle, params: z.infer<typeof Parameters.previewPricesParameters>) => { try { const pricingPreview = await paddle.pricingPreview.preview(params); return pricingPreview; } catch (error) { return error; } };
- src/tools.ts:421-431 (schema)Tool schema definition including method name, description from prompts, Zod input parameters schema, and required actions for permissions.method: "preview_prices", name: "Preview prices", description: prompts.previewPricesPrompt, parameters: params.previewPricesParameters, actions: { pricingpreview: { write: true, preview: true, }, }, },
- src/api.ts:20-20 (registration)Registration of the preview_prices tool in the toolMap, mapping TOOL_METHODS.PREVIEW_PRICES to the previewPrices handler function.[TOOL_METHODS.PREVIEW_PRICES]: funcs.previewPrices,
- src/constants.ts:12-12 (helper)Constant definition for the preview_prices tool method string used in registration and tool definitions.PREVIEW_PRICES: "preview_prices",