← Daily insights

fa chai api: Handle Rollbacks That Arrive Before Bets

December 2, 2026

Integrating fa chai api requires more than checking whether a bet debits the wallet and a win credits it. One important failure case is a rollback reaching your wallet before the bet it references. If your handler treats every rollback as an immediate refund, it can create money that was never deducted. If it simply discards unknown references, a delayed bet may debit the player after the cancellation was acknowledged.

This guide explains how to handle that ordering problem without inventing balances or losing cancellation intent. It describes an operator-side design pattern, not a claim about FA CHAI's specific callback behavior. Confirm the available operations, reference fields, and acknowledgement rules in the integration contract before implementing it.

Why a rollback can reach your wallet first

Distributed systems do not necessarily preserve the order in which business actions happened. A bet request might stall at a gateway while a cancellation travels over another connection. A worker can retry an older request after a newer request has already completed.

Your application can also create the reversal internally: two callbacks arrive in the expected order, but different workers acquire database locks in the opposite order.

Consider this illustrative sequence:

  • The player's balance starts at 100 units.
  • A 10-unit bet is sent but does not reach the wallet handler promptly.
  • A rollback referencing that bet arrives first.
  • The original bet arrives later.

Crediting 10 units on the rollback would temporarily produce 110 units without a corresponding debit. Ignoring the rollback and later accepting the bet would leave 90 units despite the cancellation.

The requirement is simple: preserve the cancellation request without inventing a refund, then resolve both events under the documented transaction rules.

Define the fa chai api rollback contract first

Before choosing database states, ask your integration contact how the exposed wallet interface represents reversals. When connecting through an aggregator, use the aggregator-facing specification rather than assuming direct-provider behavior applies unchanged.

Questions that change the implementation

Get written answers to these points:

  • Does a rollback reference a specific bet transaction or an entire round?
  • Can a rollback arrive before the original transaction?
  • Are reversals always full, or can they be partial?
  • Does the rollback have its own stable transaction identifier?
  • What response is required when the original transaction is unknown?
  • Can a reversal be withdrawn or superseded?
  • What retry and reconciliation windows apply?

Also confirm whether acknowledging an unknown-reference rollback means “received for processing” or “cancellation completed.” Those meanings are not interchangeable. Your system must not report final success merely because it saved a pending record, unless that behavior is explicitly supported.

The design below assumes transaction-level, full bet reversals. Partial reversals and round-wide cancellations require additional allocation rules.

Store cancellation intent separately from money movement

A rollback message is evidence of a requested action. It is not, by itself, evidence that the player is owed money.

Maintain durable records for both incoming events and the original transaction they reference. Useful fields include:

  • Operator or tenant identifier and integration identifier.
  • Original transaction reference and rollback event identifier.
  • Player account, currency, and amount where supplied.
  • Processing state, receipt time, and ledger entry references.
  • A payload fingerprint for detecting conflicting retries.
  • The response or response outcome required for consistent retries.

Treat these as conceptual fields, not official API parameter names. Use the identifier scope documented by your integration; do not assume a transaction reference is globally unique across every operator.

Use explicit states

A compact internal model might include `BET_POSTED`, `REVERSAL_PENDING`, `REVERSED`, and `REVIEW_REQUIRED`.

`REVERSAL_PENDING` means an authenticated cancellation request exists, but the wallet has not located a corresponding posted debit. It must not increase the available balance.

`REVERSED` means the cancellation has been resolved under the contract, with any required ledger entries committed. Keep those definitions precise so support staff can distinguish a received request from a completed financial action.

Process both events through one concurrency boundary

Persist the event, change transaction state, and write any ledger entries atomically where your architecture permits. A check followed by an unrelated balance update leaves room for two workers to make incompatible decisions.

Serialize work on the same scoped original transaction reference. Also enforce database uniqueness for event identities and reversal effects. A lock alone does not provide durable protection after a crash or retry.

When the rollback arrives first

