API 路徑、欄位名稱、事件名稱和程式碼範例保持英文,與介面完全一致,可直接複製使用。
Webhook
每當儲值或代付(出款)狀態變化時,我們會向您的接收端點發送一個 HTTPS POST。這就是您的回呼網址(也叫通知網址):您自己伺服器上的一個公開 HTTPS 端點,例如 https://api.example.com/icryptonow/webhook。
在商戶後台的開發者 → Webhook 端點中設定(需要輸入 2FA 驗證碼)。簽名密鑰(whsec_…)只在儲存網址時顯示一次,請立即保存。
推送規則
- 請在 10 秒內返回任意
2xx狀態碼。回應內容會被忽略;重新導向視為失敗。 - 推送失敗會按退避間隔重試(10 秒、20 秒、40 秒……最長間隔 1 小時),持續 24 小時。
- 推送至少一次,且不保證順序。請按
event_id去重,並以data中的status為準。
請求標頭
| 標頭 | 值 |
|---|---|
X-Event-Id | 與請求內容中的 event_id 相同 |
X-Event-Type | 與請求內容中的 type 相同 |
X-Timestamp | Unix 時間(毫秒),每次推送都會更新 |
X-Signature | 十六進位 HMAC-SHA256,見下文 |
事件
| type | 觸發時機 |
|---|---|
deposit.detected | 鏈上已發現一筆轉到玩家地址的付款。尚未最終確認:不要入帳。Standard 儲值不發這個事件,最終確認後才報告。 |
deposit.confirmed | 儲值已最終確認。按完整的 data.amount 為玩家入帳;您的餘額收到 data.net(amount 減去我們的手續費,手續費由您承擔)。 |
deposit.below_min | 儲值低於最低金額,未入帳。 |
deposit.flagged | 不入帳。reason:high_risk(來源錢包與被制裁、被盜或洗錢的資金有關,俗稱黑U,帶 risk)、verification_failed 或 asset_not_enabled。不要為玩家加值。 |
deposit.unmatched | 轉入您Standard收款地址的一筆款項比對不到任何支付頁面訂單(金額不符、逾時或沒有透過頁面付款)。不入帳:在後台分配給某位玩家(之後收到 deposit.confirmed),或標記為您自己的儲值(vault.topup)。 |
deposit.orphaned | 已發現的儲值所在區塊被鏈重組移除。之後仍可能收到 deposit.confirmed。 |
deposit.swept | 這筆儲值已歸集到您的金庫。僅作通知:它在 deposit.confirmed 時已經入帳。 |
payout.pending_approval | 代付正在等待人工審批。 |
payout.completed | 代付已在鏈上確認。data.tx_hash 已有值。 |
payout.failed | 代付無法發送。data.reason 說明原因。 |
payout.rejected | 代付在審批中被拒絕。預留的金額會釋放。 |
vault.topup | 資金直接轉入了您的金庫(沒有經過儲值地址)。計入您的餘額,不收手續費。Standard 網絡上,轉入金庫的款項先以 deposit.unmatched 通知,您標記為自己的儲值後才發 vault.topup。 |
vault.withdrawal | 資金在代付之外轉出了您的金庫,例如您自己提款。從您的餘額中扣除。 |
儲值事件攜帶儲值資訊(deposit_id、chain、asset、decimals、address、player_ref、from、amount、tx_hash……),見儲值;透過支付頁面付的儲值還會帶 checkout(id、order_id)。代付事件攜帶完整的代付物件。金庫事件攜帶 vault_event_id、asset、vault、counterparty、amount 和 tx_hash。
{
"event_id": "9d4f7a12-3b6e-4c8d-a1f0-5e2b7c9d0a14",
"type": "deposit.confirmed",
"created_at": "2026-10-10T08:01:12.000Z",
"data": {
"deposit_id": "c1a5e8f2-7b3d-4e9a-8c6f-1d2e3f4a5b6c",
"status": "confirmed",
"chain": "tron",
"asset": "tron:USDT",
"decimals": 6,
"address": "TQ9xG7c2...7kLm",
"player_ref": "player_1024",
"from": "TFp3...Wq8",
"amount": "50000000",
"fee": "1000000",
"net": "49000000",
"tx_hash": "7c3e...b91d",
"log_index": 0,
"block_number": "68421337",
"finality": "finalized"
}
}Standard 儲值
TRON 或 Ethereum 網絡設為Standard時,玩家透過支付頁面按準確金額付款到您的收款地址。這些儲值用同樣的事件:deposit.confirmed(或 deposit.flagged / deposit.below_min),address 是您的收款地址,帶上會話的 player_ref 和 checkout(id、order_id)。沒有 deposit.detected 和 deposit.swept:儲值在最終確認後才報告,而且已經在您的金庫裡。
轉入這個地址、但比對不到訂單的款項(金額不符、逾時或沒有透過頁面付款)不會入帳。您會收到 deposit.unmatched,帶 vault_event_id、status、chain、asset、decimals、address、from、amount(最小單位,跟所有事件一樣)、tx_hash、log_index 和 block_number。不要據此為任何人入帳。請在後台的等您處理的付款裡處理:分配給某位玩家後,會照常收到該 player_ref 的 deposit.confirmed;標記為您自己的儲值後,會收到 vault.topup。
{
"event_id": "2b8e6c41-9f3a-4d7e-b5c2-8a1f0e9d7c63",
"type": "deposit.unmatched",
"created_at": "2026-11-06T09:14:03.000Z",
"data": {
"vault_event_id": "e4d2a9b1-6c8f-4a3e-9d7b-0f1e2c3a4b5d",
"status": "unmatched",
"chain": "tron",
"asset": "tron:USDT",
"decimals": 6,
"address": "TVk8...3pQr",
"from": "TFp3...Wq8",
"amount": "100250000",
"tx_hash": "a91f...04ce",
"log_index": 0,
"block_number": "68533102"
}
}驗證簽名
簽名方式與 API 請求相同,只是以您的 Webhook 密鑰作為簽名金鑰:
hex(HMAC-SHA256(whsec_secret, "{X-Timestamp}\nPOST\n{path + query of your webhook URL}\n{raw body}"))- 使用原始請求內容,在任何 JSON 解析之前。
- 密鑰按發放時的原樣使用,包括
whsec_前綴。 - 拒絕超過 5 分鐘的時間戳記,並用固定時間比較簽名。
import crypto from "node:crypto"; import express from "express"; const WEBHOOK_SECRET = process.env.ICN_WEBHOOK_SECRET; // whsec_... (use as-is) const app = express(); // Keep the raw body: the signature covers the exact bytes we sent. app.post("/webhooks/icryptonow", express.raw({ type: "application/json" }), (req, res) => { const ts = req.get("X-Timestamp"); const raw = req.body.toString("utf8"); const expected = crypto .createHmac("sha256", WEBHOOK_SECRET) .update(`${ts}\nPOST\n${req.originalUrl}\n${raw}`) .digest("hex"); const given = Buffer.from(req.get("X-Signature") ?? "", "utf8"); const fresh = Math.abs(Date.now() - Number(ts)) < 5 * 60 * 1000; if (!fresh || given.length !== 64 || !crypto.timingSafeEqual(given, Buffer.from(expected))) { return res.sendStatus(401); } const event = JSON.parse(raw); // Deliveries are at-least-once: skip event_ids you have already processed. queueForProcessing(event); res.sendStatus(200); // reply fast; do the work asynchronously });
import hashlib, hmac, json, os, time from flask import Flask, abort, request WEBHOOK_SECRET = os.environ["ICN_WEBHOOK_SECRET"] # whsec_... (use as-is) app = Flask(__name__) @app.post("/webhooks/icryptonow") def icryptonow_webhook(): ts = request.headers.get("X-Timestamp", "") raw = request.get_data(as_text=True) # exact bytes we sent path = request.full_path.rstrip("?") # path + query of your webhook URL msg = f"{ts}\nPOST\n{path}\n{raw}".encode() expected = hmac.new(WEBHOOK_SECRET.encode(), msg, hashlib.sha256).hexdigest() fresh = ts.isdigit() and abs(time.time() * 1000 - int(ts)) < 5 * 60 * 1000 if not fresh or not hmac.compare_digest(expected, request.headers.get("X-Signature", "")): abort(401) event = json.loads(raw) # Deliveries are at-least-once: skip event_ids you have already processed. queue_for_processing(event) return "", 200