Quick start
- Create an account and complete identity verification.
- Open Dashboard → Payments API and create a key. Copy the API key and webhook secret; they're shown once.
- Create an invoice from your server and redirect the customer to
checkout_url. - Handle the
invoice.paidwebhook (or pollGET /v1/invoices/:id) and fulfil the order.
Authentication
Send your key in the Authorization header. Keys look like ak_1a2b3c4d_…. Keep them on your server; never put them in a browser or app.
Authorization: Bearer ak_1a2b3c4d_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Create an invoice
| Field | Type | Description |
|---|---|---|
amount | number | Required. Amount in USDT, 1 to 1,000,000, up to 2 decimals. |
coin | string | Default USDT-TRC20 (currently the only option). |
order_id | string | Your reference, up to 100 characters. Returned in webhooks. |
description | string | Shown to the customer on the checkout page. |
redirect_url | string | Where the checkout sends the customer after payment. |
webhook_url | string | Overrides the key's webhook URL for this invoice. |
expires_in_minutes | number | 10 to 1440. Default 30. |
curl https://api.lastserver.cloud/v1/invoices \
-H "Authorization: Bearer $AMERIFAX_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 120, "order_id": "1042", "description": "Pro plan",
"redirect_url": "https://shop.example/thanks"}'{
"id": "inv_3f9c0d1e2a4b5c6d7e8f",
"status": "pending",
"coin": "USDT-TRC20", "currency": "USDT", "network": "TRC20",
"amount": "120.00",
"pay_amount": "120.37",
"address": "T…",
"checkout_url": "https://pay.lastserver.cloud/i/inv_3f9c0d1e2a4b5c6d7e8f",
"order_id": "1042", "fee": "0.600000", "net_amount": "119.400000",
"expires_at": "2026-11-12 14:30:00", …
}pay_amount is the exact amount the customer must send. It's your amount plus a few cents so each open invoice can be matched on the blockchain without a memo. You are credited net_amount (amount minus fee).
Get an invoice
Returns the invoice object. Useful for polling if you don't use webhooks.
List invoices
Newest first. status is optional: pending, paid, expired or cancelled. limit 1–100.
Cancel an invoice
Only pending invoices can be cancelled.
Balance
{ "balances": [ { "coin": "USDT-TRC20", "amount": "1194.000000000000000000" } ] }Rates & status
No key needed. Returns the current fee percentage, invoice lifetime and which coins are enabled.
Invoice object
| Field | Description |
|---|---|
status | pending → paid, or expired / cancelled. |
pay_amount | Exact amount to send. |
address | TRON address to pay. |
txid | Blockchain transaction hash once paid. |
fee, net_amount | Processing fee and the amount credited to you. |
paid_at, expires_at | Timestamps in UTC. |
Hosted checkout
Send the customer to checkout_url. The page shows the exact amount, a QR code and a countdown, and updates by itself when the payment confirms. If you set redirect_url, the customer is sent back after payment.
Webhooks
When an invoice is paid we POST JSON to your webhook URL:
POST /your-webhook
X-Amerifax-Event: invoice.paid
X-Amerifax-Timestamp: 1794470000
X-Amerifax-Signature: sha256=5d41402abc4b2a76b9719d911017c592…
{ "event": "invoice.paid", "created": "2026-11-12T14:12:03Z",
"data": { "id": "inv_…", "status": "paid", "order_id": "1042",
"amount": "120.00", "net_amount": "119.400000", "txid": "…" } }Reply with any 2xx status. Failed deliveries are retried after 1, 5, 30, 120 and 720 minutes. Make your handler idempotent: use the invoice id to ignore repeats.
Verify signatures
Compute HMAC-SHA256 of timestamp + "." + raw_body with your webhook secret and compare it to the signature. Reject timestamps older than 5 minutes.
const crypto = require('crypto');
function verify(rawBody, headers, secret) {
const ts = headers['x-amerifax-timestamp'];
const sig = (headers['x-amerifax-signature'] || '').replace('sha256=', '');
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const expected = crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex');
return sig.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
}$ts = $_SERVER['HTTP_X_AMERIFAX_TIMESTAMP'] ?? '';
$sig = str_replace('sha256=', '', $_SERVER['HTTP_X_AMERIFAX_SIGNATURE'] ?? '');
$raw = file_get_contents('php://input');
$ok = abs(time() - (int)$ts) < 300 &&
hash_equals(hash_hmac('sha256', $ts . '.' . $raw, getenv('AMERIFAX_WHSEC')), $sig);Errors & limits
| Status | Meaning |
|---|---|
400 | Invalid input. {"error": "…"} explains what to fix. |
401 | Missing, malformed or revoked API key. |
403 | Merchant account frozen or not verified. |
404 | Invoice not found (or not yours). |
429 | Rate limit: 120 requests per minute per IP. |
503 | Payments in that coin are temporarily unavailable. |