Developers · v1

Payments APIreference.

Base URL https://api.lastserver.cloud/v1 · JSON over HTTPS · Bearer keys · OpenAPI spec

Quick start

  1. Create an account and complete identity verification.
  2. Open Dashboard → Payments API and create a key. Copy the API key and webhook secret; they're shown once.
  3. Create an invoice from your server and redirect the customer to checkout_url.
  4. Handle the invoice.paid webhook (or poll GET /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

POST/v1/invoices
FieldTypeDescription
amountnumberRequired. Amount in USDT, 1 to 1,000,000, up to 2 decimals.
coinstringDefault USDT-TRC20 (currently the only option).
order_idstringYour reference, up to 100 characters. Returned in webhooks.
descriptionstringShown to the customer on the checkout page.
redirect_urlstringWhere the checkout sends the customer after payment.
webhook_urlstringOverrides the key's webhook URL for this invoice.
expires_in_minutesnumber10 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

GET/v1/invoices/:id

Returns the invoice object. Useful for polling if you don't use webhooks.

List invoices

GET/v1/invoices?status=paid&limit=20

Newest first. status is optional: pending, paid, expired or cancelled. limit 1–100.

Cancel an invoice

POST/v1/invoices/:id/cancel

Only pending invoices can be cancelled.

Balance

GET/v1/balance
{ "balances": [ { "coin": "USDT-TRC20", "amount": "1194.000000000000000000" } ] }

Rates & status

GET/v1/rates

No key needed. Returns the current fee percentage, invoice lifetime and which coins are enabled.

Invoice object

FieldDescription
statuspending → paid, or expired / cancelled.
pay_amountExact amount to send.
addressTRON address to pay.
txidBlockchain transaction hash once paid.
fee, net_amountProcessing fee and the amount credited to you.
paid_at, expires_atTimestamps 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

StatusMeaning
400Invalid input. {"error": "…"} explains what to fix.
401Missing, malformed or revoked API key.
403Merchant account frozen or not verified.
404Invoice not found (or not yours).
429Rate limit: 120 requests per minute per IP.
503Payments in that coin are temporarily unavailable.