Tariffs API for Adobe Commerce.
Add US duty calculation to Magento Open Source or Adobe Commerce checkouts with a thin PHP module that calls our REST endpoint and writes the result as a quote total.
Adobe Commerce (formerly Magento) is the workhorse for US mid-market and enterprise stores. The integration here is a small PHP module that hooks into the quote totals collector, calls Tariffs API per cart item, and adds the duty as a custom total. Works on both Open Source and Adobe Commerce editions.
Built for Adobe Commerce developers.
Native quote total
Magento's totals_sort + collector pattern lets you slot duty in alongside tax and shipping with no theme changes.
Enterprise-ready
PHP-only, no external service to host. Deploy via Composer to a single instance or a multi-store setup.
Section 301/232/IEEPA covered
All US stacking returned in one call. No second integration needed for Chapter 99 measures.
Public pricing
$199/month flat, 100,000 API calls. No per-shipment fee, no commitment, no demo call.
Drop it in.
Two pieces: a thin HTTP client class and a quote total collector that calls it. Plus DI wiring.
1. HTTP client (app/code/Vendor/TariffsApi/Model/Client.php)
php<?php
namespace Vendor\TariffsApi\Model;
use Magento\Framework\HTTP\Client\Curl;
class Client
{
public function __construct(private Curl $curl) {}
public function resolve(string $hts, string $origin): array
{
$key = getenv('TARIFFSAPI_KEY');
$url = "https://tariffsapi.com/api/v1/tariffs/resolve?hts={$hts}&origin={$origin}";
$this->curl->addHeader('Authorization', "Bearer {$key}");
$this->curl->get($url);
return json_decode($this->curl->getBody(), true);
}
}
2. Quote total collector
php<?php
namespace Vendor\TariffsApi\Model\Quote;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address\Total;
use Magento\Quote\Model\Quote\Address\Total\AbstractTotal;
use Vendor\TariffsApi\Model\Client;
class DutyCollector extends AbstractTotal
{
public function __construct(private Client $client) {
$this->setCode('us_duty');
}
public function collect(Quote $quote, $shippingAssignment, Total $total)
{
parent::collect($quote, $shippingAssignment, $total);
$duty = 0.0;
foreach ($shippingAssignment->getItems() as $item) {
$product = $item->getProduct();
$hts = $product->getCustomAttribute('hts_code')?->getValue();
$origin = $product->getCustomAttribute('country_of_origin')?->getValue();
if (!$hts || !$origin) continue;
$data = $this->client->resolve($hts, $origin);
$rate = ($data['summary']['total_resolved_ad_valorem_rate'] ?? 0) / 100;
$duty += $item->getRowTotal() * $rate;
}
$total->addTotalAmount('us_duty', $duty);
$total->addBaseTotalAmount('us_duty', $duty);
return $this;
}
}
3. DI: register collector (etc/sales.xml)
xml<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Sales:etc/sales.xsd">
<section name="quote">
<group name="totals">
<item name="us_duty" instance="Vendor\TariffsApi\Model\Quote\DutyCollector" sort_order="350"/>
</group>
</section>
</config>
One endpoint. Deterministic JSON.
The resolve endpoint returns base HTSUS duty plus every applicable Chapter 99 measure (Section 301, 232, IEEPA) in a single deterministic JSON response. Memoize per [hts, origin] in Magento's cache layer to keep request count low across cart updates.
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 }
}
]
}
Adobe Commerce + Tariffs API
Is there a module on the Magento Marketplace?
Not yet. A Marketplace-listed module is on the roadmap. For now you vendor the small module above into your project, which most Adobe Commerce teams prefer for auditability.
Where do I store HTS codes?
Add hts_code and country_of_origin as product custom attributes via a setup script. They flow into the quote item naturally.
Does this work with Hyvä Themes?
Yes. The integration is backend-only. Hyvä reads the quote totals like any other theme.
What about EU VAT and other taxes?
Tariffs API is US duty only. Keep your existing tax integration (e.g. Vertex, Avalara) for VAT and sales tax. Our duty total is additive.
- Adobe Commerce: extending sales totals · accessed 2026-05-14
- Adobe Commerce product custom attributes · accessed 2026-05-14