Skip to main content

Payment Platform Architecture

Last Updated: 2026-12-01 Status: Complete

Payment platform architecture is the set of systems a payment facilitator, marketplace or embedded-payments platform must build on top of its processor: the data model for merchants and money, the ledger that proves every balance, the event and webhook plumbing that keeps everyone in sync, the payout and fee engines that move the money, and the controls that keep it auditable and secure. The earlier modules explain how the industry works. This one is about what to build.

Each page gives you schemas, state machines, journal entries, decision tables and short TypeScript examples in NestJS style. The examples are deliberately small. They show the shape of a correct design, not a production codebase.

Quick Reference​

AreaThe design rule that matters mostWhere it is covered
Data modelFinancial records are immutable; status changes are appended, never overwrittenData Modeling
LifecyclesOnboarding, payments, disputes and payouts are explicit state machines that reject invalid transitionsState Machines
LedgerEvery movement is a balanced journal entry; balances are derived from entries, not storedLedger & Balances
IdempotencyKeys belong to the caller and stop at the API boundary; below it, ISO 8583 uses reversalsIdempotency
EventsWrite the event in the same transaction as the change (outbox); every consumer is idempotentEvent-Driven Architecture
PayoutsPay from available balance only; a payout can come back after it was paidPayouts, Reserves & Fees
Audit and dataAppend-only, tamper-evident audit logs (PCI DSS retention: At least 12 months of audit log history, with the most recent three months immediately available for analysis); card data tokenized before it reaches your serversAudit, Data Protection & Access
OperationsAlert on rates against your own baseline; test failure paths, not only the happy pathObservability, Testing & Scale
Time-Sensitive

PCI DSS requirements, Nacha rules and processor behaviors (webhook retry windows, idempotency key retention) change. Every such figure on these pages links to its source and verification date on Key Numbers. Processor behaviors are quoted as examples of what to design for; check your own provider's documentation.

Reference Architecture​

The state machines decide what is allowed to happen. The ledger records what happened to the money. The outbox makes sure the rest of the system, and your customers, hear about it exactly as often as the delivery guarantees allow: at least once.

Learning Objectives​

After completing this module, you will be able to:

  • Model the domain: Design the platform → sub-merchant → location hierarchy with principals, bank accounts and pricing, and link payments to captures, refunds, settlements, disputes and payouts.
  • Build lifecycles: Implement onboarding, payment, dispute and payout state machines with guarded transitions and an append-only history.
  • Build a ledger: Choose a chart of accounts, post balanced journal entries for sales, fees, refunds, chargebacks, reserves and payouts, and compute pending and available balances in several currencies.
  • Reconcile: Prove the ledger against processor files and bank statements using clearing and suspense accounts, and correct errors without editing history.
  • Make it reliable: Implement idempotency keys, a transactional outbox, idempotent consumers, dead-letter queues, and signed webhooks you can both send and receive safely.
  • Move money: Calculate payouts, implement split funding, rolling, fixed and capped reserves, recover negative balances, and build a fee engine with exact integer arithmetic.
  • Secure it: Design tamper-evident audit trails, keep card data and PII out of your systems where possible, and implement API authentication, RBAC, MFA and secrets management.
  • Operate it: Instrument technical and business metrics, test with sandboxes and simulated chargebacks, and scale the ledger without giving up correctness.

Sections​

1. Data Modeling & State Machines​

2. Ledger & Balances​

3. Idempotency, Events & Webhooks​

4. Payouts, Reserves & Fees​

5. Audit, Data Protection & Access​

6. Observability, Testing & Scale​

7. Study Guide​

Build Order for a New Platform​

If you are starting from nothing, this order keeps rework low. Each step depends on the ones before it.

StepBuildWhy first
1Entity model and tenant scopingEvery table and every query depends on who owns the data
2Ledger with a chart of accountsRetrofitting double entry onto stored balances is the most painful migration in payments
3Payment state machine with idempotent APIThe first money-moving endpoint needs keys and an explicit unknown state from day one
4Outbox and webhooksCustomers need asynchronous outcomes as soon as payments are live
5Settlement ingestion and reconciliationYou cannot pay anyone until you can prove what the processor paid you
6Fee engine, reserves and payoutsPayouts are only safe once balances are proven
7Disputes, negative balances and recoveryLosses arrive weeks after the sale; the machinery must exist before they do

Audit logging, access control and observability are not steps. Build them into each step as you go.

PayFac, Marketplace and ISO Considerations​

  • A PayFac owns sub-merchant onboarding, the ledger and payouts. Everything in this module is its responsibility, under the terms of its sponsor bank agreement. See PayFac Implementation.
  • A marketplace or SaaS platform on a PayFac-as-a-service provider (for example Stripe Connect or Adyen for Platforms) still needs its own entity model, webhooks, idempotency and reconciliation. The provider runs the regulated ledger and payouts, but the platform must mirror balances it shows to its users and react to provider events.
  • An ISO usually relies on the processor's platform. It needs reliable ingestion of processor data, residual calculation and reporting, so the ledger, fee distribution and reconciliation pages still apply.

References​

Share: