Razorpay Payment Infrastructure

Bettrlabs’ end-to-end Razorpay payment backend, engineered so that a purchase is never incorrectly granted or lost.

ownership
Sole engineer, end to end
when
2026
org
Bettrlabs

The film, as text: Razorpay Payment Infrastructure. Bettrlabs’ end-to-end Razorpay payment backend, engineered so that a purchase is never incorrectly granted or lost. Verify: Every payment is verified with Razorpay before anything is granted. Webhooks: Webhook events move the transaction through its states. Idempotent settlement: A duplicate event is recognised by its key and settles nothing twice. Background reconciliation: Late or out-of-sync states are found and reconciled in the background. Failure-safe states: Failed and incomplete payments resolve safely: never granted wrongly, never lost. Sole engineer, end to end, Bettrlabs, 2026.

Problem.

The payment provider, the backend and the client can disagree. Webhooks arrive twice, arrive late, or report a state the database has not yet reached.

How it works

  • Payment integration: the complete Razorpay integration, built from the provider’s documentation, covering payment APIs and payment verification.
  • Webhook handling: provider events are processed through webhook endpoints, with duplicate and late deliveries accounted for.
  • Idempotent settlement: a payment settles once however many times it is reported, so a purchase is never granted twice.
  • Failure-safe states: duplicate, delayed, incomplete, failed and out-of-sync payments are each handled explicitly, with fallback and recovery logic.
  • Transaction state and database flows: transaction fields and payment state are tracked in the database, with database-level protections that keep that state consistent.
  • Background reconciliation: a reconciliation process corrects payment state when the provider, backend and client disagree.

Stack

Payments
  • Razorpay
  • Payment APIs
  • Payment verification
  • Webhook handling
Reliability
  • Idempotent settlement
  • Background reconciliation
  • Transaction-state management
  • Fallback and recovery logic
Backend
  • Python
  • FastAPI
  • PostgreSQL