checkoutOs

Quickstart

Run checkoutOs locally against a mock Razorpay server and create your first payment.

This gets you a running checkoutOs with Redis and a deterministic mock gateway — no real credentials, no real money.

Prerequisites

  • Node.js v20 or newer
  • Docker (for Redis)
  • npm

Clone and install

git clone https://github.com/checkoutOs/checkoutOs.git
cd checkoutOs
npm install

Configure the environment

cp .env.example .env

The mock gateway ships with fixed test credentials, so these values work as-is:

.env
NODE_ENV=development
PORT=3000
ACTIVE_GATEWAY=razorpay
REDIS_URL=redis://localhost:6379
WEBHOOK_RELAY_URL=http://localhost:4000/webhook
RAZORPAY_BASE_URL=http://localhost:9090
RAZORPAY_KEY_ID=rzp_test_mockKeyId00001
RAZORPAY_KEY_SECRET=mockSecret00001
RAZORPAY_WEBHOOK_SECRET=mockWebhookSecret001

BASE_URL is not validated

BASE_URL is read straight from process.env rather than through the Zod schema, and defaults to http://localhost:3000. Set it explicitly in production or the paymentUrl returned to your clients will point at localhost.

Start Redis

docker run -d --name checkoutos-redis -p 6379:6379 redis:7-alpine

Start the mock gateway

npm run mock:gateway
# ✓ Listening on http://localhost:9090

An MSW-based server that mocks Razorpay and Paytm. Order IDs derive from the receipt and created_at is fixed, so responses are stable across runs. It does validate Razorpay Basic Auth, so wrong credentials return 401.

Start the app

npm run dev
# [server] checkoutOs server started { port: 3000, gateway: 'razorpay' }

Create a payment

curl -s -X POST http://localhost:3000/payments \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"amount":50000,"currency":"INR","orderId":"order_001"}' | jq

amount is in paise — 50000 is ₹500.00. You get back a chk_ payment ID and a paymentUrl to redirect the user to.

Verify it is healthy

curl -s http://localhost:3000/health | jq

Returns 200 when Redis and the gateway are both reachable, 503 when degraded. This is the endpoint to use as a liveness probe — Cloud Run is configured against it in Deployment.

Running the whole stack with Docker Compose

cp .env.example .env
docker compose up          # app + Redis
docker compose up -d       # in the background
docker compose logs -f
docker compose down

Compose overrides REDIS_URL to redis://redis:6379 so the app reaches Redis by its service name — you do not need to change .env for this. Add --profile mock to run the mock gateway alongside the app and Redis.

Commands

CommandWhat it does
npm run devDev server with hot reload via tsx watch
npm run buildCompile TypeScript to dist/
npm startRun the compiled dist/server.js
npm run typechecktsc --noEmit in strict mode
npm run mock:gatewayMSW mock Razorpay + Paytm on :9090
npm run verify:telemetryBoot the app with a stub gateway and assert the /metrics shape
npm run test:unitVitest unit project — no Redis needed
npm run test:integrationVitest integration project — Redis required
npm run test:coverageCoverage report
npm run test:watchWatch mode, unit tests only

Never use `npm test`

It is a dead placeholder that exits 1. Run npm run test:unit && npm run test:integration instead. See Testing.

Next

On this page