Phoenix Games
Guidelines

Bet Reconciliation

How to handle bet status reconciliation using cron jobs

Periodic Bet Status Reconciliation

Operators should implement a cron job that periodically scans for bets that remain in OPEN status and are more than 2 hours old, then reconcile their status using the fetch-bet API.

Why This Is Needed

Phoenix Games attempts to deliver webhook notifications up to 100 times with exponential backoff. However, in cases where operators don't receive these notifications due to:

  • Server downtime or issues
  • Network connectivity problems
  • Firewall or routing issues
  • Any other technical problems

The bet status may remain OPEN in the operator's system even though it has been settled on Phoenix Games' side.

Implementation Guidelines

Cron Job Schedule

Run the reconciliation process every 15-30 minutes to ensure timely updates.

Process Flow

  1. Query Local Database: Scan for bets with:

    • Status: OPEN
    • Age: More than 2 hours old
  2. Fetch Current Status: For each identified bet, call:

    GET https://operators.phoenixbet.io/api/v0.2/fetch-bet/{reference_id}
  3. Update Local Records: Based on the API response:

    • If status is CLOSED: Update local bet record with payout amount
    • If status is ROLLED_BACK: Mark bet as cancelled/refunded
    • If status is NOT_FOUND: Handle as per business rules (likely mark as error for investigation)

Best Practices

  • Logging: Log all reconciliation activities for audit purposes
  • Alerting: Set up alerts for bets that remain unresolved after reconciliation attempts
  • Idempotency: Ensure your reconciliation process can safely run multiple times without causing issues
  • Error Handling: Implement proper retry logic for failed API calls during reconciliation