Accept USDT on your website
Create an invoice from your server, send the customer to the payment page, and get a signed notification when the payment is confirmed on TRON (TRC20), BNB Smart Chain (BEP20), Polygon or Arbitrum.
- Create an invoiceYour server calls
POST /v1/paymentwith the amount and your order ID, and stores the returneduuid. - Redirect the customerSend them to the
urlfrom the response. They choose a network and see a unique deposit address, exact amount and QR code. - Receive the webhookWhen the status changes, we POST a signed JSON message to your
url_callback. Verify the signature before you trust it. - Deliver the orderMark the order paid when
statusispaidorpaid_over. Treat repeated webhooks for the same order as one event.
The API follows the Cryptomus format and is served at both /v1 and /v2. If you already integrated Cryptomus payments, change the base URL, merchant ID and API key; the rest of your code keeps working. See Moving from Cryptomus for the few differences.
You need two values from the admin panel, under Merchants & API keys: your merchant ID and your API key. Keep the API key on your server only. It signs requests and verifies webhooks.
Authentication
Every request is a POST with a JSON body and two headers:
| Header | Value |
|---|---|
merchant | Your merchant ID. |
sign | md5(base64(body) + API_KEY) as lowercase hex. |
Content-Type | application/json |
body is the exact JSON string you send. Encode the JSON once, sign that string, and send the same string; re-encoding after signing changes the bytes and the signature fails with 401 Invalid sign.
The signature contains no timestamp, so anyone who sees a request could replay it. Always call the API over HTTPS from your server, never from a browser or mobile app.
Create an invoice
Creates an invoice and returns the payment page URL. Sending the same order_id again returns the existing invoice instead of creating a second one, so retries are safe.
| Field | Description |
|---|---|
amountrequired | Decimal string, e.g. "25.00". |
currencyrequired | Invoice currency: USD, USDT, TRX, BNB, ETH, SOL or GRAM (TON's coin; TON is accepted too and stored as GRAM). A TRX/BNB/ETH/SOL/GRAM invoice asks the payer for exactly that amount. |
order_idrequired | Your order ID, 1–128 characters: letters, digits, - and _. Unique per merchant. |
url_callback | HTTPS URL for webhooks. Defaults to the merchant's callback URL. |
url_success | Where the "Return" button goes after payment. |
url_return | Where the "Back" button goes before payment. |
lifetime | Seconds until the invoice expires, 300–43200. Default 3600. |
network | tron, bsc, eth, polygon, arbitrum or ton (the last four once the operator turns them on). Together with to_currency it skips the payer's choice. Without to_currency it means USDT on that network. |
to_currency | The payer currency: USDT, TRX (network tron), BNB (network bsc) GRAM (network ton; TON works too) or SOL (network sol). |
currencies, except_currencies | Lists of {"currency","network"} the payer may (not) choose from. |
is_payment_multiple | Default true: the customer may top up an underpayment. With false, an underpayment ends the invoice as wrong_amount. |
accuracy_payment_percent | Accepted difference, 0–5 (%). Default 0.5. |
discount_percent | Integer from -99 to 90. A positive value lowers the price, a negative one adds a surcharge. Without it, the network discount applies. |
subtract | 0–100. Accepted for compatibility; there is no gateway commission to split, so it has no effect. |
from_referral_code | Accepted for compatibility (up to 255 characters) and ignored. |
additional_data | Any string up to 255 characters. Returned in webhooks. |
is_refresh | With an existing order_id: reopen an expired, unpaid invoice whose network was never chosen. |
Response
Save uuid with your order. payer_amount and address stay empty until the customer chooses a network, unless you sent network.
Switching network
Until anything has been received, the customer can switch between the offered networks on the payment page, up to 3 times. Each switch gives a new address and re-prices payer_amount. Payments that still arrive at an earlier address count towards the invoice, so payment_amount is always the total in USDT. network shows the current choice. If you send network when creating the invoice, the customer can't switch.
Check an invoice
Returns the same object as Create an invoice. Send uuid or order_id; if you send both, order_id is used, as on Cryptomus. An unknown invoice returns 422 Payment not found.
Use it when a customer returns to your site before the webhook arrives, or to double-check a webhook before you ship something valuable.
Same as info, but first scans the blockchain for this invoice instead of waiting for the next automatic check.
All endpoints
All endpoints use the same headers and signing. The helper from Create an invoice works for every one of them.
| Endpoint | Body | What it does |
|---|---|---|
/v1/payment | see above | Create an invoice (or return the existing one for the same order_id). |
/v1/payment/info | uuid or order_id | Get one invoice. |
/v1/payment/list | date_from, date_to (optional, YYYY-MM-DD HH:mm:ss, UTC) | Your invoices, newest first, 100 per page, as {items, paginate}. Pass ?cursor= with paginate.nextCursor or previousCursor. |
/v1/payment/services | {} | Networks you can accept, with amount limits and commission (always 0). |
/v1/payment/qr | merchant_payment_uuid | QR code of the deposit address as a PNG data URI in result.image. The network must already be chosen. |
/v1/payment/resend (also /v2/…) | uuid, order_id or txid | Send the webhook of a finished invoice again. At most 10 times per invoice. |
/v1/payment/mark-as-paid | uuid or order_id | Accept an underpaid invoice (wrong_amount or wrong_amount_waiting) as paid. Sends a webhook. |
/v1/payment/refund | uuid or order_id, address, is_subtract | Ask for a refund of a paid invoice. See Refunds. |
/v1/payment/discount/list | {} | Your discount per network. |
/v1/payment/discount/set | currency, network, discount_percent | Set the discount for one network. See Discounts. |
/v1/test-webhook/payment | url_callback, currency, network, status | Send a signed test webhook. See Testing webhooks. |
GET /v1/exchange-rate/{USDT|TRX|BNB|USD}/list | none (sign the empty string) | Market rates from that currency to the others. |
/v1/payment/check extra | uuid or order_id | Scan the blockchain now, then return the invoice. |
/v1/payment/cancel extra | uuid or order_id | Cancel an open invoice while nothing has been paid to it. Sends a cancel webhook. Refused (409) once a payment has arrived or is on its way: the invoice then ends as paid, or as wrong_amount when the time runs out. |
Payment statuses
status and payment_status carry the same value. Final statuses never change again, except that an admin can confirm a late payment manually.
| Status | Final | Meaning and what to do |
|---|---|---|
check | No | Waiting for payment. |
wrong_amount_waiting | No | Part of the amount arrived. The customer can still send the rest. |
locked | No | A payment arrived, but the AML check flagged where it comes from. It is not counted until the gateway admin decides: then paid/paid_over (accepted) or back to waiting (rejected). Only when the AML check is on. |
paid | Yes | Paid in full, within the accepted difference. Deliver the order. |
paid_over | Yes | Paid more than asked. Deliver the order; refund the difference if you want to. |
wrong_amount | Yes | The invoice ended with too little paid. Don't deliver; contact the customer. |
cancel | Yes | Expired or cancelled without payment. |
refund_process | Yes | You asked for a refund; the store's admin is sending it. |
refund_paid | Yes | The refund was sent. |
refund_fail | Yes | The refund could not be made. Contact the customer. |
Cryptomus also lists process, confirm_check, fail and system_fail. This gateway never sends them: payments are reported only after they are confirmed, so you go straight from check to the result.
Payments are only counted after network confirmations: finalized blocks on TRON, and the configured number of blocks on BNB Smart Chain (15 by default, a few seconds).
Refunds
Works for invoices with status paid or paid_over. Send address, the customer's wallet on the network the payment came from, and is_subtract (boolean). The address is checked for that network. The invoice moves to refund_process and you get a webhook.
This is a self-hosted gateway, so funds sit in your own wallets and the refund isn't sent automatically. The admin sees the request under Invoices → Refund requests, sends the USDT, and marks it Refund sent with the transaction ID (status refund_paid) or Refund failed (refund_fail). Each step sends a webhook.
Discounts
Set a default discount per network with /v1/payment/discount/set, e.g. {"currency":"USDT","network":"tron","discount_percent":5}. The value is an integer from -99 to 90: positive lowers the price, negative adds a surcharge (useful to cover network fees). It applies to new invoices that don't send their own discount_percent, and the payment page shows the adjusted amount for each network.
Webhooks
We POST a JSON message to url_callback every time an invoice's status changes. The signature is inside the body, in the sign field.
A partial payment that the customer can still complete (wrong_amount_waiting) is not sent by default: you get one webhook with the result, paid/paid_over when the amount is complete, or wrong_amount/cancel when the time runs out. The gateway operator can turn partial-payment webhooks on per merchant, and can also fix is_payment_multiple for a merchant, overriding the value sent with the invoice.
Verify every webhook
- Parse the JSON and take out
sign. - Encode the rest again exactly like PHP's
json_encode($data, JSON_UNESCAPED_UNICODE): no spaces,/written as\/, non-English text left as is. - Compare
md5(base64(encoded) + API_KEY)withsignin constant time.
The samples do this for you and were tested against the gateway's own signing code, including Persian text and slashes in the data.
Your endpoint must
- Be HTTPS on port 443 with a public IP. Plain HTTP, other ports and private addresses are refused.
- Answer with any 2xx within 15 seconds. Redirects are not followed.
- Handle duplicates: the same status can arrive more than once. Update each order once.
Retries
If delivery fails we retry up to 10 times, waiting 1, 2, 4, 8… minutes, at most 1 hour between tries. You can see every attempt in the admin panel and trigger a new one with /v1/payment/resend.
Webhook payload
| Field | Description |
|---|---|
uuid, order_id | Identify the invoice. |
status | See payment statuses. |
is_final | true when the status won't change any more. |
amount, currency | The invoice amount as you created it. |
payer_amount | The USDT amount the customer was asked to send. |
payment_amount | The USDT amount received so far; payment_amount_usd in USD. |
network, payer_currency | tron, bsc, eth, polygon, arbitrum, ton or sol, and USDT, TRX, BNB, ETH, GRAM or SOL. |
txid, from | The first payment transaction and its sender, when known. |
payer_amount_exchange_rate | The USD → USDT rate used for the invoice. |
additional_data | The value you sent when creating the invoice. |
Testing webhooks
Sends a signed webhook to url_callback (6–150 characters) so you can test your endpoint without paying. Required: currency (USDT, TRX, BNB, ETH, GRAM or SOL) and network (tron, bsc, eth, polygon, arbitrum, ton or sol). status defaults to paid; any status from the table above works. Add uuid or order_id to get the body of a real invoice with that status; otherwise the fields are filled with sample values. The call returns at once with {"state":0,"result":[]} and the delivery shows up in the admin panel's webhook log, marked as a test.
Moving from Cryptomus
- Webhooks come from your gateway server's IP, not from Cryptomus's
91.227.144.54. If your site only accepts webhooks from that IP, allow your gateway's IP instead. The signature check doesn't change. - Offered: USDT on TRON (
tron) and BNB Smart Chain (bsc); USDT on Ethereum (eth, ERC20), Polygon (polygon), Arbitrum One (arbitrum), TON (ton) and Solana (sol), and the coins TRX, BNB, ETH (ETHoneth), GRAM (GRAMorTONonton) and SOL (SOLonsol), once the operator turns them on. Asking for any other currency or network returnsPayment service not foundorThe network was not found. - TRX, BNB, ETH, GRAM and SOL are priced from two public sources that must agree, plus a small margin; the price is locked when the payer chooses the coin.
payer_amount_exchange_rateis that locked rate. A TRX/BNB/ETH/GRAM/SOL payment may arrive withouttxidwhen it was sent by a contract (some exchanges do this); it still counts. - Payouts, transfers, static wallets, balances and recurring payments need a custodial service and aren't offered. Those endpoints answer
422with "… is not available on this self-hosted gateway" instead of 404, so the failure is obvious. - Refunds are requested by API and sent by the admin (see Refunds).
commissionis always0;subtractandfrom_referral_codeare accepted but have no effect.
Errors and limits
Errors return state: 1 with either a message or, for invalid fields, an errors object.
{"state":1,"errors":{"order_id":["validation.alpha_dash"]}}
| HTTP | Meaning |
|---|---|
401 | Invalid sign: wrong merchant ID or API key, a disabled merchant, or the body changed after signing. |
422 | A field is missing or invalid (errors lists which), the invoice doesn't exist or belongs to another merchant (Payment not found), or the feature isn't offered. |
409 | The action doesn't fit the invoice's state, e.g. cancelling a paid invoice. |
429 | More than 1200 requests per minute. Wait a minute and retry. |
5xx | Temporary problem. Retry with the same order_id; you won't get a duplicate invoice. |
Before going live
- The API key is only on your server, in an environment variable or secrets file, not in your code repository.
- Your webhook endpoint rejects a message whose
signyou changed by one character. - Receiving the same webhook twice ships the order only once.
- An order is delivered only for
paidorpaid_over, never on the customer's return tourl_successalone. - You paid a real invoice of 1 USDT on each network you use and saw the webhook arrive.
- An expired invoice reaches your site as
cancel, and you release the reserved stock.