Skip to content
HS®
All projects

(010) / 012

ReviveX

A payment-recovery agent on Razorpay's APIs: it reasons about why a payment failed, while compliance limits live in plain code the model cannot override.

Category
AI agent · Payments
Year
2026
Last pushed
Aug 2026
Primary language
TypeScript
01 SOFT02 FIRM03 FINALMAX 3 ATTEMPTSQUIET HOURS 21:00–08:00 IST
Conceptual diagram — the three-step escalation ladder: soft, firm, final.

(01) Overview

ReviveX is an autonomous payment-recovery agent built on Razorpay's APIs for recurring revenue. Instead of blindly retrying a failed payment, it looks at why the payment failed and runs a multi-attempt escalation strategy — governed by deterministic compliance rules and recorded in a full audit trail.

(02) Problem statement

Failed recurring payments are usually handled with a single retry script that knows nothing about the cause of the failure or the customer. Handing the problem to a language model fixes the first part and creates a new one: nobody wants a model deciding to message a customer at midnight, or for the fifth time.

(03) Technical approach

Split the decision in two. What to say and how is delegated to an LLM. Whether contact is allowed at all is enforced in plain TypeScript that the model cannot influence:

  • at most three attempts per case
  • no contact during quiet hours, 21:00–08:00 IST
  • at least 60 minutes between attempts

(04) System architecture

One failed paymentConceptual diagram · select a stage

Stage 01 — payment.failed

A Razorpay webhook arrives and its HMAC SHA-256 signature is verified.

(05) Implementation details

The escalation ladder has three rungs: a soft tone on the initial channel, a firm tone with the channel swapped between email and SMS, and a final notice before the case closes automatically. Gemini generates the customer copy and a plain-language explanation of its reasoning for each attempt; the call races a 5-second timeout and falls back to the rules engine if it loses.

Payment links are created with the official Razorpay Node SDK in test mode, and incoming payment.failed webhooks are verified with HMAC SHA-256 signatures. A local checkout page lets a simulated payment be completed so the dashboard's recovery figures update. Cases are persisted in a file-backed JSON store, with a /tmp fallback on serverless hosting.

(06) Main features

  1. 01Batch recovery engine for simulating and managing failed payments.
  2. 02Deterministic rules in TypeScript: at most three attempts, quiet hours 21:00–08:00 IST, a 60-minute gap.
  3. 03Three-tier escalation: soft, then firm on the alternate channel, then final.
  4. 04Gemini writes customer copy and plain-language reasoning, with a 5-second timeout and a rules-engine fallback.
  5. 05Expandable per-case audit trail of every attempt, channel, tone and outcome.
  6. 06Razorpay payment links and webhook verification with HMAC SHA-256 signatures.

(07) Technology stack

TypeScriptNext.js 14React 18Tailwind CSSGoogle Gemini SDKRazorpay Node SDKHMAC SHA-256 webhooks

(08) Engineering challenges

  • Keeping compliance out of the prompt. Rules that must always hold are code, not instructions.
  • A model that may not answer. The timeout race guarantees a decision even when the LLM is slow or unavailable.
  • Explainability. Every attempt records its timestamp, reasoning, channel, tone, action and outcome, so any case can be reconstructed afterwards.
  • Persistence on serverless. A file store does not survive across serverless instances; the project documents this and uses a temporary-directory fallback for the demo.

(09) Evaluation and results

The project runs in Razorpay test mode with simulated failures; no real payments are processed. The repository publishes no recovery-rate measurements, so none are claimed here.

Links