انتقل إلى المحتوى
guide31 أكتوبر 2026 · 13 min read

How to build a USDT payment gateway: checkout, settlement, refunds and running costs

One USDT payment from invoice to reconciliation: address allocation, confirmations, signed webhooks, refunds, TRON energy, freezes and build vs buy costs.

Kostiantyn Boiko, Blockchain Engineer

English original

A USDT payment gateway is nine parts working as one pipeline: an invoice API, deposit addresses, a chain scanner, confirmation rules, a ledger, signed webhooks, settlement, payouts and reconciliation. A demo that accepts one payment takes a few weeks. A gateway that holds up with real merchants takes most of a year, because the work is in the failure cases: wrong amounts, wrong networks, late payments, duplicate webhooks, refunds, sweep fees and frozen funds.

We build the payments software behind the reference exchange, both the payments gateway and the deposit flow of the reference exchange, and see it fail and recover in production. This guide follows one payment through it, lists what fails at each step, and ends with what it costs to build, license or outsource.

Why USDT, and why TRON first

On 30 October 2026 DefiLlama counted $180.2 billion of USDT: 51.4% on TRON, 39.3% on Ethereum and 5.1% on BNB Chain. Payments lean the same way. In a May 2025 Artemis study of data from payment companies, USDT carried about 80% of the sampled stablecoin payment volume, TRON was the most used chain, and B2B payments ran at $36 billion a year, up 315% year on year.

So most gateways start with USDT on TRON and Ethereum and add chains as merchants ask, each with its own scanner, fees and failure cases.

One payment, nine steps

Step What happens What goes wrong
1. Invoice The merchant’s server asks for 49.00 USD in USDT on TRON A retried request creates two invoices
2. Address The gateway assigns an address or tag for this payment Two open invoices share one address
3. Detection A scanner sees the transfer on chain The scanner stops and nothing alerts
4. Confirmations The payment waits until it cannot be reversed Crediting before finality
5. Ledger credit The merchant balance goes up, minus your fee Wrong amounts, late payments
6. Webhook The merchant’s server receives a signed event Duplicates, forgeries, events out of order
7. Settlement The balance stays in USDT or is converted No liquidity on the chain the merchant wants
8. Payout Funds go to the merchant’s approved address Fee limits, poisoned addresses, double sends
9. Reconciliation The ledger is checked against the chain Sweeps marked done that never happened

Step 1: the invoice

An invoice holds the amount, the price currency, the pay currency and network, the merchant’s order ID, an expiry and the URL for events. In our API it is one POST /v1/invoices call that returns a checkout URL.

Three decisions belong here. Idempotency: the merchant’s server retries when a response times out, and without an idempotency key each retry can create a new invoice with a new address. Price currency: a USDT-priced invoice has no exchange-rate question; a euro-priced one needs a quoted rate held until expiry. Expiry: it limits how long you honour the rate, not how long you watch the address.

Step 2: how does the gateway tell payments apart?

A token transfer carries only a sender, a recipient, a token and an amount. Four ways to match it to an invoice:

Method How the payment is identified Cost and risk
Address per invoice A fresh address for every invoice Cleanest matching; on TRON every address must be activated and swept
Address per customer Each buyer keeps one address Fewer sweeps; one open invoice per address at a time
Shared address plus tag A destination tag or memo per payment Only on chains with tags, such as the XRP Ledger
Shared address plus unique amount 49.0137 USDT instead of 49.00 No sweeps; breaks when an exchange deducts a withdrawal fee

TRC-20 and ERC-20 transfers have no memo field, so on TRON and Ethereum the choice is between the first two. On the XRP Ledger, turn on the account’s RequireDest setting so payments without a tag are rejected instead of landing unattributed.

On TRON, address reuse is a cost question. The payer pays for their own transfer, but the sweep to your hot wallet is your transaction. In our October 2026 measurements, collecting the first payment on a new address burned 7.53 TRX (6.43 for the transfer plus 1.1 to activate the account), about $2.52; each later payment on the same address cost 6.43 TRX. On a $20 payment, that first sweep is 12.6% of the amount. The receipts and fixes are in how to cut TRON energy costs.

With either address method, two rules apply: an address never serves two open invoices at once, and it stays on the watch list after its invoice expires.

Step 3: detection

