KNOWLEDGE WALLET & TRANSACTIONS
Rollbacks, Refunds and Interrupted Game Rounds
A game can freeze after a wallet bet has committed, but that does not automatically authorize a refund. Learn how to distinguish bet reversals, win corrections and round cancellations, preserve original postings and handle delayed responses without crediting money twice.
This is a reference integration model, not a specification for CASINO-AGG or any particular provider. Actual request formats, party responsibilities and settlement rules depend on the agreed API contract.
A rollback, a refund and a cancelled round are different instructions
A player places a bet, but the game freezes before the result appears. Should the wallet return the stake? Not automatically. The debit might never have committed; it might have committed while the game result was delayed; or the provider might already have settled the bet and lost its response. A browser interruption describes a technical symptom, not a financial instruction. Only an authenticated, contract-defined action and the authoritative transaction history can establish whether money should move.
Rollback is a reversal of a previously posted monetary movement. A stake refund is normally a credit that returns some or all of a debit. A win reversal is usually a debit that removes an earlier payout. Cancelling an entire round can involve several such movements. A partial refund might coexist with winnings that remain valid. Treating every cancellation as a full credit of the original stake produces accounting errors and, in some cases, an unauthorized gain.
| Instruction | Possible wallet effect | Important distinction |
|---|---|---|
| Reverse a recorded bet | Credit the previously debited amount, if permitted | A posted wager must be identified first |
| Reverse a recorded win | Debit the previously credited payout | It is not another stake refund |
| Partial stake refund | Credit only the authorized remaining amount | Existing cash-out or payout can remain valid |
| Cancel an entire round | Reverse the exact included postings | One round may contain multiple debits and credits |
| Browser or server interruption | No automatic money movement | Resolve the ledger and provider state first |
The provider operations below are documented examples, not a statement that CASINO-AGG implements or partners with those providers. The financial meaning, authentication and exact response must be taken from the approved integration contract.
Map cancellation types before changing any balance
VeliGames documents three different cancellation actions. CANCEL_TRANSACTION reverses one referenced bet or win; CANCEL_ROUND reverses the transactions of a round; CANCEL_BET credits an explicit adjustment refund while already paid wins remain untouched. The names are meaningful within that provider's protocol. Tom Horn Gaming instead documents a RollbackTransaction method that points to a specified transaction reference. Aviatrix documents its own cancellation path through a win operation with a CancelBet meaning after unsuccessful delivery attempts. They are not interchangeable endpoints.
| Public contract example | Object being corrected | Do not assume |
|---|---|---|
| VeliGames CANCEL_TRANSACTION | Exactly one referenced bet or win posting | The target must always be a stake |
| VeliGames CANCEL_BET | Only adjustmentRefund amount | An earlier win is also cancelled |
| VeliGames CANCEL_ROUND | The provider-defined round's monetary events | Every brand or game uses this same scope |
| Tom Horn RollbackTransaction | One transaction identified by reference | A rollback method has a universal HTTP result |
| Aviatrix CancelBet operation | A provider-specific bet cancellation flow | Its message schema matches VeliGames or Tom Horn |
An adapter must translate each operation into an explicit internal intent: reverse this ledger debit, reverse this ledger credit, refund this amount or reverse this reviewed set of round postings. Validate operation type, original transaction identity, round and player ownership, amount, currency and correction reason. Keep the provider's distinct response and retry contract. Do not rename every provider method to a generic cancel and discard the fields needed for reconciliation.
An instruction can also be informational rather than monetary. A zero-value result or an updated round status should not create an invented refund. Document which provider signals are authoritative, which are hints and which require an explicit follow-up query. The implementation must reject a request that tries to reverse another operator's or another player's transaction even if the referenced ID exists.
Locate the original ledger posting before compensating it
A valid rollback request should identify a financial posting, not merely a browser session or game title. Find the original by its contract-defined provider reference and authenticated namespace, then verify whether the operator actually committed a debit or credit. The same round ID may contain several players or several transactions. Reversing the first matching record by round ID is therefore unsafe. Preserve the complete mapping of provider transaction, operator ledger posting, account, currency, amount, round and authorization scope.
Verify signature or credential and bind the request to the correct provider, brand and wallet account.
Locate the exact original financial transaction using its documented identity and scope.
Confirm reversal type, permitted amount, currency, ownership and any previous compensations.
Commit a separate correcting ledger entry and its idempotency identity atomically.
Return the provider-defined result and retain both original and correction references for audit.
If the original is missing, distinguish a transaction never accepted, a posting not yet visible, and one already archived. Do not credit money simply because the provider says cancel. Record the incoming correction with its own identity, perform a documented lookup or bounded hold, and follow the contract's not-found or retry policy. Conversely, do not assume a missing hot-cache record proves no original ledger posting exists.
A rollback should never erase or overwrite the historical debit. The ledger needs both the original movement and the linked correction so audits can show why the final balance changed. The provider and operator may have different transaction IDs: preserve the mapping instead of replacing one with the other.
Return a cancelled stake once and only once
For a simple example, a player starts with 100 units and a posted stake of 10 leaves 90. If the provider later authorizes a full reversal of that same bet, one compensating credit of 10 restores 100. A retry of the reversal must not raise the account to 110. The rollback has its own stable financial identity, references the original bet and is subject to a unique database rule. The first accepted correction determines the durable result for matching retries.
| Event | Balance movement | Balance | Ledger interpretation |
|---|---|---|---|
| Opening position | 0 | 100 | Not a bet posting |
| Bet B-10 committed | -10 | 90 | One authorized stake debit |
| Rollback R-10 of B-10 | +10 | 100 | Separate corrective credit |
| Retry of R-10 | 0 | 100 | Original correction outcome is reused |
| New unrelated bet B-11 | Contract-defined | Depends on funds | Not suppressed by the old rollback |
A reversal ID and an original transaction ID serve different purposes. Reusing the original debit ID as if the refund were that same financial movement can prevent legitimate corrections or create identity collisions. Some provider contracts encode cancellation identity differently, so use a normalized internal correction key with the contract-defined scope, but always preserve the original reference. The original debit, compensating credit and final result must be independently inspectable.
Use one database transaction for checking and reserving the correction, confirming that no equivalent correction already exists, and committing the credit. If two workers process the same cancellation concurrently, both must not release funds. MySQL's InnoDB isolation and locking documentation covers relevant database behavior; the exact design depends on the wallet's account and ledger model.
Partial refunds must leave valid cash-outs untouched
Not every voided wager receives its entire stake back. A sportsbook may have paid a partial cash-out before the remaining exposure was cancelled. VeliGames documents a case where a 2.00 EUR stake is followed by a 1.58 EUR cash-out and then a 0.38 EUR adjustment refund. The player receives the cash-out and the remaining refundable portion; the earlier payout is not reversed. The small residual difference reflects the provider example's retained fee, not an accounting error that the wallet should silently correct.
| Documented example | Balance effect | Running net from initial balance |
|---|---|---|
| Accepted stake | -2.00 EUR | -2.00 EUR |
| Partial cash-out already credited | +1.58 EUR | -0.42 EUR |
| Authorized remaining refund | +0.38 EUR | -0.04 EUR |
| Incorrect additional win reversal | Do not post -1.58 EUR | Would create an artificial loss |
The values and fee treatment belong to the cited provider's example; another provider might have no fee or a different representation of outstanding liability. The general design lesson is to distinguish refunded principal, settled cash-out, previously paid wins and fees. A CANCEL_BET style refund must not be rewritten as 'reverse all transactions in the round' unless that is exactly the supported contract meaning.
Record the precise authorized refund amount and currency as immutable attributes of the correction. Check previous partial refunds so that multiple corrections do not accidentally exceed the reversible balance. Different correction references may represent successive authorized adjustments, but repeated delivery of the same correction reference is one event. Test both full and partial cash-outs, late voids and contradictory provider payloads.
Cancel a round by examining all of its financial events
A round may contain a bet, additional wagers, several wins and earlier partial corrections. Cancelling the round means finding the set of transactions included by the provider's contract, not assuming one stake and one payout. A reversal of each eligible original posting must have an auditable identity. The total round adjustment is the sum of those distinct compensations, not a fresh payment of the round's net result on top of them.
Validate the provider, tenant, player, round ID and contract-defined financial membership.
Collect authoritative bet, win and correction IDs and identify which movements remain reversible.
Apply one appropriate sign and amount to each targeted debit or credit without reusing another player's global round.
Use transaction boundaries or a recoverable compensation workflow for the planned changes.
Confirm the sum of originals and corrections matches the provider's intended final financial result.
Some games share one round identifier across players, so a raw round ID is not sufficient to select account postings. In addition, a previous partial refund changes how much remains reversible. For a large or distributed set of postings, one all-or-nothing local database transaction may be impractical; use durable per-item progress and a recoverable workflow, never a best-effort loop that loses which compensations committed.
VeliGames documents a CANCEL_ROUND that reverses all transactions of the round, including wins, while its CANCEL_BET has narrower semantics. That distinction is exactly why a generic 'cancel' button cannot be translated into a universal wallet balance change.
An interrupted game must be investigated before refunding
The game window closes, the device loses power or an iframe shows an error. These events are not sufficient evidence that a round was void. The provider may hold the authoritative game outcome, the bet may have been accepted, and a win may arrive after the browser session is gone. Returning funds automatically from a front-end error can create a duplicate credit if settlement subsequently completes. The wallet should preserve the authorized bet and ask the appropriate provider status or recovery interface what happened.
| Observed failure | Unsafe assumption | Resolution |
|---|---|---|
| Browser closes during spin | The stake must be refunded | Look up authoritative round or transaction outcome |
| Wallet response lost after bet debit | The bet never happened | Resolve original debit by its stable transaction ID |
| Provider rejects or voids a round | Any amount may be credited | Apply only the authorized correction with its reference |
| Win arrives after session expiry | Late payout is invalid | Authenticate and settle according to the provider's wallet contract |
| No result appears in a report yet | The round is definitively cancelled | Use bounded pending status and reconciliation escalation |
Aviatrix documents retrying certain wallet requests with increasing delays and invoking a specific bet-cancellation operation if all delivery attempts fail. VeliGames documents that wins and cancellations may still be processed after a session identifier expires. These contracts show why one cannot use browser uptime or session validity as the universal financial cutoff. Check the correct provider's settlement and cancellation rules before changing money.
An unresolved round should have a controlled status and investigation path, not endless silent retries. Support staff need the operator, player, original bet, game, round, timestamps, provider responses and available outcome evidence. Access to those records must be limited, with sensitive credentials redacted.
Treat round closure and final money settlement as separate facts
A round can appear finished to the player while a correction remains possible under the provider contract. VeliGames documents sports resettlement in which an earlier win is reversed and a new adjusted win arrives, sometimes after an earlier closed status. Conversely, its documentation cautions that a roundClosed flag in ordinary casino integrations may have different meanings. Closure is therefore not a universal ban on later authorized financial messages.
An implementation should keep separate evidence for presentation state, provider round status, transaction finality and reconciliation completion. Accept only documented late operations with the necessary authorization and references. A genuinely duplicate old rollback must still resolve to its original recorded outcome, even when a replacement settlement has since arrived. Never treat a newly received correction as valid solely because it has a fresh timestamp.
- Do not derive financial finality from an iframe close event or a generic UI round-complete message.
- Retain prior transaction and compensation IDs across relaunch, logout and provider adjustment windows.
- Distinguish a corrected win from a retransmission of the previous win using the provider's financial identities.
- Keep explicit permission and validation rules for reopening and resettling an earlier closed round.
- Report unresolved financial status separately from the player's visual game-session status.
Make compensation idempotent, authenticated and recoverable
The exact problem that causes a double bet debit can also cause a double refund. After a correction commits, its acknowledgment may be lost and the provider can retry. Use a stable correction identity with a database uniqueness rule and immutable comparison of original transaction, type, amount, currency and owner. The rollback ledger posting and recorded result should commit together. If the second request changes those fields under the same identity, treat it as a conflict and do not post a new credit or debit.
Authenticate every cancellation callback before looking up a target posting or returning transaction details. An attacker who learns a reference must not be able to request a refund for a different account. Signature replay controls and financial idempotency are complementary: OWASP's webhook guidance distinguishes delivery authenticity and event deduplication. Keep corrections separate from manual support adjustments, with approval and audit controls appropriate to the operating environment.
When financial action spans independent services, a failed step cannot always be undone by a single database rollback. AWS's saga guidance describes local transactions with compensating actions and explicit recovery. An operator wallet might use durable queues, a transactional outbox or a staged reconciliation workflow. Whatever the implementation, it must record which compensation steps committed before retrying them and must not promise instantaneous atomic rollback of the remote provider's database.
Do not overwrite the initial stake, create a free-floating credit or discard a failed compensation. Every monetary adjustment needs a documented authority, unique identity, original reference, resulting state and path to reconciliation.
Verify interrupted rounds and reversals against the ledger
A safe launch requires proof of the whole chain: provider instruction, original wallet posting, cancellation authorization, correction posting, resulting balance and provider acceptance. A test that merely shows 'refund succeeded' on screen is insufficient. Run concurrent and delayed retries, crash a worker around commit, and compare actual ledger entries with the provider's status or report. Keep an investigation owner for events that remain unmatched.
| Acceptance case | Expected evidence |
|---|---|
| Full reversal of one posted bet | One credit equal to authorized stake; original debit retained |
| Same rollback delivered twice | Only one corrective posting; documented duplicate response |
| Correction references a win | Correctly authorized debit of prior credit, not another stake refund |
| Partial refund after cash-out | Only residual amount refunded; earlier payout retained |
| Global round with two players | No correction of another player's balance |
| Cancel request before original becomes visible | No blind credit; documented hold, status query or refusal |
| Game iframe closes mid-round | No automatic refund without provider-confirmed financial outcome |
| Win or correction after session expiry | Authorized late event handled by the correct provider rule |
| Corrected settlement after round close | Original, reversal and new win all separately traceable |
| Provider and wallet totals disagree | Exception recorded with references, amount, status and investigation owner |
Track correction latency, duplicate and conflicting reference counts, missing originals, pending cancel operations, exhausted retries, negative-balance exceptions and unreconciled amounts. Preserve minimal, access-controlled evidence; OWASP logging guidance is useful for keeping secrets and unnecessary player details out of logs. Financial correctness is proven by matched postings and authorized compensations, not by the absence of visible browser errors.
Before production, require signed-off behavior for full, partial and win reversals; duplicate rollback retries; late and out-of-order messages; interrupted sessions; insufficient available funds; and a reproducible end-to-end reconciliation report.
KNOWLEDGE
Sources & further reading
This guide draws on primary technical references and official guidance. Regulatory applicability depends on jurisdiction and implementation.
- VeliGames — Seamless Wallet API and cancellation semantics
- Tom Horn Gaming — RollbackTransaction
- Aviatrix — Backend integration and wallet cancellation
- AWS Prescriptive Guidance — Saga pattern
- AWS Builders' Library — Making retries safe with idempotent APIs
- MySQL 8.4 — InnoDB Transaction Isolation Levels
- OWASP — Webhook Security Cheat Sheet
- IETF RFC 9110 — HTTP Semantics
- AWS Well-Architected — Control and limit retry calls
- OWASP — Logging Cheat Sheet