Autonomous payment reconciliation agent
Limbo
An agent that finds payments stuck between the gateway and the merchant, and recovers them within hard guardrails.
Built for the Razorpay AI Buildathon, Track 03
- Python
- FastAPI
- PostgreSQL
- Next.js
- Claude API
- Razorpay
- Render
- Supabase
- Vercel
Problem
A customer pays and the gateway marks the payment successful. The success webhook to the merchant is lost, delayed, or fails mid-processing.
The merchant's system records a failed payment, cancels the order, and never issues a refund. The money sits in limbo until the customer escalates.
What I built
- A reconciliation agent that compares gateway payments with merchant orders, classifies every mismatch, diagnoses the cause, and takes one bounded action: complete the order, replay the webhook, refund, or escalate to a person.
- A public demo where a visitor sends one payment into limbo and watches it recover, streamed from the real audit log.
- Postgres advisory locks, so two scheduler instances overlapping during a deploy can never run the same reconciliation cycle.
- A demo_sessions table that ties each demo order to an unguessable token, plus per-IP rate limiting, so the public demo is safe to leave open.
Architecture
Reconciliation engine
Deterministic. Diffs gateway records against merchant orders and classifies each mismatch.
LLM diagnosis layer
Explains the likely root cause and triages ambiguous cases. It can never move money.
Policy engine
Hard guardrails decide what is allowed: idempotency, amount ceilings, capped retries, a circuit breaker.
Audit trail
Append-only. Every detection, decision and action is written once.
Outcome
- Deployed end to end on Render, Supabase and Vercel, with a live demo anyone can run.
- The key lesson: the real bugs only surfaced in live Razorpay test-mode integration runs, not in mocks.