Home / Developer docs / Callbacks and verification
Callbacks and verification
Every callback is signed with HMAC-SHA256 using your callback secret. This page lists the events, shows sample callbacks and Python / Node.js / PHP verification code, says how a callback must be handled, and how to send test callbacks by event type.
- API host
https://open.e8qianbao.com - Path prefix
/partner/v1 - Based on the API notes of 2026-11-29
Callbacks and verification
- The platform
POSTs JSON to your callback URL (Content-Type: application/json); any 2xx counts as delivered. Timeout 5 seconds (10 seconds for the whole request), redirects are not followed, and the response body is not read. - Headers:
X-TE-Event,X-TE-Event-Id,X-TE-Timestamp,X-TE-Signature: v1=<hex>,X-TE-Client(API client code),X-TE-Merchant(merchant code). - Signature:
HMAC-SHA256(Webhook Secret, X-TE-Timestamp + "." + body), wherebodyis the raw request body bytes; the hex result followsv1=. - At-least-once delivery: after a failure it retries at 10 s, 30 s, 2 min, 10 min, 30 min, 1 h, 2 h, 4 h, 6 h and 10 h (about 24 hours), then stops; the platform can resend by hand. A resent event keeps the same
id/X-TE-Event-Id(plusresent_ofmarking the resend), so deduplicating by event ID is enough.
Events
| Event | Sent to | Meaning |
|---|---|---|
collect.order_paid | Collect merchants | An order was paid (web checkout or Telegram wallet). Complete your own order by external_ref; it is not an on-chain deposit |
collect.deposit_credited | Collect merchants | A player address received USDT and it was credited (TRC20 / ERC20). Credit players only on this event with asset USDT, using net |
collect.trx_received | Collect merchants | A player address received TRX (same data fields, asset is TRX, no fee). Never credit it as USDT |
collect.deposit_detected | Collect merchants | Optional, off by default, ERC20 USDT only: sent once when a transfer to a player address is seen but not final. Only for telling the player; never ship, credit or add balance on it |
collect.payout_completed | Collect merchants | A payout to a player's E8 wallet succeeded |
collect.chain_payout_updated | Collect merchants | A chain payout changed state (approved / processing / completed / failed / rejected); sent once per state, with the transaction hash and fee |
collect.bill_unmatched | Collect merchants | A transfer reached a bill address without completing the bill (wrong amount, after the deadline, a duplicate or another coin); the money, minus the fee, goes to the merchant balance. Never ship on it |
collect.refund_requested | Collect merchants | A refund request was created (any source, including the owner's direct refunds); no money has moved yet. See Collect merchant refunds |
collect.order_refunded | Collect merchants | A refund reached a new status (approved / processing / completed / failed / rejected / expired); sent once per status |
partner_order.expired | Both types | An unpaid order expired (for wallet orders the order ID field is partner_order_id). Never treat it as paid |
partner_order.accepted | Escrow merchants | The buyer accepted the checkout in Telegram and an escrow order was created |
order.status_changed | Escrow merchants | The escrow order's status changed, with order_version; ignore versions lower than one you already processed |
partner_order.cancelled | Escrow merchants | The checkout was cancelled |
webhook.test | Both types | The test callback sent by POST /partner/v1/webhooks/test, with test true; sent once, never retried |
collect.order_paid example
{
"id": "1f0c…", "type": "collect.order_paid", "created_at": "2026-11-11T14:10:49+00:00",
"test": false, "environment": "chain",
"data": {
"order_id": "…", "external_ref": "AD263152207211.822", "title": "广告",
"amount": "75.24", "fee": "0.00", "net": "75.24", "currency": "USDT",
"status": "paid", "payer_telegram_id": 10001, "paid_at": "…",
"paid_network": "BALANCE", "paid_asset": "USDC"
}
}
data.amountis the order amount (USDT),data.netthe USDT credited to the merchant balance after the collection fee,data.currencyis alwaysUSDTanddata.statusispaid. The amount you ordered (amount) is authoritative.paid_networkandpaid_assetappear only for merchants with Ethereum;payer_telegram_idis empty for web checkout payments and may be empty for ERC20 online payments.- Always treat
collect.order_paidas paid. An online payment on chain before the deadline is on time, so wallet orders sendpartner_order.expiredonly 10 minutes after the deadline, and 30 minutes for orders whose buyer saw an ERC20 payment code; if confirmation takes even longer,collect.order_paidcan still arrive after the expiry callback: if the order is closed, refund the buyer or deliver anyway, but never drop it. - Balance payments have no deposit record; after a lost callback reconcile with
GET /partner/v1/collect/orders/{id}, and onlypaidcounts as paid.
collect.deposit_credited example
{
"id": "1f0c…", "type": "collect.deposit_credited", "created_at": "2026-11-08T03:04:05+00:00",
"test": false, "environment": "chain",
"data": {
"deposit_id": "…", "customer_ref": "u1001", "address": "T…", "asset": "USDT",
"amount": "100", "fee": "1", "net": "99",
"txid": "…", "event_index": 0, "block_number": 76543210,
"block_time": "…", "credited_at": "…"
}
}
ERC20 USDT deposits send the same event, with "network": "ERC20", "chain_id": 1 and "confirmations_required": "finalized" added to data (plus "source": "balance" for balance-based credits). TRC20 callbacks are unchanged.
Verification code
Verify with the raw body bytes, before parsing the JSON. The three examples below implement the same algorithm, followed by a test vector.
import hashlib
import hmac
import time
def verify_webhook(secret: str, headers, raw_body: bytes, tolerance: int = 300) -> bool:
"""headers: the request headers; raw_body: the exact bytes received, before any JSON parsing."""
ts = headers.get("X-TE-Timestamp", "")
sig = headers.get("X-TE-Signature", "")
if not ts.isdigit() or abs(time.time() - int(ts)) > tolerance or not sig.startswith("v1="):
return False
expected = hmac.new(secret.encode(), ts.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected.encode(), sig[3:].encode())
const crypto = require("node:crypto");
// rawBody: a Buffer with the exact bytes received, e.g. from express.raw({ type: "application/json" }).
function verifyWebhook(secret, headers, rawBody, tolerance = 300) {
const ts = String(headers["x-te-timestamp"] || "");
const sig = String(headers["x-te-signature"] || "");
if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > tolerance || !sig.startsWith("v1=")) {
return false;
}
const expected = crypto.createHmac("sha256", secret).update(ts + ".").update(rawBody).digest("hex");
const a = Buffer.from(sig.slice(3), "utf8");
const b = Buffer.from(expected, "utf8");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
<?php
// Verify with the raw body, before anything parses it.
function e8_verify_webhook(string $secret, string $rawBody, int $tolerance = 300): bool
{
$ts = $_SERVER['HTTP_X_TE_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_TE_SIGNATURE'] ?? '';
if (!ctype_digit($ts) || abs(time() - (int) $ts) > $tolerance || strncmp($sig, 'v1=', 3) !== 0) {
return false;
}
$expected = hash_hmac('sha256', $ts . '.' . $rawBody, $secret);
return hash_equals($expected, substr($sig, 3));
}
$raw = file_get_contents('php://input');
if (!e8_verify_webhook(getenv('TE_WEBHOOK_SECRET'), $raw)) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
// Record $_SERVER['HTTP_X_TE_EVENT_ID'] in the same transaction that applies the event; skip it if already seen.
http_response_code(200);
Webhook Secret whs_example_do_not_use
X-TE-Timestamp 1767225600
Raw body {"id":"1f0c"}
Signed string 1767225600.{"id":"1f0c"}
X-TE-Signature v1=f977bbb854be99e938911cd2c74fb6f0e974a588a209bc8e39f32fe7b34841bb
What every callback handler must do
- Verify before parsing: compute the signature over the raw body bytes and compare in constant time; drop it on a mismatch.
- Check the timestamp: drop callbacks whose
X-TE-Timestampis more than 300 seconds from your clock (replay protection). - Deduplicate by
X-TE-Event-Id, and put a database unique constraint ontxid + event_index(ordeposit_id); answer repeats with 200 and never credit again. - Trust only
data.customer_ref,data.assetanddata.net: credit players only oncollect.deposit_creditedwithassetUSDT, usingnet;customer_refmust be a player you generated, and one starting withe8bill.is not a player deposit, so never credit it. A purchase is complete only oncollect.order_paid. - Check large or suspicious ones yourself: call
GET /partner/v1/collect/deposits/{txid}to confirm the platform really has that deposit (you sign this request, so it cannot be forged). - Accept only the platform's requests at your callback URL: if you filter by source IP, use only the outbound IPs the platform gives you in writing; the signature is what really protects you, never the IP alone.
- Return 2xx only after processing succeeded; on failure return 5xx and the platform retries.
- After a lost player deposit callback, catch up with
GET /partner/v1/collect/deposits?since=…; wallet payments have no deposit record, so reconcile them withGET /partner/v1/collect/orders/{id}.
Never: credit a player from a screenshot, a block explorer link or a txid the player submits; trust a request without a valid signature; put the Secret into a front end or an app package.
Test callbacks
POST /partner/v1/webhooks/test (needs webhooks:test) without a body sends the connectivity test webhook.test, as before. A collect merchant may send {"event_type": "…"}: the platform at once sends a test event of that type to your callback URL, shaped exactly like the real event and signed with the same callback key; the returned delivered says whether a 2xx came back. API access in the Mini App and each merchant's page in the Developer center offer the same choice.
Event types: collect.order_paid, partner_order.expired, collect.deposit_credited, collect.chain_payout_updated, collect.bill_unmatched, collect.refund_requested, collect.order_refunded.
- The body has
"test": trueat the top and insidedata, and the request carries the headerX-TE-Test: 1(the connectivity testwebhook.testgoes out as before, without this header). - The order, player and transaction are made up:
external_refstarts withE8TEST-,customer_refwithe8test., transaction hashes withe8test, and amounts are small. Both prefixes are reserved from 2026-11-27 (any case): real orders, player deposit addresses and payouts can no longer use them, and ones created before still query and replay as before. - Test events are kept in the callback log like any other and can be resent by you (same event id, handy for testing deduplication); the connectivity test
webhook.testcannot be resent. - At most 10 typed test callbacks per minute per API client; beyond that you get 429. Escrow merchants have the connectivity test only; an event type returns 422
TEST_EVENT_NOT_AVAILABLE. - A test callback creates no order, deposit, payout or refund and never reaches statements or the ledger.
Never credit, ship, top up or refund on a callback whose test is true or that carries X-TE-Test: 1. Verify and deduplicate as usual, then answer 200 and only log it.
POST /partner/v1/webhooks/test
{"event_type": "collect.order_paid"}
→ POST https://your-server.example/e8/webhook
X-TE-Event: collect.order_paid
X-TE-Test: 1
{"id": "…", "type": "collect.order_paid", "created_at": "…", "test": true, "environment": "chain",
"data": {"order_id": "…", "external_ref": "E8TEST-9F1C2A7B3D4E", "title": "E8 测试订单",
"amount": "1.00", "fee": "0.01", "net": "0.99", "currency": "USDT", "status": "paid",
"payer_telegram_id": null, "paid_at": "…", "paid_network": "TRC20", "paid_asset": "USDT",
"test": true}}