Wallet API钱包回调接口
Debit扣款
Take a stake. Idempotent by txnId; one wallet round may contain several debits.扣款(下注)。按 txnId 幂等;一个钱包局可以有多笔扣款。
POST
{callbackUrl}/debitTake a stake. Common and transaction fields, plus:
扣款。公共字段与交易字段,另加:
bets[]array
Bets in this debit:
{betCode, betAmount}; the sum of betAmount equals amount. Informational.这笔扣款包含的注 {betCode, betAmount},betAmount 之和等于 amount。仅供参考。merchantTxnIdstring
Your transaction id; same value on repeats. Required on
OK.商户交易号,重发时相同。OK 时必填。balancestring
Balance after the debit; on
INSUFFICIENT_BALANCE the current balance (required).扣款后余额;INSUFFICIENT_BALANCE 时为当前余额(必填)。Must必须Check, in one database transaction:
txnId seen before? → original result · txnId already rolled back? → TXN_ROLLED_BACK · round closed? → ROUND_CLOSED · player / currency / limits · balance ≥ amount → deduct and record. Record failures too.在同一个数据库事务里依次检查:txnId 处理过?→ 返回第一次的结果 · txnId 已被冲正?→ TXN_ROLLED_BACK · 钱包局已关?→ ROUND_CLOSED · 玩家 / 币种 / 限额 · 余额 ≥ 金额 → 扣款并记录。失败也要记录。| Your answer商户返回 | What we do平台处理 |
|---|---|
OK | Bet accepted.注生效。 |
INSUFFICIENT_BALANCE · BET_REJECTED · PLAYER_* · CURRENCY_MISMATCH | Bet refused; no rollback (nothing was taken).注不生效;不冲正(本来就没扣)。 |
TXN_CONFLICT · TXN_ROLLED_BACK · ROUND_CLOSED | Bet refused; alert (states diverged).注不生效;告警(两边状态不一致)。 |
Timeout · transport error · HTTP ≠ 200 · INTERNAL_ERROR · MAINTENANCE · response failing Strict response validation超时 · 网络错误 · HTTP ≠ 200 · INTERNAL_ERROR · MAINTENANCE · 响应不满足 响应强制校验 | Bet refused; rollback sent for this debit (rollbackReason: debit_uncertain or decision_failed).注不生效;对这笔扣款发冲正(rollbackReason: debit_uncertain 或 decision_failed)。 |
In blackjack, a failed insurance / split / double debit means that decision does not happen and the hand continues without it; a failed main-bet debit means the player sits out the round.
21 点里,保险 / 分牌 / 加倍的扣款失败 = 这个决策不生效,这手牌按没加注继续;主注扣款失败 = 玩家不参与这局。
Result codes结果码
OKINSUFFICIENT_BALANCEBET_REJECTEDPLAYER_NOT_FOUNDPLAYER_DISABLEDCURRENCY_MISMATCHTXN_CONFLICTROUND_CLOSEDTXN_ROLLED_BACK
In addition to the common codes listed in另可能返回通用结果码,见 Result codes结果码.
Test cases测试用例
The conformance test sends the following 34 requests to /debit. Each response must match the expected result exactly.接口对接测试会向 /debit 发送以下 34 个请求,每个响应都必须与期望结果完全一致。 All test cases全部测试用例
/debit R0 T0 A, wrong signatureThe balance remains unchanged.余额不变。
/debit R0 T0 A, same body, correct signatureThe request with the invalid signature was not recorded as processed.签名错误的请求未被记为已处理。
/debit R1 T1 seq1 Abalance = B0 − Abalance = B0 − A
/debit T1, identical bodymerchantTxnId is identical to DEB-01; no second deduction.merchantTxnId 与 DEB-01 一致;未重复扣款。
DEB-03 blocking阻断级 Debit with a reused txnId and a different amount同一交易号不同金额的扣款 Expected期望 TXN_CONFLICT/debit T1 with amount 2A/debit R2 T3 amount = balance + Adata.balance is present and equals the current balance.响应须携带 data.balance,且与当前余额一致。
/debit T3, identical bodyIdentical to DEB-05.与 DEB-05 一致。
/debit R3, one decimal more than the currency allows/debit R3 new T, currency C'/debit R3 new T, extPlayerId zz_<random>/debit R3 A, bets 2 × A/2; /credit R3 0 roundClosedIf the amount cannot be split in two at the currency precision, the debit is sent without bet lines; the round is still settled as debit A, credit 0.金额在币种精度下无法均分时,扣款不携带注单明细;该局仍按「扣款 A、派彩 0」结算。
/debit R4 seq1 main A/debit R4 new T seq2 insurance AThe debit must not be treated as a duplicate.不得视为重复请求。
/debit R4 new T seq3 double 2A/debit R4 new T seq5 A/debit R5 2A; /credit R5 A roundClosed=false; /credit R5 A roundClosed/debit R6 A; /credit R6 0 roundClosed/debit R6 new T A/debit R8 A; /credit R8 2A roundClosedOffsets the loss of MUL-09.抵补 MUL-09 的输局金额。
/debit R9 Ta A; /rollback ref Ta A round_cancelled roundClosed/debit R10 txnId Tx ANo deduction is made.未发生扣款。
/debit R11 Tb 2A; /rollback ref Tb amount AROL-07 blocking阻断级 Rollback of one debit among several (failed blackjack double)多笔扣款中单笔冲正(21 点加倍失败) Expected期望 OK ×4/debit R12 main A; /debit R12 Td double A; /rollback ref Td decision_failed; /credit R12 A roundClosed/debit R16 one unit (USD 0.01); /credit R16 same amount roundClosedBoth transactions are posted with the exact amount.两笔交易均按精确金额记账。
/debit R17 amount = current balance; /credit R17 same amount roundCloseddata.balance is 0 after the debit. BET_REJECTED (risk limits) is also compliant.扣款后 data.balance 为 0。返回 BET_REJECTED(风控限额)亦视为合规。
/debit R18 "amount": 1.00 (number, not string)No change of funds.资金不变。
/debit R18 "amount": "-1.00"No change of funds.资金不变。
/debit R18 "amount": "1e2"No change of funds.资金不变。
/debit R18 without currencyNo change of funds.资金不变。
/debit + /credit R19 with roundId and txnId of 32 charactersBoth transactions are posted.两笔交易均成功记账。
/debit R20 A with one bet line A/2; /credit R20 A roundClosedThe debit is posted at amount A.扣款按金额 A 记账。
BND-10 warning警告级 Debit of an excessive amount超大金额扣款 Expected期望 INSUFFICIENT_BALANCE or或 BET_REJECTED/debit R21 amount 100000000000000.00No change of funds; no error and no timeout.资金不变,且不得出现错误或超时。
/debit R14 T A × 10 in parallelAll OK responses carry the same merchantTxnId and the amount is deducted exactly once. INTERNAL_ERROR among the responses is tolerated; any other result code is not.所有 OK 响应的 merchantTxnId 一致,且仅扣款一次。允许夹杂 INTERNAL_ERROR,不允许其他结果码。
/debit R15…R24 A each, in parallel