v1.0 · Razorpay and Paytm live

One API for every Indian payment gateway.Switch gateways without rewriting your checkout.

checkoutOs is a redirect-based, SDK-less payment orchestration API. Create a payment, send the user to a hosted checkout, and receive a verified webhook back — with idempotency, refunds and observable state built in.

2
Gateways implemented
24 h
Idempotency retention
Webhook
Only path to SUCCESS
chk_
One stable payment ID

POST /payments

razorpay · INR

201 Created

paymentId
chk_a1b2…e5f6
status
PENDING
amount
50000
redirect the user

Webhook · payment.captured

Signature verified→ SUCCESS

Redis is updated before the normalized event is relayed. A relay failure is logged, not turned into a failed webhook.

The problem

Every gateway is a different integration.

Razorpay, Paytm, PayU and Cashfree ship different SDKs, status strings and retry semantics. Teams that integrate one get locked in; teams that integrate all of them maintain four payment flows.

  • Problem

    Four SDKs, four state machines

    A status that means “captured” on one gateway means something else on the next. One provider change ripples through your checkout, reconciliation and refund code.

  • Cost

    Retries create real money

    A timeout does not mean the request failed. Without idempotency, a retried POST /payments can create a second order and a second charge.

  • Solution

    One stable contract

    checkoutOs normalizes creation, polling, refunds and webhooks behind one HTTP API. Switching gateways is an environment variable, not a rewrite.

The one principle

“A gateway response can reserve an order. Only a verified webhook can report that money moved.”

Polling can move a payment through intermediate states, but it can never setSUCCESS. That single invariant keeps the state machine honest across every gateway.

  • Create never marks a payment paid

    POST /payments returns PENDING and a paymentUrl. The gateway hosts the checkout, then reports the outcome by webhook.

  • Verify before applying

    Razorpay signs the raw bytes with HMAC-SHA256; Paytm posts a checksum-signed form body. Verification happens inside the plugin, before any state changes.

  • Your IDs stay stable

    API responses use chk_ and ref_ identifiers. A gateway-native order or payment ID never becomes your primary key.

How it works

Six steps from order to verified settlement.

Your server creates the payment once. Everything after that is the user on the gateway page and a webhook deciding the final state.

  1. Create payment

    POST /payments

  2. Redirect

    gateway-hosted checkout

  3. User pays

    on the gateway page

  4. Webhook in

    signature verified

  5. State updated

    Redis first

  6. Relay out

    normalized event

Webhook is authoritativecreate → PENDING · poll never → SUCCESS

Verified, then applied

The raw body is checked before anything changes. Invalid transitions are ignored with a warning instead of corrupting a terminal state.

Relay is fire-and-forget

Your endpoint gets the normalized event with a 5-second timeout. A relay failure is a warning, never a failed gateway webhook.

Redis is always updated before the relay is attempted, so a downstream outage can never hide money that has already moved.

Capabilities

The payment plumbing you would otherwise rebuild.

Each of these is part of the V1 contract, not a wrapper around a single gateway.

  • Unified payment API

    Razorpay and Paytm behind one contract. Switching is an environment variable.

  • Idempotent creation

    An Idempotency-Key replays the original response instead of charging twice.

  • orderId deduplication

    A merchant order reference is reserved before the gateway is called.

  • Verified webhooks

    HMAC-SHA256 for Razorpay, checksum verification for Paytm. Bytes are never re-parsed first.

  • Normalized relay

    One event shape is forwarded to your endpoint, keyed by the chk_ payment ID.

  • Full and partial refunds

    Partial refunds stack safely, and the payment moves to REFUNDED at the end.

  • Staleness-aware polling

    Non-terminal payments are re-polled after 10 seconds; terminal state is served from Redis.

  • Observable by default

    Prometheus metrics, structured logs and opt-in OTLP traces on every request.

One API, many gateways

A single contract over Indian payment gateways.

Amounts in paise, IDs prefixed chk_, and gateway-native IDs never used as your primary key. Switching from Razorpay to Paytm is one environment variable — no code change, and payment IDs stay stable.