A scanner follows each chain block by block and picks out transfers of the token contracts you support to the addresses you watch. Its worst failures raise no error. Three lessons from why USDT deposits get stuck:

  • Scanners die quietly. A restart bug once took our TRON detection down for 17.5 hours. Alert per chain on the scan cursor against the chain tip, minus the confirmation count.
  • Decimals belong to the contract. USDT has 6 decimals on TRON and Ethereum and 18 on BNB Chain. A scanner that assumes 6 everywhere reads a 49 USDT BEP-20 payment as 49 trillion.
  • RPC providers can be wrong. One of ours answered “rate limited” inside an HTTP 200, so failover never triggered. A broken or hostile endpoint could also serve a payment that never happened, so check large payments against a second source before crediting. See blockchain RPC failover.

Steps 4 and 5: how many confirmations before you credit?

Send the merchant a payment.detected event as soon as the transfer appears, so the checkout can say “payment received, confirming”. Nothing should ship before payment.confirmed.

Chain Block time Finality Practice
TRON 3 seconds Solidified about 18 to 19 blocks behind the head We credit after 30 blocks, about 90 seconds
Ethereum 12-second slots About 15 minutes, though finality can stall A configured depth; wait for the finalized block on large amounts
Others Varies Per chain Never below finality without reorg handling

We cut our TRON count from 50 to 30 after measuring the gap to the last solidified block at 18. Crediting below finality is only safe if the platform can reverse a credit after a reorganisation; ours cannot.

Credit the merchant in a double-entry ledger: the gross payment, your fee, and network costs on your own accounts. Keep “credited” and “swept” as separate states. Merchants care about the first; your treasury depends on the second.

Step 6: the merchant webhook

The webhook tells the merchant’s server an order is paid, so treat it as a money message:

  • Signed: HMAC-SHA256 over the timestamp and raw body with a per-merchant secret. The merchant recomputes it, compares in constant time and rejects old timestamps to stop replays. Ours allows five minutes.
  • Delivered at least once: retry with backoff while the endpoint is down. We retry for 24 hours and keep a delivery log the merchant can replay.
  • Processed once: duplicates are normal, so every event carries an ID and the merchant ignores IDs it has handled.
  • Not in order: payment.confirmed can arrive before payment.detected, so the order state should only move forward.
X-Signature: t=1729170000,v1=9f2a…
valid if constant_time_equal(HMAC-SHA256(secret, t + "." + raw_body), v1) and |now − t| ≤ 300 s

For high-value orders, the merchant should read the invoice from the API before shipping: the webhook is a notification, the API is the record.

Step 7: settlement and auto-convert

The simplest settlement is none: the merchant keeps USDT or USDC. If you also accept TRX, ETH or BTC, convert at a quoted rate as payments arrive so the merchant sees one number; the cost is the spread plus the venue fee, 0.1% on spot for a regular Binance account. Fiat payouts need a banking or off-ramp partner and the permissions to use it.

Liquidity is the part buyers tend to miss. A merchant paid on TRON who wants payouts on Ethereum needs USDT you already hold on Ethereum. Keep an inventory per chain and price the rebalancing into your fees.

Step 8: payouts

  • Pay only to addresses the merchant approved in advance with two-factor confirmation, and screen them as you screen incoming funds.
  • Price payouts for the worst case: a TRON transfer to an address that has never held USDT costs 13.03 TRX, not 6.43. Set fee_limit above that, since a transfer that runs out of energy fails and still burns TRX up to the limit.
  • Never sign a new payout after a timeout. Look up the original transaction ID first: it may already be in the mempool, and a second signature means a second payment.
  • Never copy a payout address from transaction history. Attackers send dust from lookalike addresses; we received one made to look like our own hot wallet.

Step 9: sweeping and reconciliation

Sweeping moves funds from deposit addresses to the hot wallet. Each deposit address first needs TRX or ETH to pay for it. Three rules from production:

  • Never let the hot wallet hold zero USDT. A transfer to a zero-balance address costs 130,285 energy instead of 64,285. A permanent 1 USDT reserve fixes it.
  • Watch the fee wallet. If it cannot fund the next sweep, payments are credited but never collected.
  • Nothing is marked swept without a receipt. In our own incident review, about 29% of our Ethereum mainnet transactions over 60 days had none, because parallel sends behind an RPC pool reused nonces.

Then reconcile on a schedule: merchant balances plus fee income must match what you hold on chain, with pending transactions, fee reserves and frozen funds kept on their own accounts.

The rest of a production gateway is ordinary but not optional: signing keys isolated from the API servers (an HSM or a separate signer), per-merchant API keys and roles, two-person approval for large payouts, an audit log nobody can edit, protection against webhook URLs that point into your own network, scanner backfill after an outage, and a disaster-recovery drill with a target time to restore.

The failure cases every gateway meets

Underpayment and overpayment

