Back to Projects
HaltLine: AI Revenue Recovery Decision Agent

HaltLine: AI Revenue Recovery Decision Agent

HaltLine is a decision agent built for Razorpay merchants that recovers revenue from payment failures likely to succeed on retry. The core idea is that the AI proposes a recovery action, but a separate deterministic policy engine has final authority over whether it actually runs. Built for the Razorpay AI Buildathon 2026, it processes real payment.failed webhooks end to end: verifying, classifying, deciding, and if approved, creating a real Razorpay Payment Link.

Node.jsExpress 5Firebase Admin (Firestore)Anthropic SDKRazorpay SDKReact 19Vite

Problem

A large share of payment failures are transient: a soft decline from the gateway, a timeout, a bank issue that clears in minutes. That revenue is usually recoverable, but only if someone follows up quickly and safely. Most merchants either skip the follow-up entirely, or automate it with no guardrails, which risks contacting a customer too often or retrying a payment that was actually fraudulent.

Solution

Every payment.failed webhook is verified with HMAC-SHA256 and deduplicated through a Firestore transaction, so a retried webhook delivery is never processed twice. The failure reason is classified as retriable, non-retriable, or uncertain, then Claude proposes a recovery action with a confidence score. That proposal goes through six deterministic rules in a fixed order: fraud flags, maximum attempt limits, whether an active recovery link already exists, a 24-hour contact frequency cap, a 7-day recovery window, and the final classification decision. Only a case that clears all six gets a real Razorpay Payment Link created. Anything the policy engine isn't confident about gets escalated to a human review endpoint instead of being auto-decided either way. Every step, AI proposal, policy decision, and human action, is written to an append-only audit trail.

Features

  • •A policy engine that can override the AI's own recommendation: one documented case has Claude proposing recovery at 82 percent confidence, and the policy engine blocking it anyway for breaching the contact frequency cap
  • •HMAC-SHA256 signature verification on every webhook, using a timing-safe comparison so the check itself isn't a timing side channel
  • •Firestore-transaction deduplication on incoming webhooks, so a duplicate delivery from Razorpay can't trigger a second recovery attempt
  • •Six-rule deterministic policy layer evaluated in strict order before any action is allowed to execute, independent of whatever the AI proposed
  • •AI recovery proposals are schema-validated with Zod before they reach the policy layer, so a malformed or off-spec model response can't slip through into a real decision
  • •A human-in-the-loop escalation path for uncertain cases, with a dedicated resolve-escalation endpoint rather than a forced auto-approve or auto-reject
  • •An append-only audit trail that tags every entry by actor (AI, Policy, or Human), so any decision can be traced back to what made it and why
  • •Vitest test suite covering the policy engine's six rules independently, so a change to one rule's logic can't silently break another's precedence
  • •Real Razorpay test-mode Payment Links created only on an approved decision, never speculatively

Project Gallery

HaltLine: AI Revenue Recovery Decision Agent Screenshot 1

Revenue recovery dashboard

HaltLine: AI Revenue Recovery Decision Agent Screenshot 2

Auto-approved case detail

HaltLine: AI Revenue Recovery Decision Agent Screenshot 3

Audit trail: approved case

HaltLine: AI Revenue Recovery Decision Agent Screenshot 4

Escalated case, human approved

HaltLine: AI Revenue Recovery Decision Agent Screenshot 5

Audit trail: escalated case

HaltLine: AI Revenue Recovery Decision Agent Screenshot 6

Full audit trail log