Tariffs API for Foxy.
Add US duty calculation to a Foxy.io checkout using a pre-payment webhook. Foxy posts the cart, your endpoint calls Tariffs API and returns the duty.
Foxy is a US-based hosted cart that drops into any site or CMS. Its pre-payment webhook is the right place to bolt on duty math: Foxy POSTs the cart to your endpoint before charging the card, you call Tariffs API, and you return the duty as a custom field or modified shipping total.
Built for Foxy developers.
Pre-payment hook
Foxy's pre-payment webhook is built exactly for this. Synchronous, blocks the charge until you return.
No platform redeployment
Drop the webhook URL into Foxy admin. No theme code, no plugin to install, no compile step.
Works with any frontend
Foxy attaches to Webflow, Squarespace, custom HTML, anything. The duty integration lives outside the frontend.
Public pricing
$199/month flat. No per-cart fee. Predictable spend even on traffic spikes.
Drop it in.
A pre-payment webhook in Node. Configure the URL in Foxy admin under Integrations + Webhooks.
1. Pre-payment webhook (Node, Express)
javascriptimport express from "express"
import fetch from "node-fetch"
const app = express()
app.use(express.json())
app.post("/foxy/pre-payment", async (req, res) => {
const cart = req.body._embedded["fx:items"]
const TA = process.env.TARIFFSAPI_KEY
let dutyTotal = 0
for (const item of cart) {
const hts = item._embedded["fx:item_options"]?.find(o => o.name === "hts_code")?.value
const origin = item._embedded["fx:item_options"]?.find(o => o.name === "country_of_origin")?.value
if (!hts || !origin) continue
const r = await fetch(
`https://tariffsapi.com/api/v1/tariffs/resolve?hts=${hts}&origin=${origin}`,
{ headers: { Authorization: `Bearer ${TA}` } }
)
const data = await r.json()
const rate = data.summary.total_resolved_ad_valorem_rate / 100
dutyTotal += item.price * item.quantity * rate
}
res.json({
ok: true,
details: `US duty: $${dutyTotal.toFixed(2)}`,
custom_fields: [{ name: "us_duty", value: dutyTotal.toFixed(2) }],
})
})
app.listen(3000)
One endpoint. Deterministic JSON.
Foxy's webhook is synchronous: the charge waits for your response. Tariffs API resolve responds in under 200ms for a single code; use resolve_batch for multi-item carts to keep total webhook time low.
GET /api/v1/tariffs/resolve?hts=8541.10.00.80&origin=CN
{
"summary": {
"applicable_ad_valorem_rate": 0.0,
"resolved_additional_ad_valorem_rate": 25.0,
"total_resolved_ad_valorem_rate": 25.0
},
"base_tariff": { "percentage_component": 0.0 },
"additional_measures": [
{
"program": "section_301",
"chapter_99_code": "9903.91.05",
"resolved_rate": { "percentage_component": 0.25 }
}
]
}
Foxy + Tariffs API
Where do I store HTS codes in Foxy?
Foxy uses item options. Pass hts_code and country_of_origin as hidden item options in the add-to-cart form, or set them via Foxy's API on the product.
Can I modify the cart total from the webhook?
Yes, indirectly. The pre-payment webhook can add a custom field for display and reject the charge if needed, but to modify the actual charge total you set a shipping fee or use Foxy's category logic. Many merchants render the duty in the checkout copy and bundle it into shipping.
What happens if Tariffs API is down?
Return ok: true with no duty applied (fail-open) or ok: false with a human-readable message (fail-closed). Most merchants fail-open to avoid blocking checkout and reconcile any missed duty after the fact.
Is there a Foxy template snippet for showing the duty?
Use Foxy's template language to render the custom field you set in the webhook. Foxy's docs cover the syntax in the Templates section.
- Foxy pre-payment webhook · accessed 2026-05-14
- Foxy item options + custom fields · accessed 2026-05-14