A production-minded payment reliability gateway built to eliminate ghost transactions, duplicate charges, and inconsistent payment states.
Designed to explore how money breaks in distributed systems — and how resilient systems recover.
In distributed payment systems, success is not binary.
Payment providers may report success while your system crashes, retries duplicate requests, or fails halfway through settlement.
This creates:
Money moves, but systems disagree on what actually happened.
TelePay solves this using:
- Idempotency
- Finite State Machines (FSM)
- Saga Compensation
- Redis Distributed Locks
- BullMQ Background Recovery
TelePay was built to answer one question:
How do payment systems remain correct even when everything goes wrong?
Instead of another CRUD payment API, TelePay focuses on:
- Transactional correctness
- Failure recovery
- Duplicate prevention
- Deterministic state transitions
- Distributed reliability patterns
┌──────────────────┐
│ Client │
└────────┬─────────┘
│
▼
┌───────────────────┐
│ TelePay API │
│ Express Server │
└────────┬──────────┘
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌────────────────┐ ┌────────────────┐ ┌────────────────┐
│ PostgreSQL DB │ │ Redis │ │ BullMQ │
│ Source of Truth│ │ Locks + Cache │ │ Background Jobs│
└────────────────┘ └────────────────┘ └────────────────┘
│
▼
┌─────────────────────┐
│ Mock Payment │
│ Provider/Webhook │
└─────────────────────┘
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Caching / Locks: Redis
- Queues: BullMQ
- HTTP Client: Axios
Prevents duplicate payment processing.
Safely handles delayed or duplicate provider webhooks.
Ensures legal payment transitions only.
Automatically refunds when partial failures occur.
Prevents race conditions and concurrent state corruption.
Handles retries, reconciliation, and dead-letter workflows.
INITIATED
↓
AUTHORIZED
↓
SETTLED
Refund flow:
SETTLED
↓
REFUND_PENDING
↓
REFUNDED
git clone https://github.com/yourusername/telepay.git
cd telepay
npm install
npm run devDATABASE_URL=
REDIS_URL=
PORT=
NODE_ENV=
PROVIDER_SECRET=- Payments are state machines.
- Retries without idempotency are dangerous.
- Distributed systems fail by default.
- Correctness matters more than speed.
- Reliable systems recover automatically.