In our experience, most underpayments come from exchange withdrawal fees: the buyer types 49 USDT and less arrives. Decide per merchant whether a small shortfall counts as paid, needs a top-up or is refunded. Our checkout sends the buyer a top-up link and the merchant a payment.partial event with the amount due. Credit overpayments in full and flag them; returning a small difference can cost more in fees than it is worth.

Wrong network or wrong token

TRON addresses start with T and Ethereum addresses with 0x, so wallets catch that mix-up. EVM chains share one format, so a buyer can send BEP-20 USDT to an ERC-20 invoice address. With ordinary key-pair addresses you recover it with the same key on the other chain after funding it with gas; with smart-contract addresses, only if the same contract can be deployed there. A scanner also misses USDC sent to a USDT invoice unless it watches both contracts. Show the network prominently and publish a recovery fee.

Late payment after expiry

Exchanges queue withdrawals, so payments arrive after expiry. Keep watching expired addresses for days; credit late payments on USDT-priced invoices, and re-quote or let the merchant decide on fiat-priced ones.

Refunds in crypto

There are no card-style chargebacks; a refund is a new outgoing transaction with four questions:

  1. Where to? Not the sending address: for a payment from an exchange, that is the exchange’s hot wallet. Ask for a refund address on the same network and screen it.
  2. How much? For fiat-priced invoices, the fiat amount at today’s rate or the original token amount, as the merchant terms say.
  3. Who pays the fee? Usually the refund does. On TRON a refund to a fresh address costs 13.03 TRX.
  4. Who approves? A refund is a payout and gets the same approvals.

Frozen USDT and sanctioned senders

Tether’s terms allow it to freeze tokens and blacklist addresses. According to BlockSec, it blacklisted 4,163 addresses holding $1.26 billion in 2025, 3,506 of them on TRON, and according to The Block, in January 2026 it froze about $182 million on five TRON addresses at the request of law enforcement. Circle’s terms reserve the same right for USDC.

A blacklisted address can no longer send USDT, so the risk for a gateway is mixing tainted funds into the hot wallet that pays every merchant. Screen the sending address (KYT) before you credit or sweep, leave flagged payments on their deposit address, and keep the hot wallet small. OFAC lists crypto addresses on its sanctions list but warns the listings are not exhaustive, so a list check alone is not enough.

What does it cost to run a USDT payment gateway?

Software, built. Our estimate for a production gateway on TRON and Ethereum, covering everything above plus merchant panel, operator console, SDKs, monitoring and two shop plugins, is 30 to 50 engineer-months. At €8,000 to €12,000 per fully loaded engineer-month that is roughly €240,000 to €600,000 before audits, then one to three people to run it. This is an estimate, not a measured figure.

Software, licensed. BitPolaris Payments is €2,100 setup plus €410 a month on our cloud, €7,700 self-hosted plus 20% a year for updates and support, or €20,300 for the source code. See the price list.

Infrastructure and RPC. By our estimate, self-hosted production plus staging costs €600 to €1,200 a month on Hetzner or AWS, and chain RPC adds roughly €180 to €400 a month, depending on volume and redundancy. On cloud, hosting is in the monthly fee. Watch RPC volume: ours was 17 million calls a month before we cut it to about 5.6 million.

Chain fees. The payer covers their own transfer; the gateway pays to collect it:

Case Cost to collect one payment About
TRON, first payment on a new address, 1 USDT reserve kept 7.53 TRX $2.52
TRON, later payment on the same address 6.43 TRX $2.16
TRON, new address, hot wallet at zero USDT 14.13 TRX $4.74
TRON, rented energy (quotes), new address 3.0–4.1 TRX $1.01–1.37
Ethereum, gas top-up plus sweep (about 86,000 gas) at 0.062 gwei 0.0000053 ETH $0.01
Same at 0.5 gwei, our signer’s floor 0.000043 ETH $0.10
Same at 20 gwei 0.00172 ETH $3.85

TRON figures are our 16 October 2026 measurements at 100 sun per energy unit and TRX at $0.3353 (still 100 sun on 30 October). Ethereum rows use ETH at $2,235 and Etherscan’s gas price on 30 October 2026. Gas moves: in March 2022, 40.82 gwei was reported as the lowest average since August 2021. Price payouts and refunds the same way.

Screening. Chainalysis, Elliptic and TRM Labs do not publish prices; expect an annual contract sized to your assets and API volume, so ask for quotes early. AMLBot lists self-serve check credits from $1 down to $0.10 each.

Liquidity. Float on every payout chain, TRX and ETH in the fee wallets, and spread and fees on anything you convert.

