MintPay
Affiliate payouts Docs
English
  • English
  • 简体中文
  • 日本語
  • 한국어
  • Русский
Open in Telegram
Contents Overview Getting started Signing requests Orders Callbacks Test mode Funds and settlement Affiliate payouts Code samples Go-live checklist

Integration docs

For developers connecting a membership system to MintPay: create USDT orders, receive a signed callback once the payment is confirmed, then activate the member. Optionally, let your partners withdraw their commission through MintPay.

Overview

API basehttps://www.mintpay.dev
Telegram bot@MintPaymentBot
NetworkTRC20 (TRON) USDT, 6 decimals
Order lifetime30 minutes (payments within 60 minutes after expiry are still credited)
Your system                      MintPay                         Customer
   │  POST /api/v1/orders  ───────►│                               │
   │◄──── address + exact amount ──│                               │
   │  show address/amount, or send telegram_link ─────────────────►│
   │                               │◄──── customer sends USDT ─────│
   │                               │  confirmed on-chain (~1 min)
   │◄── POST your callback order.paid
   │  verify signature → activate → 2xx

A payment counts only on-chain: an order becomes paid only when a confirmed USDT transfer of at least the amount due has arrived. The exceptions are an operator settling an order by hand after checking a payment made outside the normal flow, and a small tolerance for card (on-ramp) payments. On an order settled automatically, paid_amount and txid are what arrived on chain; on one settled by hand they may be null (or below the amount due), so there they are no proof of funding.

Getting started

  1. In a private chat with the bot, send /merchant → "📝 Apply as a merchant", with your name and contact. The bot tells you once you are approved.
  2. Send /merchant again → "➕ New product". On the product page:
    • "Add plan": send name price days, for example Monthly 9.9 30. Each plan shows its plan code, which the order API takes as plan_code;
    • "🔗 Set payment callback": the URL that receives events (see Callbacks);
    • "API keys": your API Key and API Secret. The secret only signs requests; keep it on your server, and rotate it in one tap if it leaks.
  3. No code yet? Send customers the product's payment link https://t.me/MintPaymentBot?start=p_<product code>: they pick a plan and pay in the bot, and you get the callback.

Signing requests

