TUNGKAO API 文档
🏦
API · slip_deposit

凭证充值

为你的用户充值:核验凭证、记录该用户的充值并通过 webhook 通知你的网站。

🕒 最近更新: 泰国时间(UTC+07:00) · ✅ 现有代码照常可用,无需修改

🤖 让 AI 帮你写对接代码

复制此链接给 AI 阅读(该 API 的完整 Markdown),或点击下方按钮:自动复制提示词并打开所选 AI,粘贴后告诉它你的语言/框架

https://app.tungkao.com/docs/api/slip_deposit.md?lang=zh-CN
https://api.tungkao.com/changelog/slip_deposit.json

此链接以 JSON 返回该 API 的更新(无需 key,任何域名可访问)。可在后台显示为“更新公告”框,last_updated 变化时标记“新”

复制并打开: 点击 AI 按钮会自动复制提示词,若对话框为空直接粘贴即可

🔑 使用的密钥

在商户后台(API key)创建 slip_deposit 密钥,并在每个请求中发送此 header——其他服务的密钥在这里无效

Authorization: Bearer $TUNGKAO_KEY

📋 步骤

  1. 在后台为密钥设置收款账户和 webhook 地址。
  2. 提交凭证时附带 customer_ref(你的用户 ID)。
  3. 收到 deposit.succeeded webhook(先校验签名)后为用户加余额。

📡 接口调用 + 代码示例

POST/v1/deposits/slip
curl -X POST https://api.tungkao.com/v1/deposits/slip \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"qr_payload":"0041000600000101030040220014…","customer_ref":"member-1001","expected_amount":"300.00"}'
GET/v1/deposits/dep_xxx
curl -X GET https://api.tungkao.com/v1/deposits/dep_xxx \
  -H "Authorization: Bearer $TUNGKAO_KEY"

校验 webhook 签名

每个 webhook 都带有 X-Tungkao-Signature: t=…,v1=…。信任数据前先校验(设置地址时会显示 webhook 密钥)。

import crypto from "node:crypto";
// use the raw body only — never re-JSON.stringify it
function verify(rawBody, header, secret) {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header || "");
  if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return false;
  const want = crypto.createHmac("sha256", secret).update(`${m[1]}.${rawBody}`).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(m[2]));
}

📚 使用示例

示例 1

Credit a member's deposit

场景: Member member-1001 deposits 300 THB and attaches the slip

请求
POST /v1/deposits/slip
{
  "image_base64": "<base64 of the slip image>",
  "customer_ref": "member-1001",
  "expected_amount": "300.00"
}
响应示例
{
  "success": true,
  "status": "VALID",
  "data": {
    "deposit_id": "dep_8f2c…",
    "customer_ref": "member-1001",
    "amount": "300.00"
  }
}

➡️ Store deposit_id with the order and credit the member

示例 2

Attach your own data to the deposit

场景: You want to know which promotion the deposit came from

请求
POST /v1/deposits/slip
{
  "image_base64": "<base64 of the slip image>",
  "customer_ref": "member-1001",
  "metadata": {
    "promo": "NEWYEAR",
    "channel": "app"
  }
}

➡️ metadata comes back in the webhook and when you fetch the deposit

示例 3

Receive the result by webhook

场景: With a webhook URL on the key, the result is pushed to your site

➡️ Verify the webhook signature before crediting and use deposit_id to avoid double credit

示例 4

Check a deposit later

场景: Your site missed the webhook or wants to re-check

请求
GET /v1/deposits/dep_8f2c…
响应示例
{
  "success": true,
  "data": {
    "deposit_id": "dep_8f2c…",
    "status": "succeeded"
  }
}

➡️ succeeded = credit · failed = rejected · pending = wait

示例 5

Member resubmits the same slip

场景: A member tries to deposit again with the same slip

响应示例
{
  "success": false,
  "status": "DUPLICATE"
}

➡️ DUPLICATE; no new deposit is created

📜 此 API 的更新记录

  1. 新增 泰国时间(UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  2. 新增 泰国时间(UTC+07:00)
    error.user_message: ready-to-show text for end users on outages, no credits or key problems (white-label keys omit tungkao.com)
  3. 新增 泰国时间(UTC+07:00)
    GET /status:按服务显示 API 状态(无需密钥)
  4. 新增 泰国时间(UTC+07:00)
    密钥开关及状态变更时间 + 每个网站每项服务 1 个密钥
  5. 改进 泰国时间(UTC+07:00)
    API v1 永久冻结(仅新增)+ X-Tungkao-Api-Version header + 提前 12 个月的弃用通知
  6. 文档 泰国时间(UTC+07:00)
    每个 API 独立文档页及 AI 链接(10 种语言)
  7. 安全 泰国时间(UTC+07:00)
    每个 API 密钥域名验证(1 密钥 = 1 网站)——现有密钥照常可用
  8. 新增 泰国时间(UTC+07:00)
    可选 HMAC 请求签名——不开启则一切照旧
  9. 新增 泰国时间(UTC+07:00)
    API 密钥有效期、到期提醒和续期——密钥字符串不变
  10. 新增 泰国时间(UTC+07:00)
    所有服务支持 test 模式密钥(模拟、免费)
  11. 上线 泰国时间(UTC+07:00)
    上线凭证充值和 webhook

✅ 现有代码照常可用,无需修改

🛡️ 稳定性承诺:一次对接,长期可用

🚦 系统状态(GET /status)

随时查看 API 是否正常,无需密钥

GET https://api.tungkao.com/status

curl https://api.tungkao.com/status
{
  "success": true,
  "data": {
    "status": "ok",
    "services": [
      { "id": "slip_verify", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "slip_deposit", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "login", "status": "ok" },
      { "id": "telegram", "status": "ok" },
      { "id": "discord", "status": "ok" },
      { "id": "email", "status": "busy" },
      { "id": "crypto", "status": "ok" },
      { "id": "core", "status": "ok" }
    ],
    "paused": [],
    "updated_at": "2026-11-14T12:00:00.000Z"
  }
}

🏷️ TUNGKAO 署名要求

Powered by TUNGKAO