Wallet integration
After this page you can build the four wallet endpoints Reelbit calls, and handle every failure case correctly.
#The four calls
You give Reelbit a wallet base URL. Reelbit sends signed POST requests to four paths under it. Verify each signature with your outbound secret, as in Authentication and signing.
| Call | What you do | Other providers call it |
|---|---|---|
POST /balance | Return the player's balance. | balance |
POST /debit | Take the play amount. | bet |
POST /credit | Pay the win (may be 0) and close the round. | win |
POST /rollback | Undo a debit Reelbit could not confirm. | refund, cancel |
Every call carries request_id, player_id, currency and session_id, plus operator_session_id if you sent one. Every success answer is:
{ "balance": 49850 }balance is the player's balance after the call, in integer minor units. Refusals use the error body and a code from the error catalogue, for example:
{ "code": "INSUFFICIENT_FUNDS", "message": "Balance is lower than the debit.", "request_id": "req_9f2c1a" }The full request and response schemas are in the API reference.
#Three ids, three jobs
| Id | One per | Use it for |
|---|---|---|
request_id | HTTP attempt | Tracing only. Never for de-duplication. |
transaction_id | Money movement | De-duplication. Unique for ever. |
round_id | Round | Grouping one debit with its credit or rollback. |
#One round, one debit, one credit
- A round is exactly one debit and then one credit.
- A feature purchase is still one debit, for the play amount times the mode's cost multiplier.
- A losing round sends a credit of
0withround_closed: true, so you always see the round end. - A player can have only one open round in a session.
sequenceDiagram
participant R as Reelbit
participant W as Your wallet
R->>W: debit tx_d1, round r1, amount 100
W-->>R: 200 balance 49900
Note over R: Result decided and recorded
R->>W: credit tx_c1, round r1, amount 0, round_closed true
W-->>R: 200 balance 49900
#Idempotency
The same transaction_id can reach you more than once: a network retry, or a credit retried after a timeout.
- Same
transaction_id, same details: return the original result and the current balance. Move no money. - Same
transaction_id, different details: answer409 DUPLICATE_TRANSACTION_MISMATCH. Reelbit raises an alert.
sequenceDiagram
participant R as Reelbit
participant W as Your wallet
R->>W: credit tx_c1, amount 250
W--xR: answer lost
R->>W: credit tx_c1, amount 250 (same transaction_id)
Note over W: Already applied: no money moves
W-->>R: 200 balance 50150
#Retries and timeouts
Answer every call within 1 second in normal running. Reelbit waits at most 5 seconds.
A debit is never retried. If a debit gets no answer within 5 seconds, a 5xx, or an answer Reelbit cannot read, Reelbit cannot know whether money moved. It voids the round, sends a rollback, and tells the player the round did not go ahead.
sequenceDiagram
participant R as Reelbit
participant W as Your wallet
R->>W: debit tx_d1, amount 100
Note over R: No answer within 5 seconds
R->>W: rollback tx_r1, original_transaction_id tx_d1
W-->>R: 200 balance 50000
Note over R: Round voided. No result was decided.
Credits and rollbacks are retried with the same transaction_id, waiting 1 second, then doubling up to 60 seconds between attempts, for 24 hours. Accept them even after the player's session has expired. After 24 hours the transaction is marked failed in the transaction feed, flagged for manual settlement, and Reelbit is alerted.
sequenceDiagram
participant R as Reelbit
participant W as Your wallet
R->>W: credit tx_c1, amount 250
W-->>R: 503
Note over R: wait 1 s
R->>W: credit tx_c1, amount 250
W--xR: timeout
Note over R: wait 2 s, then 4 s ... up to 60 s, for 24 hours
R->>W: credit tx_c1, amount 250
W-->>R: 200 balance 50150
A clean refusal of a debit is not retried and needs no rollback: INSUFFICIENT_FUNDS, PLAYER_BLOCKED, PLAYER_NOT_FOUND, SESSION_EXPIRED, CURRENCY_NOT_SUPPORTED and INVALID_AMOUNT all mean no money moved.
#Rollbacks
A rollback names the debit to undo in original_transaction_id.
- If you applied that debit, return the money and answer with the new balance.
- If you never saw that debit, answer success and remember the
original_transaction_id. If the late debit then arrives, refuse it with409 ROUND_ROLLED_BACK. This is the case most integrations get wrong. - A credit for a round whose debit was rolled back is refused with
409 ROUND_ROLLED_BACK.
sequenceDiagram
participant R as Reelbit
participant W as Your wallet
R->>W: debit tx_d1 (delayed in the network)
Note over R: No answer within 5 seconds
R->>W: rollback tx_r1, original_transaction_id tx_d1
Note over W: Never saw tx_d1. Remember it as rolled back.
W-->>R: 200 balance 50000
R-->>W: debit tx_d1 finally arrives
W-->>R: 409 ROUND_ROLLED_BACK (no money moves)
#Crashes and abandoned rounds
Reelbit decides and records a result only after your debit succeeds, and before it sends the credit. Pending credits and rollbacks are stored in Reelbit's database and sent by a background worker, so a restart never loses or repeats one. When to expect the credit:
- A losing round's credit of
0is sent straight after the result is decided. - A winning round's credit is sent when the game has finished showing the win, so the balance in your page changes when the player sees the win.
- If the player closes the game before that, Reelbit sends the credit itself 30 minutes after the result was decided. If they come back within the session, the game shows the result first.
#Check your wallet
The sandbox conformance runner runs every case on this page against your wallet and reports what passed.
Docs