Skip to content
HisarPay

Accepting payments

Invoices

An invoice is the basic unit of a payment in HisarPay: it defines how much is due, in which coin and until when. Every invoice gets its own payment address and a hosted payment page.

Statuses

pendingpartialpaid/overpaid
pending/partialexpiredpendingcancelled
Blue: open, green: paid, grey: closed. pending can go straight to paid or overpaid.
StatusMeaningEvent
pendingWaiting for payment.—
partialPartly paid; the rest is still due. The deadline moves out by at least 30 minutes.invoice.partial
paidPaid in full or within tolerance. Fulfil the order.invoice.paid
overpaidMore than due was paid. The excess is credited to your balance too.invoice.overpaid
expiredTime ran out before it was paid.invoice.expired
cancelledYou cancelled it.invoice.cancelled

paid and overpaid are final: later payments never reopen these invoices. expired can reopen with a late payment, so be ready for invoice.paid after invoice.expired.

Pricing: USD or coin

There are three ways to price an invoice:

  1. USD price, customer chooses (price_usd): the customer picks TRX or USDT on the payment page. Narrow the options with tokens.
  2. USD price, fixed coin (price_usd + token): the amount is calculated right away at the current rate.
  3. Amount in a coin (token + amount): the customer pays exactly this amount (plus any network fee). It cannot be combined with price_usd.
# 1) USD price, the customer picks the coin
curl -X POST https://hisarpay.com/v1/invoices \
  -H "Authorization: Bearer $HISARPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "price_usd": "25.00",
    "order_id": "A-1001"
  }'

# 2) USD price, fixed coin
curl -X POST https://hisarpay.com/v1/invoices \
  -H "Authorization: Bearer $HISARPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "price_usd": "25.00",
    "token": "USDT"
  }'

# 3) Exact amount in a coin
curl -X POST https://hisarpay.com/v1/invoices \
  -H "Authorization: Bearer $HISARPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "TRX",
    "amount": "150"
  }'

An invoice must be worth at least 10 USD and at most 10,000,000 USD; smaller requests get 400 amount_too_small. If no fresh rate is available for a moment, the response is 503 rate_unavailable. Retry shortly.

Amounts, network fee and commission

  • Every amount is a decimal string in both directions: "49.90", "166.333334". USD takes up to 2 decimals, coin amounts up to 6. Use a decimal library rather than floats for arithmetic.
  • USDT invoices include a 1 USDT network fee paid by the customer; TRX invoices have none. The fee shows in network_fee.
  • Commission (0.4% by default) is deducted from what you receive. Send fee_paid_by_customer: true to add it to the amount instead, so you receive the full price.
25.00 USD in USDTCustomer paysYou receive
Default26 USDT24.90 USDT
fee_paid_by_customer: true26.100402 USDT25 USDT

Rate lock and expiry

On USD-priced invoices the rate locks the moment the customer picks a coin. If the customer pays without choosing, the coin they used counts as the choice and the rate locks then. The locked rate is in rate_usd.

  • The default lifetime is the one set in your dashboard (60 minutes to start with). Per request, expires_in_minutes accepts 5–1440 minutes.
  • Once a coin is chosen the customer has at least 15 minutes left; the deadline moves out if needed.
  • A partial payment moves the deadline to at least 30 minutes from that moment.

Partial, over and late payments

  • Partial payment: the invoice becomes partial and remaining_amount shows what is left. The customer can send the rest to the same address.
  • Tolerance: you can set an underpayment tolerance of 0–20% in the dashboard. If the shortfall is within it, the invoice becomes paid and the difference is recorded in underpaid_amount.
  • Overpayment: the invoice becomes overpaid; the excess is in overpaid_amount and credited to your balance. Refund it with a withdrawal if you wish.
  • Late payment: payments mined after the deadline are still credited and flagged payment.late: true. An expired invoice reopens with such a payment: it becomes paid or overpaid if the payment covers it, partial otherwise. On USD-priced TRX invoices a late payment is valued at the current rate; the change is in payment.repriced. USDT amounts are never recalculated.
  • Wrong coin or cancelled invoice: a payment in a different coin, or to a cancelled invoice, is still credited to your balance; the invoice status does not change and an invoice.payment_received event is sent.

When you retrieve an invoice, each payment it received looks like this:

payments[0]
{
  "id": "6c2d0f0e-7a1b-4f7e-9c55-8a0d3f1e2b47",
  "txid": "9f2c51d7…e41a",
  "token": "TRX",
  "amount": "80.645162",
  "from": "TXk2…9Qp",
  "status": "confirmed",
  "confirmations": 20,
  "late": true,
  "repriced": {
    "previous_amount": "78.125",
    "amount": "80.645162",
    "rate_usd": "0.31"
  },
  "usd_value": "25.00",
  "block_time": "2026-10-23T10:04:12.000Z",
  "simulated": false
}

Payments count after 20 block confirmations on TRON (about one minute), and webhooks are sent after confirmation. GET /v1/tokens returns the current confirmation count.

Order ids and lookups

order_id is unique per mode. Creating an invoice with an order_id that already exists does not open a new one; the existing invoice comes back with 200 OK (new invoices return 201 Created). That makes retries after a network error safe.

curl https://hisarpay.com/v1/invoices/0b6a3f52-3c1d-4a7e-8f4b-1d2c3e4f5a6b \
  -H "Authorization: Bearer $HISARPAY_API_KEY"

curl https://hisarpay.com/v1/invoices/by-order/A-1001 \
  -H "Authorization: Bearer $HISARPAY_API_KEY"

metadata takes a JSON object of up to 4 KB, returned as sent, also in webhooks.

Cancelling

POST /v1/invoices/{id}/cancel cancels only pending invoices that have received nothing. An invoice with a payment, even one still unconfirmed on chain, returns 409 not_cancellable. Payments that arrive after cancellation are not lost; they are credited to your balance.

The invoice object

These are the main fields in responses. The full schema is in the API reference.

iduuid
Invoice id.
livemodeboolean
true for live invoices, false in test mode.
type"choice" | "fixed"
choice: the customer picks the coin. fixed: the coin is set up front.
statusstring
One of the statuses above.
token"TRX" | "USDT" | null
Coin to pay in; null until chosen.
amountdecimal | null
Total the customer must send (network fee included).
paid_amountdecimal
Sum of confirmed payments.
remaining_amountdecimal | null
Still due; 0 once settled.
overpaid_amount · underpaid_amountdecimal
Amount paid in excess, and the shortfall accepted within tolerance.
price_amount · price_currencystring | null
Price and "USD" for USD-priced invoices.
rate_usddecimal | null
Locked rate (USD per coin).
network_fee · commission_addeddecimal
Network fee added to the amount, and commission passed on to the customer.
addressstring | null
TRON address to pay to.
payment_urlurl
Hosted payment page.
order_id · description · metadatastring · string · object
Your values, returned as sent.
expires_at · paid_at · created_atISO 8601
Deadline, settlement time and creation time.
paymentsarray
Payments received, included when you retrieve a single invoice.