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.
Response
requestBody)
Response
Using the estimate at checkout
Compute the order total from the estimate, then submit that same tax-inclusive total tocreateOrder — the order endpoint
recalculates the tax server-side and confirms the total matches.
shipping_amount and discount_amount to previewTax that the order will carry, so the
estimate covers the delivery charge. When tax_source is fallback, tax_amount is the store’s own
rate, computed by the same rules the order endpoint applies, so the figures agree. When
prices_include_tax is true the tax is already inside the prices: the total is
subtotal + shipping − discount, and tax_amount is the part of it that is tax.
