Production-grade B2B Payment Gateway — built for high concurrency, financial integrity, and zero double-spending.
Repos: github.com/aldoprogrammer/PayPulse-API
Full gallery (card checkout, PulsePay wallet, payment success): docs/preview/PLATFORM_PREVIEW.md
Used by: travel marketplace VoyageX — hotel/package checkout redirects to a PayPulse Checkout page (TEST MODE, card / PulsePay wallet UI), then confirms payment via this API and webhooks VoyageX to mark the order PAID.
PayPulse API is a fintech backend that handles wallet balances, ledger transactions, checkout payments, and merchant webhooks at scale. Deposits are queued asynchronously via RabbitMQ so the HTTP layer stays fast under burst traffic, while balance writes are processed safely by a background consumer. Checkout payments are created as PENDING, then confirmed (demo pay) with HTTP webhook delivery to merchants such as VoyageX.
Sister repo: VoyageX · UI/flow doc: VoyageX-PayPulse-Integration-v1.0.md
VoyageX uses PayPulse for hotel/package checkout only (flights stay instant-PAID).
Hotel/package checkout → Create order (UNPAID)
→ VoyageX booking creates PayPulse payment (PENDING)
→ Redirect to VoyageX FE /paypulse/checkout?orderId=…&returnUrl=/dashboard
→ Customer pays in hosted UI (TEST MODE · card / PulsePay wallet — demo only)
→ VoyageX booking POST /api/v1/orders/:id/pay
→ PayPulse POST /api/v1/payments/:id/confirm
→ Order PAID in VoyageX (+ HTTP webhook payment.completed as backup)
The browser never calls PayPulse directly; VoyageX booking-service is the B2B client (X-API-Key).
- Start PayPulse:
npm run dev(API 4100). - Bootstrap merchant:
npm run bootstrap:voyagex→ copyapiKey. - In VoyageX
.env(booking-service):
PAYPULSE_ENABLED=true
PAYPULSE_API_URL=http://host.docker.internal:4100
PAYPULSE_API_KEY=<apiKey from bootstrap>
PAYPULSE_CALLBACK_URL=http://host.docker.internal:4000/api/v1/webhooks/paypulse- Recreate VoyageX booking:
docker compose up -d --force-recreate booking-service. Openhttp://localhost:3000.
Without PAYPULSE_API_KEY, VoyageX disables PayPulse and hotel/package orders default to PAID (offline demo).
Default webhook URL (PayPulse container → VoyageX booking on host):
http://host.docker.internal:4000/api/v1/webhooks/paypulse
See Payments contract (VoyageX) below for create / confirm / webhook payloads.
| Layer | Technology |
|---|---|
| Framework | NestJS (TypeScript) |
| Database | PostgreSQL + Prisma ORM |
| Cache / Idempotency | Redis |
| Message Broker | RabbitMQ |
| API Docs | Swagger (/docs) |
| Dev Infra | Docker Compose + hot-reload (ts-node-dev) |
- Async Deposit Pipeline —
POST /depositreturns202 QUEUEDinstantly; RabbitMQ consumer handles balance + ledger writes off the HTTP thread. - Checkout Payments — create
PENDINGpayments, confirm to credit wallet + ledger, deliverpayment.completedover HTTP. - Idempotency Engine — Redis-backed
X-Idempotency-Keylocks prevent duplicate processing on retries or double-clicks. - ACID Wallet Transfers — Prisma
$transactionblocks guarantee atomic balance deduction, credit, and ledger entry. - Reliable Webhooks — notifications are published to RabbitMQ, then HTTP-delivered by a dedicated consumer with
WebhookLogstatus tracking. - Zero-Friction DevEx — Docker volume mounts + auto
prisma db pushon container boot. Edit code, save, reload — no manual DB sync.
Client / VoyageX
│
├─ POST /payments
│ ├─ Redis idempotency check
│ └─ Create Payment PENDING
│
├─ POST /payments/:id/confirm
│ ├─ Redis idempotency check
│ ├─ Prisma $transaction (wallet credit + ledger DEPOSIT + Payment COMPLETED)
│ └─ Publish → RabbitMQ (paypulse.webhooks)
│
├─ POST /wallets/:id/deposit
│ ├─ Redis idempotency check
│ ├─ Publish → RabbitMQ (paypulse.deposits)
│ └─ Return 202 QUEUED
│
└─ POST /transfers
├─ Redis idempotency check
├─ Prisma $transaction (balance + ledger)
└─ Publish → RabbitMQ (paypulse.webhooks)
RabbitMQ Consumer (paypulse.deposits)
└─ Prisma $transaction → balance update + ledger insert
RabbitMQ Consumer (paypulse.webhooks)
└─ HTTP POST → merchant webhookUrl / payment.callbackUrl
| Method | Endpoint | Auth | Description |
|---|---|---|---|
POST |
/api/v1/merchants |
— | Register merchant, get API key |
POST |
/api/v1/wallets |
X-API-Key |
Create wallet |
GET |
/api/v1/wallets |
X-API-Key |
List wallets |
POST |
/api/v1/wallets/:id/deposit |
X-API-Key + X-Idempotency-Key |
Queue async deposit |
POST |
/api/v1/transfers |
X-API-Key + X-Idempotency-Key |
ACID balance transfer |
POST |
/api/v1/payments |
X-API-Key + X-Idempotency-Key |
Create PENDING payment |
GET |
/api/v1/payments/:id |
X-API-Key |
Get payment |
POST |
/api/v1/payments/:id/confirm |
X-API-Key + X-Idempotency-Key |
Confirm payment (demo pay) |
GET |
/api/v1/health |
— | Health check |
Create
POST /api/v1/payments
X-API-Key: <merchant api key>
X-Idempotency-Key: <unique key>
Content-Type: application/json
{
"amount": 149.99,
"currency": "USD",
"externalReference": "<VoyageX orderId>",
"description": "optional",
"callbackUrl": "optional override",
"metadata": {}
}Response: { id, status, amount, currency, externalReference, createdAt }
Confirm
POST /api/v1/payments/:id/confirm
X-API-Key: <merchant api key>
X-Idempotency-Key: <unique key>Response includes status: COMPLETED, paidAt, ledgerTransactionId.
Webhook (PayPulse → VoyageX)
POST <callbackUrl | merchant.webhookUrl>
Content-Type: application/json
X-PayPulse-Event: payment.completed
{
"event": "payment.completed",
"paymentId": "...",
"externalReference": "<orderId>",
"amount": "149.99",
"currency": "USD",
"status": "COMPLETED",
"timestamp": "..."
}cp .env.example .env
npm run dev| Service | PayPulse (host) | VoyageX (typical) |
|---|---|---|
| API | 4100 | 4000 (booking) |
| Postgres | 5433 → 5432 | 5432 |
| Redis | 6380 → 6379 | 6379 |
| RabbitMQ AMQP | 5673 → 5672 | 5672 |
| RabbitMQ UI | 15673 → 15672 | 15672 |
Note:
.envuseslocalhost+ remapped host ports for DB/Redis/RabbitMQ so host-side tools work. Docker app container overrides these to internal hostnames automatically.
Stack must be running first (npm run dev), then:
npm run prisma:studioStay on Prisma 6.x with Node 20. Do not upgrade to Prisma 7 unless you move to Node 22+.
| Command | Description |
|---|---|
npm run dev |
Start full stack with logs |
npm run dev:down |
Stop all containers |
npm run dev:clean |
Stop + wipe DB/volume data |
npm run bootstrap:voyagex |
Create VoyageX merchant + USD wallet, print apiKey |
npm run test:load |
Run 5,000 deposit stress test (100/batch) |
simulate-traffic.ts automates a full blast test:
- Creates 1 merchant + retrieves API key
- Creates 1 IDR wallet
- Fires 5,000 deposit requests in batches of 100 (
Promise.allper batch) - Each request uses a unique
X-Idempotency-Keyand random amount (10,000–50,000 IDR)
Prerequisite: API must be running (npm run dev).
npm run test:loadOr directly:
npx ts-node simulate-traffic.tsVerify async queuing in RabbitMQ UI:
http://localhost:15673 → Queues → paypulse.deposits
You should see message count spike during the blast, then drain as the consumer processes them.
Optional env overrides:
API_BASE_URL=http://localhost:4100 \
API_PREFIX=api/v1 \
LOAD_TOTAL_REQUESTS=5000 \
LOAD_BATCH_SIZE=100 \
npm run test:loadsrc/
├── merchants/ # Merchant onboarding + API keys
├── wallets/ # Wallet CRUD + async deposit producer/consumer
├── payments/ # PENDING payments + confirm (checkout)
├── transfers/ # ACID balance transfers
├── webhooks/ # HTTP webhook delivery consumer
├── idempotency/ # Redis middleware (X-Idempotency-Key)
├── rabbitmq/ # Queue publisher + consumers
├── redis/ # Redis client + lock helpers
└── prisma/ # Database service
scripts/
└── bootstrap-voyagex-merchant.ts
simulate-traffic.ts # High-volume stress test script
docker-compose.yml # Full local infra
MIT