Request

curl -X POST https://api.checkoutos.in/payments \  -H 'Content-Type: application/json' \  -H 'Idempotency-Key: 3f7d2a1e-9c4b-4f6a-8d2e-1b5c7a9e3f01' \  -d '{    "amount": 125000,    "currency": "INR",    "orderId": "order_abc123"  }'

201 Created

{  "success": true,  "data": {    "paymentId": "chk_a1b2c3d4e5f6a7b8",    "paymentUrl": "https://api.checkoutos.in/checkout/chk_a1b2c3d4e5f6a7b8",    "status": "PENDING",    "amount": 125000,    "currency": "INR",    "gateway": "razorpay",    "orderId": "order_abc123",    "createdAt": "2026-10-18T09:12:44.000Z"  }}

Gateway support

Two gateways live today. One plugin contract.

Razorpay and Paytm are implemented and registered. PayU and Cashfree are explicit startup stubs rather than half-working integrations.

  • Razorpay

    Live

    The reference plugin. Order at creation, payment ID backfilled by payment.captured.

    Checkout
    HTML page with the Razorpay JS SDK
    Webhooks
    HMAC-SHA256 over the raw body
  • Paytm

    Live

    customerPhone is required. Refund status cannot be polled.

    Checkout
    302 redirect to the hosted payment page
    Webhooks
    Form-encoded body with CHECKSUMHASH
  • PayU

    Stub

    Name and credential keys exist; registration throws at startup.

    Checkout
    Not implemented
    Webhooks
    Not implemented
  • Cashfree

    Stub

    Name and credential keys exist; registration throws at startup.

    Checkout
    Not implemented
    Webhooks
    Not implemented

Every gateway is a plugin behind getActiveGateway(). The service layer never imports a gateway folder, so adding one is a registry entry plus a plugin file — never a change to the payment flow.

Architecture

Your app, checkoutOs, and the gateway.

Controllers stay HTTP-only, services own business logic, and the store layer is the only thing permitted to touch Redis. Adding a gateway is a registry entry plus a plugin file.

Your application

Checkout UI

redirects to paymentUrl

Server

creates payment, signs nothing

Webhook endpoint

receives normalized events

checkoutOs · Node.js + Express

Controllers

HTTP only

Services

orchestration

Gateway registry

one plugin contract

Store

the only Redis caller

Redis

payments · refunds · idempotency records · gateway reverse lookups

Payment gateways

Razorpay

implemented

Paytm

implemented

PayU · Cashfree

registry stubs

The create call only reserves an order. SUCCESS is applied exclusively by a verified webhook, so no gateway can report a settlement it did not make.

Technology

Boring infrastructure on purpose.

A small Node.js service with strict TypeScript, Redis-backed state, and observability wired in from the first request.

Node.js 20
Matches the production container image
TypeScript 5.9
Strict mode, exactOptionalPropertyTypes, no any
Express 5
HTTP controllers, load-sensitive webhook body parsing
Redis + ioredis
Payment, refund and idempotency state; reverse lookups
Zod
Environment validation that fails startup, not the first request
Winston
Structured JSON logs on stdout
OpenTelemetry
Prometheus metrics on :9464, opt-in OTLP traces
MSW + Vitest
Deterministic mock gateways and unit/integration tests
Docker + Cloud Run
Non-root container, health check at /health

Roadmap and future scope

What V1 does not do yet.

  1. V1.1

    • API-key / JWT authentication
    • Refund idempotency
    • Webhook retry with a dead-letter queue
  2. V1.2

    • Automatic gateway failover
    • Multi-merchant namespacing
    • Merchant dashboard and SDKs
  3. Future scope · not in V1

    • Agentic AI payments: signed spending mandates and an authorization guard
    • MCP server so an AI agent can create and track payments
    • Delegated-debit rails such as UPI Reserve Pay, behind the same plugin contract

Stop rewriting payment code for every gateway.

Start with the quickstart to run checkoutOs against a mock gateway in a few minutes, then read the payment lifecycle to see the invariants every gateway plugin must preserve.