Skip to content

建立充值

非同步充值介面。返回 transaction_id 與初始 status: 1 (processing);最終結果透過 card.recharged / card.recharge_failed webhook 推送。

端點

MethodPOST
Path/api/v1/openapi/card/recharge
鑑權HMAC
冪等鍵必填 Idempotency-Key

請求欄位

欄位型別必填說明
card_idstringcard_<id> 格式
amountstring (decimal)充值金額(卡內幣種單位)

請求示例

json
{ "card_id": "card_12345", "amount": "100.00" }

請求頭必須含:

http
Idempotency-Key: 7b3e9d5c-1a2b-4f3e-8c7d-6f5e4a3b2c1d

響應欄位

欄位型別說明
transaction_idstringtxn_<...> 格式
card_idstring回顯
amountstring客戶請求金額
currencystring卡內幣種
statusint1=processing 2=success 3=failed
status_descstring英文描述
created_atstringRFC3339 時間

響應示例

json
{
  "code": 200,
  "message": "成功",
  "data": {
    "transaction_id": "txn_OO20260429120000xyz",
    "card_id": "card_12345",
    "amount": "100.00",
    "currency": "USD",
    "status": 1,
    "status_desc": "processing",
    "created_at": "2026-04-29T12:00:00Z"
  }
}

典型錯誤

HTTPmessage_key說明
400amount_requiredamount 缺失
400insufficient_balance餘額不足
400openapi_invalid_card_id卡 ID 錯誤
400openapi_idempotency_key_required缺冪等鍵
401openapi_invalid_credentials鑑權失敗
404card_not_found卡不存在
409openapi_idempotency_key_conflict同 key 不同 body
500openapi_recharge_failed服務端異常

注意事項

  • 不要在前端用同一個 Idempotency-Key 重複發起多筆不同金額充值(會 409)
  • 同 key 的安全重試(網路重試)→ 返回原響應
  • transaction_idtxn_<...>(視為不透明字串),請用此值與 webhook 中的 transaction_id 對賬

採用 MIT 等價條款釋出