Authenticate the request and validate its shape before recording actionable cancellation intent. Otherwise, an untrusted request could block a legitimate future bet.

If the original debit is absent:

  1. Create or update the pending reversal record atomically.
  2. Store the reference and available validation attributes.
  3. Leave the player's balance unchanged.
  4. Return the documented unknown-reference or pending response.
  5. Make the record available to reconciliation workers.

If the contract requires a retryable error rather than acknowledgement, return that response while retaining your internal record. Persistence does not authorize you to change the external protocol.

When the original bet arrives later

Under the same concurrency boundary, inspect pending cancellation intent before making funds unavailable. Validate that both messages refer to the same permitted operation and account. Compare amount and currency where the contract supplies them.

For a valid full cancellation, follow the agreed handling model. Some interfaces may permit resolving the bet as cancelled without a net wallet movement. Others may require an auditable debit and compensating reversal. If the latter is supported, commit the pair atomically so no intermediate debit becomes available to other wallet operations.

Do not manufacture a successful bet response to simplify bookkeeping. If the contract does not define this sequence, escalate it before production rather than inventing semantics.

When the debit already exists

Reverse the recorded debit, not an arbitrary amount supplied by the rollback. Validate the request against the original transaction and create exactly one compensating effect.

If a repeated event changes the account, amount, currency, or reference, treat it as a conflict rather than a harmless duplicate. Hold ambiguous processing for investigation without creating another credit.

Keep unresolved references visible

A pending reversal needs an operational lifecycle. Set review thresholds using documented delivery and retry behavior, then monitor pending-record age and volume.

Do not delete unresolved records simply because a local timer expired. A late bet could then appear new and bypass the cancellation. Retain cancellation evidence according to the contract, audit obligations, and data-retention policy.

Reconciliation should compare your ledger and event records with available integration transaction reports. Separate these cases:

  • A reversal remains pending because no original bet is visible.
  • A debit exists, but its expected reversal effect is missing.
  • Local cancellation state disagrees with the integration's final status.

Each case needs a different investigation. A generic “callback failed” alert hides that distinction. Keep access controlled and exclude credentials or launch tokens from diagnostic records.

Test ordering, retries, and process crashes

A successful same-order test is not enough. In a controlled test environment, exercise these sequences:

  • Rollback first, then the matching bet.
  • Matching bet first, then rollback.
  • Two rollback workers processing the same reference concurrently.
  • Bet and rollback workers racing before either commits.
  • Process failure after commit but before the response is delivered.
  • A repeated rollback with conflicting transaction attributes.
  • A bet arriving after the pending reversal's review threshold.

Assert the final balance, ledger entries, transaction state, and retry response. For the 100-unit example, a valid completed full cancellation should leave 100 units, with no duplicate refund and no externally visible intermediate balance change. Unresolved cases should remain clearly distinguishable from completed cancellations.

Plan the integration around evidence, not assumptions

GamingAPI offers 16,000+ games from 150+ studios through one API, with a seamless wallet, multi-currency support, and USDT deposits. Confirm current FA CHAI availability, permitted markets, and rollback behavior for your intended configuration through contact.

Commercial terms are $350 for one-time setup plus 10% of positive GGR; see pricing. Before launch, agree how reversals appear in transaction exports and billing reconciliation. Operators remain responsible for applicable licensing and market restrictions.

FAQ

Should an unknown rollback immediately credit the player?

No. Without a matching posted debit, there is no established refund amount. Preserve the request and follow the documented response rules.

Can pending reversals expire automatically?

They can trigger timed review, but deleting their protective state can allow a late bet to debit incorrectly. Agree retention and late-arrival handling first.

Is event deduplication sufficient?

No. Deduplication prevents repeated processing of one event. You also need atomic coordination between different events that affect the same original transaction.

Top Game Providers

150+ Studios. One integration.

Slots, live casino, crash and sports — all connected through one API. Browse our studios and explore their free-play demos.