Every /api/v1/* request carries three headers:

X-Api-Key:   <API Key>
X-Timestamp: <unix seconds>
X-Signature: hex( HMAC_SHA256( API Secret, "{timestamp}.{METHOD}.{path_with_query}.{raw_body}" ) )
  • METHOD in upper case; path_with_query is the path and query string without the host, e.g. /api/v1/orders?external_order_id=inv-1001.
  • raw_body is the exact bytes you send (empty for GET): serialize the JSON once, sign it, send those bytes.
  • A timestamp more than 300 seconds off is refused; a signed POST is accepted once — retry with a fresh timestamp.
  • Errors are {"detail": "…"}: 400 invalid request, 401 bad signature/timestamp/key, 404 not found, 422 malformed, 503 try again later.

Orders

Create an order

POST /api/v1/orders

{
  "chain": "TRC20",
  "plan_code": "<plan code>",
  "external_order_id": "inv-1001",
  "external_user_id": "member-7",
  "metadata": {"source": "web"}
}
  • Give plan_code or amount, not both. amount is a string with up to 6 decimals, at least 1.00 USDT; title (≤64) and description (≤200) are shown on the payment card.
  • external_order_id is an idempotency key: sending it again returns the same order. external_user_id and metadata come back in callbacks.
  • GET /api/v1/plans lists your plans and their codes.

Response:

{
  "order_id": "ord_4ee3f87b961949b3",
  "status": "pending",
  "chain": "TRC20",
  "network": "mainnet",
  "test": false,
  "address": "TQ…",
  "amount": "9.90",
  "base_amount": "9.90",
  "paid_amount": null,
  "txid": null,
  "plan_code": "…",
  "external_order_id": "inv-1001",
  "external_user_id": "member-7",
  "expires_at": "2026-10-21T08:30:00Z",
  "activation_status": "none",
  "telegram_link": "https://t.me/MintPaymentBot?start=ord_4ee3f87b961949b3",
  "metadata": {"source": "web"},
  "remaining_amount": null
}

Ask the customer to send exactly amount USDT to address. The amount may be a few cents above the price (it tells orders on one address apart): always show amount. Or send the customer to telegram_link and the bot shows the payment card.

Look up and cancel

GET  /api/v1/orders/{order_id}
GET  /api/v1/orders?external_order_id=inv-1001
POST /api/v1/orders/{order_id}/cancel        (only a pending order with no payment)

Statuses

pendingWaiting for payment
detectedTransfer seen, waiting for confirmation
underpaidToo little; a top-up to the same address makes it paid
paidConfirmed (the only success state)
expiredNot paid in time (a payment within the grace period is still credited)
cancelledCancelled

Callbacks

order.paidConfirmed and paid in full — the only event to activate on
order.underpaidPaid too little; includes remaining_amount. Do not activate
order.expiredNot paid in time; a later payment within the grace period still produces order.paid
order.cancelledThe order was cancelled
POST <your callback URL>
Content-Type: application/json
X-Event: order.paid
X-Delivery-Id: 42
X-Delivery-Attempt: 1
X-Timestamp: 1792540000
X-Signature: hex( HMAC_SHA256( API Secret, "{X-Timestamp}." + raw_body ) )

{
  "event": "order.paid",
  "delivery_id": 42,
  "order_id": "ord_4ee3f87b961949b3",
  "status": "paid",
  "merchant": "<product code>",
  "external_order_id": "inv-1001",
  "external_user_id": "member-7",
  "tg_user_id": 123456789,
  "plan": {"code": "…", "title": "Monthly", "duration_days": 30},
  "chain": "TRC20", "network": "mainnet", "test": false,
  "amount": "9.90", "paid_amount": "9.90", "txid": "…",
  "metadata": {"source": "web"},
  "lang": "en"
}
  1. Verify the signature first over the raw body bytes, and that X-Timestamp is within 300 seconds.
  2. Deduplicate deliveries by the signed body's delivery_id: a retry repeats it. Activate a membership at most once per order_id. A new order.underpaid (with a new remaining_amount) is a new delivery, not a duplicate. Answer 2xx to events you do not know.
  3. Answer any 2xx. Anything else, or no answer within 10 seconds, is retried after 10s, 20s, 40s… up to 12 times.
  4. Optional: answer {"message": "Welcome! https://t.me/+xxx"} and the bot passes it to the customer. Write it in the body's lang, or give several: {"messages": {"en": "…", "zh": "…"}}.

The callback URL must be reachable from the internet; private and loopback addresses are refused. "Send test callback" on the product page sends a signed ping.

Test mode (Nile)

  1. Product page → "🧪 Switch to the Nile testnet" (asks once). The product's new orders then take test USDT on the TRON Nile testnet — not real money.
  2. No code changes: still send "chain": "TRC20". Orders and callbacks carry "network": "nile" and "test": true. Check test before activating.
  3. Test coins sit in a separate test balance that cannot be withdrawn; affiliate payouts pause in test mode. Switch back to mainnet when done.

Test coins: switch TronLink to Nile Testnet and get test TRX from the Nile faucet; the test USDT contract is TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf.

Funds and settlement

  • Confirmed payments are credited to the product's ledger (the "Ledger" button lists every line).
  • Set a payout address (TRC20, a wallet whose key you hold) and turn on automatic payout: the balance is paid out on schedule (by default daily, from 20 USDT), less the actual network fee; sweep fees are shared pro rata.
  • Payouts above the single or daily limit wait for a manual review. Exchanges may deduct a withdrawal fee: an amount short of amount is underpaid.

Affiliate payouts

Your partners withdraw their commission to their own USDT address in the bot. The money comes from your product's ledger, and every payout needs your system's signed approval. Your API key can read payouts but never start one or change a limit. Overview: Affiliate payouts.

Turning it on

  1. Product page → "Turn partner withdrawals on". MintPay approves a product once; the bot tells you.
  2. Product page → "Withdrawal limits": four numbers in USDT (- for none): per payout, per day, the review line, and the reserve your automatic payout leaves, e.g. 1000 2000 500 0. Payouts at or above the review line wait for the owner's confirmation in the bot.
  3. The callback URL must be https://, and cannot be cleared or downgraded while payouts are open.
  4. Send each partner https://t.me/MintPaymentBot?start=wd_<product code>_<ref>, where ref is your id for the partner (≤32 letters and digits). It comes back in every request. The link is not a secret — anyone who has it can open it — so when you answer payout.authorize, pay only the partner whose Telegram account it is: look the partner up by tg_user_id and check that their ref matches the request's ref; refuse otherwise.

Flow and amounts

partner opens the link → picks an address → everything owed / an amount → confirms
  → MintPay sends your callback payout.authorize (signed)
  → you answer (signed): how much, or a refusal with a reason
  → MintPay checks the minimum, your limits and balance → debits the ledger → sends
  → payout.sent / payout.failed (definitely not sent, refunded) / payout.voided (never took effect)

The amount you approve is debited; the network fee (quoted when the partner asked) is withheld from it; the partner receives net_amount = amount − fee. The minimum is 10.00 USDT. If the actual fee is lower, the difference returns to your ledger; if higher, MintPay bears it — you are never debited more than you approved.

The authorization request payout.authorize

{
  "event": "payout.authorize",
  "payout_id": "po_6f1c2a9d0b1e2f3a4b5c6d7e",
  "status": "authorizing",
  "merchant": "<product code>",
  "tg_user_id": 8300963908,
  "tg_username": "channel_x",
  "ref": "u21",
  "chain": "TRC20",
  "asset": "USDT",
  "address": "T…",
  "address_is_new": true,
  "requested_amount": null,
  "fee_estimate": "4.80",
  "requested_at": "2026-10-27T08:00:00Z"
}

requested_amount: null means "everything owed": you decide the amount; otherwise approve no more than it. address_is_new is true the first time this partner uses this address.

Approve (the answer must be signed):

HTTP/1.1 200 OK
Content-Type: application/json
X-Timestamp: <unix seconds>
X-Signature: hex( HMAC_SHA256( API Secret, "{X-Timestamp}." + raw_response_body ) )

{"ok": true, "payout_id": "po_6f1c2a9d0b1e2f3a4b5c6d7e", "amount": "250.00", "address": "T…"}

Refuse: {"ok": false, "payout_id": "po_…", "reason": "You can withdraw 120.00"} (signed too; the partner sees the reason).

  • Pay only the partner the link belongs to: look the partner up by tg_user_id and refuse unless their ref matches the request's ref — anyone who has a withdrawal link can open it.
  • An unsigned answer, a wrong signature, or a different payout_id or address does not pay — including 200 {"ok": true}: the request is voided and you receive payout.voided (authorize_invalid); it is not retried. Serialize the answer, sign those bytes, send them unchanged. amount is a string.
  • Be idempotent on payout_id: store your first answer and repeat it.
  • No answer within 10 seconds, non-2xx or a network error: asked again 2 seconds later, 3 times in all; then voided with payout.voided (authorize_unreachable). Keep answers under 64 KiB: a larger one counts as no answer (asked again, then authorize_unreachable).

Follow-up callbacks

payout.heldAt your review line (owner_review) or the platform's limit (platform_review); a final callback follows once the owner or MintPay decides
payout.sentSent and confirmed; with txid, net_amount, sent_at
payout.failedDefinitely not sent (retried automatically); refunded: true
payout.voidedNever took effect, nothing debited; reason such as insufficient_balance, over_limit, owner_rejected, authorize_unreachable, authorize_invalid

Every payout_id you approved gets exactly one final callback (sent, failed or voided; for a held one, once the owner or MintPay decides) and is sent at most once; delivery is retried like any callback. Route on the signed body's event, not the X-Event header.

Read-only queries

GET /api/v1/payouts/{payout_id}
GET /api/v1/payouts?ref=u21          (or ?tg_user_id=…)
GET /api/v1/payouts/options          enabled, minimum, fee estimate, limits, used in 24 h
GET /api/v1/balance                  ledger balance and what is payable now

Code samples

Python: signed requests, an order, verifying callbacks

import hashlib, hmac, json, time
import requests

BASE = "https://www.mintpay.dev"
API_KEY = "<API Key>"
API_SECRET = "<API Secret>"


def call(method, path, body=None):
    raw = b"" if body is None else json.dumps(body, separators=(",", ":")).encode()
    ts = str(int(time.time()))
    msg = f"{ts}.{method.upper()}.{path}.".encode() + raw
    sig = hmac.new(API_SECRET.encode(), msg, hashlib.sha256).hexdigest()
    headers = {"X-Api-Key": API_KEY, "X-Timestamp": ts, "X-Signature": sig}
    if body is not None:
        headers["Content-Type"] = "application/json"
    r = requests.request(method, BASE + path, data=raw, headers=headers, timeout=15)
    r.raise_for_status()
    return r.json()


plans = call("GET", "/api/v1/plans")
order = call("POST", "/api/v1/orders", {"chain": "TRC20", "plan_code": plans[0]["code"],
                                        "external_order_id": "inv-1001", "external_user_id": "member-7"})
print(order["address"], order["amount"], order["telegram_link"])


def verify_webhook(headers, raw_body: bytes) -> bool:
    ts = headers.get("X-Timestamp", "")
    if not ts.isdigit() or abs(time.time() - int(ts)) > 300:
        return False
    expected = hmac.new(API_SECRET.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, headers.get("X-Signature", ""))

Python: answering payout.authorize (Flask)

from decimal import ROUND_DOWN, Decimal
from flask import Flask, Response, request

app = Flask(__name__)


def signed_json(answer: dict) -> Response:
    body = json.dumps(answer).encode()            # serialize first: these are the bytes you sign
    ts = str(int(time.time()))
    sig = hmac.new(API_SECRET.encode(), f"{ts}.".encode() + body, hashlib.sha256).hexdigest()
    return Response(body, 200, {"Content-Type": "application/json", "X-Timestamp": ts, "X-Signature": sig})


@app.post("/mintpay/webhook")
def webhook():
    raw = request.get_data()
    if not verify_webhook(request.headers, raw):
        return "bad signature", 401
    ev = json.loads(raw)                           # route on the signed body's event
    if ev["event"] == "payout.authorize":
        return signed_json(decide_once(ev))
    if ev["event"] in ("payout.sent", "payout.failed", "payout.voided"):
        settle_once(ev["payout_id"], ev["event"])   # mark paid or release the hold, once per payout_id
    elif ev["event"] == "order.paid" and not ev.get("test"):  # once per order (deliveries repeat: dedupe on delivery_id)
        activate_membership_once(ev["order_id"], ev["external_user_id"], ev["plan"])
    return {"ok": True}


def decide_once(ev):
    saved = load_answer(ev["payout_id"])           # a repeated request gets the first answer again
    if saved:
        return saved
    # The link (and its ref) can be opened by anyone: pay only the partner whose
    # Telegram account it is. Look the partner up by tg_user_id; the ref must match.
    partner = partner_by_telegram(ev["tg_user_id"])
    if partner is None or partner.ref != ev["ref"]:
        answer = {"ok": False, "payout_id": ev["payout_id"], "reason": "This withdrawal link is not yours"}
        save_answer(ev["payout_id"], answer)
        return answer
    owed = partner_owed(partner)                   # what this partner may withdraw now, in your books
    want = Decimal(ev["requested_amount"]) if ev["requested_amount"] else owed
    want = want.quantize(Decimal("0.000001"), rounding=ROUND_DOWN)  # one value (USDT's 6 places) for the check, the hold and the answer
    if want <= 0 or want > owed:
        answer = {"ok": False, "payout_id": ev["payout_id"], "reason": f"You can withdraw {owed:.2f}"}
    else:
        hold(partner, ev["payout_id"], want)       # hold it until the final callback
        answer = {"ok": True, "payout_id": ev["payout_id"], "amount": str(want), "address": ev["address"]}
    save_answer(ev["payout_id"], answer)
    return answer

Node.js (18+)

const crypto = require("crypto");

const BASE = "https://www.mintpay.dev";
const API_KEY = "<API Key>";
const API_SECRET = "<API Secret>";

async function call(method, path, body) {
  const raw = body === undefined ? "" : JSON.stringify(body);
  const ts = Math.floor(Date.now() / 1000).toString();
  const sig = crypto.createHmac("sha256", API_SECRET)
    .update(`${ts}.${method.toUpperCase()}.${path}.`).update(raw).digest("hex");
  const headers = { "X-Api-Key": API_KEY, "X-Timestamp": ts, "X-Signature": sig };
  if (body !== undefined) headers["Content-Type"] = "application/json";
  const r = await fetch(BASE + path, { method, headers, body: body === undefined ? undefined : raw });
  if (!r.ok) throw new Error(`${r.status} ${await r.text()}`);
  return r.json();
}

// rawBody: the request body as received (a Buffer), e.g. express.raw({ type: "application/json" })
function verifyWebhook(headers, rawBody) {
  const ts = headers["x-timestamp"] || "";
  if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const expected = crypto.createHmac("sha256", API_SECRET).update(`${ts}.`).update(rawBody).digest("hex");
  const got = Buffer.from(headers["x-signature"] || "");
  return got.length === expected.length && crypto.timingSafeEqual(got, Buffer.from(expected));
}
function signedJson(res, answer) {
  const body = Buffer.from(JSON.stringify(answer));     // these are the bytes you sign
  const ts = String(Math.floor(Date.now() / 1000));
  const sig = crypto.createHmac("sha256", API_SECRET).update(`${ts}.`).update(body).digest("hex");
  res.writeHead(200, { "Content-Type": "application/json", "X-Timestamp": ts, "X-Signature": sig });
  res.end(body);
}

async function onWebhook(req, res, rawBody) {
  if (!verifyWebhook(req.headers, rawBody)) { res.writeHead(401); return res.end(); }
  const ev = JSON.parse(rawBody);
  if (ev.event === "payout.authorize") return signedJson(res, await decideOnce(ev));
  if (["payout.sent", "payout.failed", "payout.voided"].includes(ev.event)) await settleOnce(ev.payout_id, ev.event);
  res.writeHead(200, { "Content-Type": "application/json" });
  res.end('{"ok":true}');
}

Go-live checklist

  • Run orders, payments and callbacks end to end in "🧪 Nile testnet" mode, then switch back to mainnet.
  • Keep the API secret on the server; deduplicate callbacks on delivery_id and activate once per order_id; check test before activating.
  • "Send test callback" reaches you as a ping and verifies.
  • Set a payout address and turn on automatic payout; make a small real payment.
  • Affiliate payouts: verify the signature first, approve only what you have computed and held, idempotent on payout_id.

Questions? Contact us in the bot with the order_id / payout_id (and the txid).

MintPay
English 简体中文 日本語 한국어 Русский
Affiliate payouts · Docs · Privacy Policy · © MintPay · USDT on TRON (TRC20)