A productionβgrade, modular payment gateway built with:
- Node.js (TypeScript)
- Express.js
- PostgreSQL (Prisma ORM)
- Redis (idempotency + caching + queues)
- BullMQ (webhook retries & background jobs)
- Docker
- OpenAPI (Swagger)
- Postman Collection
It supports both gateway providers and Nigerian banks/fintechs:
| Provider | Status | Notes |
|---|---|---|
| Paystack | β Full | Working REST integration |
| Stripe | βοΈ Ready | SDK + webhook scaffold |
| Flutterwave | π§ Scaffold | Ready for full integration |
| Remita | π§ Scaffold | RRR billing flow |
| Access Bank | π§ Scaffold | Corporate |
| First Bank | π§ Scaffold | Corporate |
| GTBank | π§ Scaffold | Corporate |
| UBA | π§ Scaffold | Corporate |
| Stanbic IBTC | π§ Scaffold | Corporate |
| Premium Trust Bank | π§ Scaffold | Basic flows |
| OPay | π§ Scaffold | Collections API |
| NIPSB | π§ Scaffold | Instant payments |
git clone <repo-url>
cd Payment-integration
npm install
Copy .env.example β .env and set your values:
DATABASE_URL=postgresql://agentic:password@localhost:5432/agentic_payments
REDIS_URL=redis://localhost:6379
PAYSTACK_SECRET_KEY=sk_test_xxxxxx
STRIPE_SECRET_KEY=sk_test_xxxxxx
FLUTTERWAVE_SECRET_KEY=
REMITA_API_KEY=
ACCESSBANK_API_KEY=
FIRSTBANK_API_KEY=
GTBANK_API_KEY=
UBA_API_KEY=
STANBIC_API_KEY=
PREMIUMTRUST_API_KEY=
OPAY_API_KEY=
NIPSB_API_KEY=
π‘ For Paystack, use the secret key, not the public key.
Start services:
docker-compose up -d postgres redis
Verify:
docker ps
npm run dev
Expected startup:
Paystack Secret Key Loaded: yes
BullMQ workers initialized
Server running on port 3000
Redis connected
Your API is now live at:
http://localhost:3000/api
GET http://localhost:3000/api/health
GET http://localhost:3000/api/payments/providers
POST
http://localhost:3000/api/payments/initiate
Headers:
Content-Type: application/json
Idempotency-Key: TEST123
Body:
{
"provider": "paystack",
"amount": 5000,
"currency": "NGN",
"customerId": "demo_123",
"reference": "ref_xyz",
"callbackUrl": "https://example.com"
}Run the endβtoβend payment initializer:
npx ts-node scripts/pay-demo.ts
Expected output:
Payment initialized successfully!
paymentUrl: https://checkout.paystack.com/xxxx
The entire API is documented in:
openapi.yaml
Import into:
- SwaggerHub
- Redoc
- Insomnia
- Postman
Import:
postman_collection.json
Includes:
- Health
- Providers
- Create Payment
- Confirm Payment
- Refund
- Create Customer
npx prisma studio
npx prisma migrate dev --name init
npx prisma db seed
BullMQ handles:
- Webhook retries
- Async provider operations
Workers start automatically:
BullMQ workers initialized
The system does not store or process raw card numbers (PAN/CVV).
This keeps you in PCI SAQβA compliance.
Security layers included:
- Idempotency keys
- Redis locks
- Webhook signature verification (Stripe-ready)
- Separate raw body parsing for webhooks
- Server-side input validation
src
ββ app.ts
ββ server.ts
ββ config/
ββ db/
ββ jobs/
ββ middleware/
ββ modules/
β ββ payment/
β ββ adapters/
β ββ controllers/
β ββ routes/
β ββ webhooks/
β ββ types.ts
β ββ paymentService.ts
β ββ providerRegistry.ts
β ββ paymentModule.ts
ββ routes/
prisma/
scripts/
docs/
docker-compose up --build
docker build -t agentic-brain-api .
Deployable to:
- AWS ECS
- Railway
- Render
- Azure Container Apps
- Digital Ocean
- Complete more bank adapters
- Add real webhook signatures (Stripe, Paystack, Flutterwave)
- Add logging to Sentry
- Add Jest integration tests
- Add BullMQ dashboard
- Add rate limiting
Built with β€οΈ for modern organizations.