₮Payment API
Base URL https://pay.example.com

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.

  1. Create an invoiceYour server calls POST /v1/payment with the amount and your order ID, and stores the returned uuid.
  2. Redirect the customerSend them to the url from the response. They choose a network and see a unique deposit address, exact amount and QR code.
  3. Receive the webhookWhen the status changes, we POST a signed JSON message to your url_callback. Verify the signature before you trust it.
  4. Deliver the orderMark the order paid when status is paid or paid_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:

HeaderValue
merchantYour merchant ID.
signmd5(base64(body) + API_KEY) as lowercase hex.
Content-Typeapplication/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

POST/v1/payment

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.

FieldDescription
amountrequiredDecimal string, e.g. "25.00".
currencyrequiredInvoice 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_idrequiredYour order ID, 1–128 characters: letters, digits, - and _. Unique per merchant.
url_callbackHTTPS URL for webhooks. Defaults to the merchant's callback URL.
url_successWhere the "Return" button goes after payment.
url_returnWhere the "Back" button goes before payment.
lifetimeSeconds until the invoice expires, 300–43200. Default 3600.
networktron, 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_currencyThe payer currency: USDT, TRX (network tron), BNB (network bsc) GRAM (network ton; TON works too) or SOL (network sol).
currencies, except_currenciesLists of {"currency","network"} the payer may (not) choose from.
is_payment_multipleDefault true: the customer may top up an underpayment. With false, an underpayment ends the invoice as wrong_amount.
accuracy_payment_percentAccepted difference, 0–5 (%). Default 0.5.
discount_percentInteger from -99 to 90. A positive value lowers the price, a negative one adds a surcharge. Without it, the network discount applies.
subtract0–100. Accepted for compatibility; there is no gateway commission to split, so it has no effect.
from_referral_codeAccepted for compatibility (up to 255 characters) and ignored.
additional_dataAny string up to 255 characters. Returned in webhooks.
is_refreshWith 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

POST/v1/payment/info

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.

POST/v1/payment/check

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.

EndpointBodyWhat it does
/v1/paymentsee aboveCreate an invoice (or return the existing one for the same order_id).
/v1/payment/infouuid or order_idGet one invoice.
/v1/payment/listdate_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/qrmerchant_payment_uuidQR 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 txidSend the webhook of a finished invoice again. At most 10 times per invoice.
/v1/payment/mark-as-paiduuid or order_idAccept an underpaid invoice (wrong_amount or wrong_amount_waiting) as paid. Sends a webhook.
/v1/payment/refunduuid or order_id, address, is_subtractAsk for a refund of a paid invoice. See Refunds.
/v1/payment/discount/list{}Your discount per network.
/v1/payment/discount/setcurrency, network, discount_percentSet the discount for one network. See Discounts.
/v1/test-webhook/paymenturl_callback, currency, network, statusSend a signed test webhook. See Testing webhooks.
GET /v1/exchange-rate/{USDT|TRX|BNB|USD}/listnone (sign the empty string)Market rates from that currency to the others.
/v1/payment/check extrauuid or order_idScan the blockchain now, then return the invoice.
/v1/payment/cancel extrauuid or order_idCancel 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.

StatusFinalMeaning and what to do
checkNoWaiting for payment.
wrong_amount_waitingNoPart of the amount arrived. The customer can still send the rest.
lockedNoA 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.
paidYesPaid in full, within the accepted difference. Deliver the order.
paid_overYesPaid more than asked. Deliver the order; refund the difference if you want to.
wrong_amountYesThe invoice ended with too little paid. Don't deliver; contact the customer.
cancelYesExpired or cancelled without payment.
refund_processYesYou asked for a refund; the store's admin is sending it.
refund_paidYesThe refund was sent.
refund_failYesThe 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

POST/v1/payment/refund

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

  1. Parse the JSON and take out sign.
  2. Encode the rest again exactly like PHP's json_encode($data, JSON_UNESCAPED_UNICODE): no spaces, / written as \/, non-English text left as is.
  3. Compare md5(base64(encoded) + API_KEY) with sign in 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


      
FieldDescription
uuid, order_idIdentify the invoice.
statusSee payment statuses.
is_finaltrue when the status won't change any more.
amount, currencyThe invoice amount as you created it.
payer_amountThe USDT amount the customer was asked to send.
payment_amountThe USDT amount received so far; payment_amount_usd in USD.
network, payer_currencytron, bsc, eth, polygon, arbitrum, ton or sol, and USDT, TRX, BNB, ETH, GRAM or SOL.
txid, fromThe first payment transaction and its sender, when known.
payer_amount_exchange_rateThe USD → USDT rate used for the invoice.
additional_dataThe value you sent when creating the invoice.

Testing webhooks

POST/v1/test-webhook/payment

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 (ETH on eth), GRAM (GRAM or TON on ton) and SOL (SOL on sol), once the operator turns them on. Asking for any other currency or network returns Payment service not found or The 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_rate is that locked rate. A TRX/BNB/ETH/GRAM/SOL payment may arrive without txid when 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 422 with "… 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).
  • commission is always 0; subtract and from_referral_code are 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"]}}
HTTPMeaning
401Invalid sign: wrong merchant ID or API key, a disabled merchant, or the body changed after signing.
422A 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.
409The action doesn't fit the invoice's state, e.g. cancelling a paid invoice.
429More than 1200 requests per minute. Wait a minute and retry.
5xxTemporary 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 sign you changed by one character.
  • Receiving the same webhook twice ships the order only once.
  • An order is delivered only for paid or paid_over, never on the customer's return to url_success alone.
  • 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.