checkoutOs

Introduction

checkoutOs is a redirect-based, SDK-less payment orchestration API for Indian payment gateways, with idempotent creation, verified webhooks and refunds.

checkoutOs is a redirect-based, SDK-less HTTP API that wraps Indian payment gateways behind a single unified contract. Razorpay, Paytm, PayU and Cashfree all speak different status strings and ship different SDKs; checkoutOs exposes one stable surface and makes switching between the implemented gateways an environment-variable change.

V1.0 ships with Razorpay and Paytm implemented and registered. PayU and Cashfree exist as registry stubs only — setting either as ACTIVE_GATEWAY exits at startup rather than failing on the first payment.

The one principle

A verified webhook is the only source of truth

POST /payments returns PENDING and a paymentUrl. Polling can move a payment through intermediate states, but it can never set SUCCESS. Only a gateway webhook that passes signature verification advances a payment to a terminal captured state.

That invariant is what makes the state machine honest across every gateway. It also means the webhook endpoint is load-bearing, not a convenience: if your gateway dashboard is not pointed at checkoutOs, payments will be created and completed but nothing will ever reach SUCCESS.

What V1 includes

  • Payment creation via one API, returning a paymentUrl.
  • Idempotency-Key on payment creation, with 24-hour replay.
  • A second deduplication dimension on merchant orderId.
  • Status polling with a 10-second staleness window.
  • Full and partial refunds.
  • Verified webhook ingestion and a normalized relay.
  • Prometheus metrics, structured logs and opt-in OTLP traces.
  • A deterministic mock gateway for local development.

Where to start

What the API looks like

Create a payment
curl -X POST https://api.checkoutos.in/payments \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: 3f7d2a1e-9c4b-4f6a-8d2e-1b5c7a9e3f01' \
  -d '{ "amount": 50000, "currency": "INR", "orderId": "order_abc123" }'
201 Created
{
  "success": true,
  "data": {
    "paymentId": "chk_a1b2c3d4e5f6a7b8",
    "paymentUrl": "https://api.checkoutos.in/checkout/chk_a1b2c3d4e5f6a7b8",
    "status": "PENDING",
    "amount": 50000,
    "currency": "INR",
    "gateway": "razorpay",
    "orderId": "order_abc123",
    "createdAt": "2026-10-18T09:12:44.000Z"
  }
}

Redirect the user to paymentUrl. The gateway hosts the checkout page, fires a webhook back to checkoutOs when the payment completes, and checkoutOs relays a normalized event to your own endpoint keyed by the chk_ identifier.

Endpoint surface

MethodPathDescription
POST/paymentsCreate a payment, get a paymentUrl
GET/payments/:chkIdCheck payment status
POST/payments/:chkId/refundRefund a payment, fully or partially
GET/refunds/:refIdCheck refund status
POST/webhooks/:gatewayReceive a gateway webhook
GET/checkout/:chkIdServe the checkout page (HTML or redirect)
GET/healthRedis and active-gateway health

Architectural contracts

These are load-bearing. A change that violates one is wrong even if it works.

LayerRule
ControllersHTTP only. No business logic, no Redis, no gateway-specific code.
ServicesOwn business logic. Orchestrate store and gateway via getActiveGateway(). Never import a gateway folder directly.
StoreThe only layer permitted to touch Redis or a database.
GatewayImplement GatewayPlugin and GatewayMapper. Never leak gateway-specific models upward.
UtilsPure functions, no side effects.
TelemetryA peer layer of Store; business code emits through the OTel API and never names an exporter.

Adding a gateway must never change the service layer — a registry entry plus a plugin file is the whole job. If a gateway seems to require a service change, the abstraction is being modelled wrong; fix the plugin, not the service.

See Adding a gateway for the full checklist.

Future scope

Agentic AI payments — signed spending mandates, an authorization guard and an MCP payment tool — are future scope and not functional in V1. See the roadmap for the boundary between what ships today and what is planned.

On this page