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 等价条款发布