Nafiz Anam.

All case studies
Fintech / PaymentsPaymentsFintechSubscriptionsbKashStripe

AgiloPay: A Multi-Gateway Payment Orchestration Platform

How I designed and built AgiloPay, a payment orchestration service that routes payments across bKash, Rocket, SSLCommerz, EPS, Stripe and Paddle, handles subscriptions and signed callbacks, and powers every product I run.

Services provided: Payments, Fintech, Subscriptions, bKash, Stripe, Paddle, Node.js, PostgreSQL, BullMQ, API Design

See How We Helped

Client

AgiloPay (own platform)

My Role

Lead Backend Engineer & Payments Architect

Key Outcome

One idempotent, signed payment path for six gateways, shared by multiple SaaS products

AgiloPay: A Multi-Gateway Payment Orchestration Platform: case study cover image for AgiloPay (own platform)

Short answer: what is AgiloPay?

AgiloPay is a payment orchestration platform I designed and built so that every product I run shares one secure payment path. Merchant applications submit a payment request, AgiloPay routes it to the right provider (Paddle, Stripe, EPS, bKash, Rocket or SSLCommerz), tracks the payment state, and notifies the application with a signed callback. It also owns subscription plans, coupons, invoices and dunning. It currently serves Agilo Academy, Agency, CRM, DreamPOS, and the SaaS billing for ISP Nova and Ponnokhata.

This case study covers the problem, the architecture, the hard engineering decisions and the security model. AgiloPay is an internal platform rather than a public website, so the discoverability section focuses on its documentation and developer experience.

Project snapshot

ProductAgiloPay, a multi-gateway payment and subscription orchestration service
My roleLead Backend Engineer & Payments Architect
ModelInternal platform service with an ops admin console and a private TypeScript SDK
Build windowFirst commit June 2026, with subscriptions and recurring billing added by October 2026
Scale of the codebase24 data models, 20+ API modules, 25,000+ lines of TypeScript across API, admin dashboard and SDK
StackNode.js, Express, TypeScript (strict), PostgreSQL, Prisma, Redis, BullMQ, Zod, Pino, Next.js, Docker, OpenAPI 3.1

What problem does AgiloPay solve?

Each product I built needed to take money, and each started by wiring its own gateways. That repeats the same risky work and spreads it thin:

  • Duplicated payment code. bKash, Nagad, Rocket, SSLCommerz, EPS, Stripe and Paddle integrations were copied between apps, each with its own bugs.
  • Secrets everywhere. Gateway credentials lived in every application's environment.
  • Inconsistent state. Webhooks, redirects and retries were handled differently per app, so payments could be marked paid twice or lost.
  • Different rules for different currencies. Bangladeshi gateways take one-time payments in taka. International subscriptions need card processors in dollars.

The brief: one service that owns money movement, so applications only say "charge this customer" and trust a verified answer.

What did I build?

Payments and checkout

  • Checkout sessions: a merchant creates a session, the customer is sent to the chosen gateway, and AgiloPay handles the return and confirmation.
  • Gateway adapters behind a single interface for Paddle, Stripe, EPS, bKash, Rocket and SSLCommerz, with a routing engine that picks a provider by currency, rules and availability.
  • Refunds and payment event history for every state change.

Subscriptions and recurring billing

AgiloPay owns the plan catalog, coupons, subscription lifecycle state machine, invoices and dunning policy, while Paddle or Stripe perform the actual collection. Bangladeshi gateways are one-time only, so a subscription in an unsupported currency is rejected up front with a clear error instead of failing later.

Callbacks and webhooks

Inbound gateway webhooks are signature-verified. Outbound callbacks to merchant apps are HMAC-signed and delivered through a retry queue, so an application that is briefly down still hears about the payment.

Operations console and SDK

A Next.js admin dashboard gives ops a view of merchants, payments, refunds, gateways, reconciliation and audit logs. A private TypeScript client SDK, published to GitHub Packages, lets each merchant app integrate in a few lines.

