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
| Area | The design rule that matters most | Where it is covered |
|---|---|---|
| Data model | Financial records are immutable; status changes are appended, never overwritten | Data Modeling |
| Lifecycles | Onboarding, payments, disputes and payouts are explicit state machines that reject invalid transitions | State Machines |
| Ledger | Every movement is a balanced journal entry; balances are derived from entries, not stored | Ledger & Balances |
| Idempotency | Keys belong to the caller and stop at the API boundary; below it, ISO 8583 uses reversals | Idempotency |
| Events | Write the event in the same transaction as the change (outbox); every consumer is idempotent | Event-Driven Architecture |
| Payouts | Pay from available balance only; a payout can come back after it was paid | Payouts, Reserves & Fees |
| Audit and data | Append-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 servers | Audit, Data Protection & Access |
| Operations | Alert on rates against your own baseline; test failure paths, not only the happy path | Observability, Testing & Scale |
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
- Payment Platform Data Model - Entities, relationships, money fields and multi-tenancy
- Payment State Machines - Onboarding, payment, dispute and payout lifecycles
- Quiz
2. Ledger & Balances
- Double-Entry Ledger Design - Accounts, journal entries and derived balances
- Pending vs Available Balance - Holds, balance types and multi-currency
- Ledger Reconciliation - Proving the ledger against processor and bank data
- Quiz
3. Idempotency, Events & Webhooks
- Idempotency Key Implementation - Server-side keys, races and downstream calls
- Event-Driven Payment Architecture - Outbox, ordering, idempotent consumers and DLQs
- Webhook Delivery and Signature Verification - Retries, signing and verification, sending and receiving
- Payments API Design - Resources, errors, versioning and async operations
- Quiz
4. Payouts, Reserves & Fees
- Payout Architecture - Schedules, split funding, rails, failures and returns
- Reserves and Negative Balances - Reserve mechanics and loss recovery
- Payment Fee Engine Design - Fee schedules, rounding and revenue share
- Quiz
5. Audit, Data Protection & Access
- Audit Trail Design - Append-only logs, tamper evidence and retention
- Handling PII and Card Data - Tokenization, vaults, encryption, documents and deletion
- Access Control for Payment APIs - API keys, OAuth, RBAC, MFA and secrets
- Quiz
6. Observability, Testing & Scale
- Payment Platform Observability - Metrics, SLOs, tracing and alerting
- Testing Payment Systems - Sandboxes, test cards, chargeback simulation and failure injection
- Scaling Payment Platforms - Hot accounts, partitioning, replicas and capacity planning
- Quiz
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.
| Step | Build | Why first |
|---|---|---|
| 1 | Entity model and tenant scoping | Every table and every query depends on who owns the data |
| 2 | Ledger with a chart of accounts | Retrofitting double entry onto stored balances is the most painful migration in payments |
| 3 | Payment state machine with idempotent API | The first money-moving endpoint needs keys and an explicit unknown state from day one |
| 4 | Outbox and webhooks | Customers need asynchronous outcomes as soon as payments are live |
| 5 | Settlement ingestion and reconciliation | You cannot pay anyone until you can prove what the processor paid you |
| 6 | Fee engine, reserves and payouts | Payouts are only safe once balances are proven |
| 7 | Disputes, negative balances and recovery | Losses 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.
Related Modules
- Payment Ecosystem - The four-party model and the PayFac model
- Merchant Onboarding - KYC/KYB, underwriting and the merchant lifecycle that the onboarding state machine implements
- Risk & Compliance - Chargebacks, reserve policy and PCI DSS
- Transaction Processing - Authorization, ISO 8583, clearing, settlement files and three-way reconciliation
- Idempotency in Payments - The blog post the idempotency pages build on
- Key Numbers - Every time-sensitive figure used in this module, with sources
References
- PCI DSS v4.0.1 - PCI Security Standards Council, 2024
- Transactional outbox pattern - Chris Richardson, microservices.io
- What do you mean by "Event-Driven"? - Martin Fowler, 2017
- Ledger: Stripe's system for tracking and validating money movement - Stripe engineering blog, 2024
- The Idempotency-Key HTTP Header Field - IETF HTTPAPI working group, Internet-Draft
- Standard Webhooks specification - Standard Webhooks community
- OWASP API Security Top 10 (2023) - OWASP Foundation