Skip to main content

Payment Data Modeling

Last Updated: 2026-12-01 Status: Complete

Payment data modeling is the work of deciding which records a platform keeps, how they link, and which states they are allowed to move through. Get it wrong and every later feature (reporting, settlement, disputes, payouts) needs a workaround; get it right and the ledger, the API and the risk rules sit on stable ground. In this category you will build the entity model for a PayFac (platform, sub-merchant, location, terminal, principals, bank accounts, payments and disputes) and four explicit lifecycles with transition tables and enforcement code.

The two pages are meant to be read in order. The entity model defines what exists; the state machines define how it changes.

Quick Reference​

TopicDecision
HierarchyPlatform, sub-merchant (legal entity), location, terminal
Moneybigint minor units plus ISO 4217 code
Facts vs statusImmutable financial rows; mutable status with append-only history
TenancyTenant id on every row; row-level security as a backstop
LifecyclesOnboarding application, account status, payment, dispute, payout
EnforcementTransition map, conditional update, history row and outbox event in one transaction
Late eventsDeduplicate, compare with current state, ask the source of truth

How the Pieces Fit​

Learning Objectives​

After this category you should be able to:

  • Draw the tenant hierarchy and say what attaches at each level (pricing, settlement, risk, reporting).
  • Model principals, bank accounts and fee-schedule assignment with effective dating.
  • Separate payment intent from attempts, and model partial captures and refunds so totals are derived.
  • Store money, currency, FX rate and identifiers so settlement files can be matched later.
  • Write transition tables with guards and side effects for onboarding, payment, dispute and payout.
  • Apply a transition atomically in NestJS and handle out-of-order events.

Topics​

  1. Payment Platform Data Model — tenant hierarchy, principals, bank accounts, payment-side records, DDL and a NestJS DTO.
  2. Payment State Machines — four lifecycles, transition tables, enforcement code, late events and testing.
  3. Data Modeling Quiz — ten scenario questions on entity design and state machines.
Share: