Skip to main content
The TaxService class (accessed via client.tax) estimates the tax for a shipping destination and a cart before an order is placed, so your storefront can show and charge the final, tax-inclusive total. When a store has automatic tax enabled, the estimate is calculated for the destination and itemized per jurisdiction; otherwise the store’s own rate applies. The endpoint is publishable-key accessible, so you can call it directly from the browser during checkout. The estimate is a quote only — it is never recorded for tax filing. For the full picture (how tax flows from preview → order → returns), see the Tax guide.

Methods

previewTax

Estimate the tax for a cart at a shipping destination, without creating an order.
Parameters (requestBody) Response
A line without category_name is taxed as standard tangible goods. Categories such as food, clothing, books, and digital goods are taxed differently from general merchandise, so the field changes the result wherever a jurisdiction treats them separately.

Using the estimate at checkout

Compute the order total from the estimate, then submit that same tax-inclusive total to createOrder — the order endpoint recalculates the tax server-side and confirms the total matches.
When tax_source is fallback, apply the store’s configured rate to compute the total; the order endpoint uses that same rate, so the figures agree.