ReelbitDocs

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.

CallWhat you doOther providers call it
POST /balanceReturn the player's balance.balance
POST /debitTake the play amount.bet
POST /creditPay the win (may be 0) and close the round.win
POST /rollbackUndo 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

IdOne perUse it for
request_idHTTP attemptTracing only. Never for de-duplication.
transaction_idMoney movementDe-duplication. Unique for ever.
round_idRoundGrouping one debit with its credit or rollback.

#One round, one debit, one credit

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.

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.

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:

#Check your wallet

The sandbox conformance runner runs every case on this page against your wallet and reports what passed.