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 installConfigure the environment
cp .env.example .envThe mock gateway ships with fixed test credentials, so these values work as-is:
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=mockWebhookSecret001BASE_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-alpineStart the mock gateway
npm run mock:gateway
# ✓ Listening on http://localhost:9090An 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"}' | jqamount 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 | jqReturns 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 downCompose 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
| Command | What it does |
|---|---|
npm run dev | Dev server with hot reload via tsx watch |
npm run build | Compile TypeScript to dist/ |
npm start | Run the compiled dist/server.js |
npm run typecheck | tsc --noEmit in strict mode |
npm run mock:gateway | MSW mock Razorpay + Paytm on :9090 |
npm run verify:telemetry | Boot the app with a stub gateway and assert the /metrics shape |
npm run test:unit | Vitest unit project — no Redis needed |
npm run test:integration | Vitest integration project — Redis required |
npm run test:coverage | Coverage report |
npm run test:watch | Watch 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.