Reliability & Recovery
Razorpay sends financial events asynchronously. What happens if a webhook arrives twice, arrives out of order, or Mandate crashes halfway through a payment? This page demonstrates how Mandate prevents double-spending and makes financial state converge safely despite those failures.
How Mandate Handles Asynchronous Failures (End-to-End Reliability Flow)
Every financial action follows a strict 7-stage pipeline. If a network packet drops, a worker crashes, or Razorpay sends duplicate webhooks, the pipeline isolates the fault and converges safely without leaking merchant budget.
Financial Operation State Machine Lifecycle
CRITICAL TWO-PHASE COMMIT: Spend is reserved in PostgreSQL before invoking external Razorpay REST API. If the API crashes or network drops, this reservation guarantees another agent cannot double-spend the budget.
Failure Testing Lab (Live Fault Injection)
Test Mandate's failure handling in real time. Click any of the 4 test scenarios to inject live fault conditions into the running control plane and inspect the before/after state transition, gateway effect, and budget delta.
1. Duplicate Webhook Replay
Simulates Razorpay sending the exact same payment.captured webhook twice due to network retry.
2. Out-of-Order Webhook Event
Simulates webhook arriving before the synchronous client API call completes.
3. Ambiguous Gateway Timeout
Simulates network dropping right as Razorpay is processing order creation.
4. Process Crash & Orphan Sweep
Simulates worker crashing after funds are reserved but before order creation completes.
Mandate Ledger ↔ Razorpay Test Mode Reconciliation
Continuous background worker cross-checks internal PostgreSQL state against Razorpay Test Mode APIs• Orphan Reservation Sweep: Identifies operations stuck in RESERVED state for longer than 10 seconds (e.g. from container crashes) and releases uncommitted funds back to the mandate budget.
• Status Cross-Check: Ensures every order marked SUCCEEDED in Mandate corresponds to an authorized or captured payment in Razorpay Test Mode.