InvarPay AI
Invariant-first financial operations platform: safe payment recovery, explainable fraud scoring, ledger reconciliation and an MCP checkout agent
Overview
InvarPay AI is an open-source, multi-tenant platform for payment operations. Each module is built around invariants that code enforces, so an AI can investigate and explain but never move money on its own.
Problem
Payment teams lose money on the edge cases: duplicate webhooks, retries that charge twice, a payment marked failed that actually succeeded, unreconciled settlements and agents that act on untrusted data.
Solution
Seven modules: InvarGuard (payment lifecycle, HMAC webhook ingestion, deduplication, safe retries where unknown is never treated as failed), InvarInvestigator (evidence-grounded AI incident triage), PaymentGraph AI (explainable fraud scoring), PayDev AST (payment code linter with auto-fix patches), MerchantOS (double-entry ledger and UTR matching), ShopAgent MCP (checkout behind a buyer confirmation gate) and a SHA-256 Merkle audit chain.
Architecture
- 1FastAPI modular monolith with async background workers
- 2Next.js 14 console, Typer CLI, MCP server and typed Python and TypeScript SDKs
- 3Deny-by-default agent policy engine with scoped tools
- 4Razorpay adapter in test mode only
Technical Challenges
- Keeping the AI useful for triage while code, not the model, decides anything that touches money.
- Exact minor-unit accounting so the ledger never drifts.
Results
- 170 passing tests.
- Independent project, not affiliated with Razorpay; runs in test mode only.