Overview
The gateway registry, what each plugin must implement, and the current implementation status of every supported gateway.
The registry at src/gateways/gateway.registry.ts is the single source of truth for supported
gateway names, their required environment keys, and their base URLs. Adding a gateway is a
registry entry plus a plugin file — no service or controller changes.
Status
| Gateway | Plugin | Registered | Notes |
|---|---|---|---|
| Razorpay | Implemented | Yes | Fully working; the reference implementation |
| Paytm | Implemented | Yes | Registered via createPaytmPlugin(); websiteName needs overriding for production |
| PayU | Empty file | No | The registry throws at registration |
| Cashfree | Empty file | No | The registry throws at registration |
PayU and Cashfree will not start
Their plugin files are empty, and the registry throws an explicit error for both rather than
registering undefined. Setting ACTIVE_GATEWAY=payu exits at startup — deliberately, so the
failure is a boot error and not a mystery at the first payment.
Selecting the active gateway
One environment variable:
ACTIVE_GATEWAY=razorpayA Zod superRefine in src/config/env.schema.ts makes that gateway's credentials required at
startup. Invalid config exits the process rather than starting a server that will fail on its
first request.
Switching is a config change for new payments: no code changes, and all chk_ payment IDs
stay stable. Existing payments continue to poll and refund through the gateway that created
them, so one deployment has one active gateway.
ACTIVE_GATEWAY=paytm
PAYTM_MERCHANT_ID=your_merchant_id
PAYTM_MERCHANT_KEY=your_merchant_key
PAYTM_WEBHOOK_SECRET=your_webhook_secret
PAYTM_WEBSITE_NAME=DEFAULTRequired environment keys
| Gateway | Keys | Default base URL |
|---|---|---|
razorpay | RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET, RAZORPAY_WEBHOOK_SECRET | https://api.razorpay.com/v1 |
paytm | PAYTM_MERCHANT_ID, PAYTM_MERCHANT_KEY | https://securegw.paytm.in |
payu | PAYU_MERCHANT_KEY, PAYU_MERCHANT_SALT, PAYU_WEBHOOK_SECRET | https://api.payu.in |
cashfree | CASHFREE_APP_ID, CASHFREE_SECRET_KEY, CASHFREE_WEBHOOK_SECRET | https://api.cashfree.com |
Each gateway also accepts a <GATEWAY>_BASE_URL override — set it to http://localhost:9090
to point at the mock server during development.
How services reach the gateway
Never by importing a gateway folder.
import { getActiveGateway } from '../gateways/gateway.registry';
const gateway = getActiveGateway();
const result = await gateway.createPayment({ /* … */ });registerGateways() runs once at startup, after config validation, and populates the plugin
map. getActiveGateway() throws GatewayUnavailableError if it was never called — a startup
contract violation that surfaces on the first request rather than returning undefined.
Two rules that keep the registry decoupled
The registry never imports config/index.ts (circular dependency risk) and never reads
process.env directly — it receives the validated env object as a parameter.
What a plugin must implement
Every gateway needs all seven operations:
The interface covers createPayment, getPaymentStatus, createRefund, getRefundStatus,
parseWebhookEvent, getCheckoutAction and healthCheck.
Plus webhook signature verification inside the plugin. See Adding a gateway.