How is it architected?

  • Layered modules: controllers stay thin, business rules live in services, and each domain (checkout, payment, refund, subscription, plan, coupon, invoice, callback, webhook, reconciliation, audit, idempotency) is its own module.
  • Adapter pattern for gateways: a new provider means a new adapter, not a change to payment logic.
  • PostgreSQL with Prisma for state, Redis and BullMQ for callback delivery, retries and scheduled reconciliation.
  • API-first: every endpoint is defined in an OpenAPI 3.1 contract and Zod schemas before any code is written, and the same contract drives docs and the SDK.
  • Observability: structured Pino logs, a metrics module and health checks.

What were the hard engineering decisions?

How do you prevent double charges and double credits?

Every mutating call carries an idempotency key, and the idempotency module stores and replays the original result. Gateway webhooks and customer redirects can both report the same success, so state transitions are one-way and a payment already settled is never settled again.

How do you trust a webhook?

Nothing from a gateway changes state until its signature is verified. For gateways without webhooks, the return endpoint re-queries the provider rather than trusting query parameters, and a reconciliation job later compares AgiloPay's records against the provider's to catch anything missed.

How are gateway secrets protected?

Gateway credentials are encrypted with envelope encryption, with a documented key-rotation procedure. Merchants authenticate with API keys and HMAC signatures, admins with JWT, and every sensitive action writes an audit record. Card data is never stored: AgiloPay handles references, not card numbers.

Where does AgiloPay stop?

Deliberately, it does not own users, products, orders, customers or entitlements. Those belong to the requesting application, which keeps the service small and keeps a payment bug from becoming a business-logic bug.

How was the cutover done safely?

Moving ISP Nova and Ponnokhata onto AgiloPay followed a written cutover runbook: prepare a merchant record, wire credentials, remove the legacy per-gateway adapters, and verify callbacks. Deleting the old adapters left one payment path to secure and test.

How is AgiloPay documented for developers and AI tools?

AgiloPay is internal, so its audience is engineers and coding assistants rather than search users. The same discoverability principles apply.

  • Machine-readable contract: the OpenAPI 3.1 specification is the source of truth, with Swagger UI and Redoc rendered from it.
  • Task-oriented docs: architecture, API, database, security, events, webhooks, subscriptions, key rotation and a user guide, each answering one question directly.
  • Typed SDK: the client library gives autocompletion and examples that code assistants can use correctly.
  • Project rules file: a session-start protocol and module boundaries written down so any engineer or AI assistant extends the service consistently.

Results

  • One payment service now backs several products, replacing separate gateway integrations in each app.
  • Six payment providers behind one adapter interface, covering taka gateways and international card processors.
  • Subscription lifecycle, coupons, invoicing and dunning policy centralized instead of rebuilt per product.
  • A documented, signed and idempotent path for every payment and callback, built by one engineer in a few months.

Live sandbox verification of recurring billing with Paddle and Stripe credentials was still pending when this was written. I do not claim transaction volumes or success rates here, because I have not published audited figures.

Frequently asked questions

What does AgiloPay do?

It receives payment requests from merchant applications, routes them to a payment provider, tracks the state, handles refunds and subscriptions, and notifies the application through signed callbacks.

Which payment providers does it support?

Paddle, Stripe, EPS, bKash, Rocket and SSLCommerz. Bangladeshi gateways handle one-time payments, and recurring subscriptions run through Paddle or Stripe.

What tech stack is AgiloPay built on?

Node.js, Express and strict TypeScript with PostgreSQL and Prisma, Redis and BullMQ for queues, Zod validation, Pino logging, a Next.js admin console, and an OpenAPI 3.1 contract.

Can I hire the person who built it?

Yes. I build payment integrations, billing systems and SaaS platforms. Book a call to talk through your project.

Start a Project

Planning something similar?

Let's talk about your goals and how we can turn them into a scalable, production-ready system.

Send a MessageExplore Services