Build, license or use a hosted processor?

Build in-house License software (e.g. BitPolaris) Hosted processor
Upfront 30–50 engineer-months (our estimate) €2,100 cloud setup, €7,700 self-hosted, €20,300 source Usually none
Ongoing Team, hosting, RPC €410 a month cloud, or 20% a year plus hosting self-hosted; RPC on both A fee on every payment
Merchant fee You set it You set it The processor’s; you add a margin if you resell
Licence Yours Yours The processor’s
Time to first payment Months Weeks Days

Published processor fees and status, checked on 30 October 2026:

  • NOWPayments: 1% service fee, lower for higher volume.
  • CoinGate: 1% per transaction; crypto payouts €0.50 plus 0.5% (1.5% with conversion); weekly settlement.
  • BitPay: 2% plus 25¢ under $500,000 a month, 1.5% plus 25¢ up to $1 million, 1% plus 25¢ above; more for high-risk industries.
  • Coinbase Commerce: Coinbase is moving merchants to Coinbase Business, according to its help centre; check current availability and supported assets in your country.

At 1%, a processor takes $10,000 from $1 million of monthly volume. Licensed gateway software costs a fixed fee plus the lines above, but the regulatory permissions, compliance and merchant support become yours. Our view: below a few hundred thousand dollars a month, or without the permissions to handle merchants’ crypto, use a processor; if payments are your product, own the gateway.

USDT payment gateway FAQ

How long does it take to build a USDT payment gateway?

By our estimate, 30 to 50 engineer-months for TRON and Ethereum with webhooks, payouts, an operator console and reconciliation: six to twelve months for a team of four to six. With licensed software, launch takes weeks.

Should I accept USDT on TRC-20 or ERC-20?

Both. TRON holds about half of all USDT and is what many buyers use, but collecting each payment costs the gateway 6 to 14 TRX unless you rent energy. On Ethereum a transfer cost about a cent at the gas price of 30 October 2026, but gas can rise sharply.

Do I need a licence to run a crypto payment gateway?

Usually, if you hold or transfer crypto for merchants: in the EU typically a MiCA crypto-asset service authorisation, elsewhere a VASP, money-transmission or payment licence. Check with counsel in each market.

How much does a TRC-20 USDT transaction cost the gateway?

In our October 2026 measurements, 6.43 TRX to an address that already holds USDT and 13.03 TRX to one that holds none, plus 1.1 TRX to activate a new address. Rented energy brought the transfer to 1.9 to 3 TRX on the quotes we collected.

What happens if a customer sends USDT on the wrong network?

Between TRON and Ethereum it rarely happens, because the address formats differ; between EVM chains it does. If you hold the address’s private key, the funds can usually be recovered on the other chain.

What should a USDT payment gateway API include?

Invoice creation with idempotency keys, status lookups, signed webhooks for detected, confirmed, partial and expired payments, payouts to approved addresses, a sandbox and SDKs. Merchants also expect a hosted checkout and shop plugins.

What is a self-hosted crypto payment gateway?

Gateway software on your own servers, with keys and funds in wallets you control rather than at a processor. You carry the custody and compliance duties and keep the whole merchant fee.

Payment gateway software from BitPolaris

BitPolaris Payments is the gateway software that runs in production at the reference exchange: hosted checkout and payment links, a REST API with idempotency keys and HMAC-signed webhooks (five-minute replay window, 24 hours of retries), a sandbox, SDKs for Node, PHP and Python, a merchant panel, payouts to pre-approved addresses with two-factor confirmation, and an operator console for fees, chain watchers and reconciliation.

USDT on TRON and Ethereum and USDC on Ethereum are included. BNB Chain, Solana, Avalanche, XRP, Polygon and other chains are €980 each, one-time. Options include Bitcoin, auto-convert to USDT or USDC through our Mirror engine, WooCommerce, Shopify, Magento and OpenCart plugins, a KYB and risk module with address screening, and a mass payouts API.

Cloud is €2,100 setup plus €410 a month, self-hosted €7,700, source code €20,300. You run the gateway under your own licence and set your own merchant fees; we supply the software and its updates. See payment companies for a typical configuration, or contact us with your chains, volume and markets for a fixed quote.

Sources

NOWPayments, CoinGate, BitPay and Coinbase are trademarks of their owners; this article describes their public pricing and does not imply any affiliation.

احجز مكالمة تحديد نطاق لمدة 30 دقيقة

Crypto exchange, payments, wallet, custody and token launch software, already running in production. Run it on your own servers, license the source code, or let us host it under your brand.