System Design: Online Payment Processing Platform
Scenario
Design a multi-tenant online payment processing platform that lets merchants accept card and digital wallet payments globally. Assume a mix of e-commerce (card-not-present) use cases and support for regional regulations (e.g., PSD2/SCA in the EU). Merchants integrate via REST APIs and webhooks.
Functional Requirements
-
Payments API
-
Authorize, capture (partial/multiple), refund (partial/multiple), void/cancel.
-
Idempotency keys and exactly-once charge semantics from the merchant’s perspective.
-
Tokenization for cards and wallet payment methods; avoid storing PAN in merchant systems.
-
Webhooks for state changes (authorized, captured, refunded, chargeback, payout).
-
End-to-end processing
-
Flow across gateway, acquirer, card networks, and issuers.
-
3DS/SCA support (frictionless and challenge flows), risk scoring, velocity controls, optional ML risk.
-
PCI scope boundaries and tokenization strategy.
-
Data and accounting
-
Data model for transactions, ledger entries, settlements, chargebacks, payouts, and immutable audit logs.
-
Consistency model, deduplication, retries, and orchestration (outbox/SAGA) for multi-step workflows.
-
Money movement and operations
-
Settlement/clearing with acquirers, currency conversion, fees, and scheduled payouts.
-
Reconciliation against acquirer/network files and dispute handling.
Non-Functional Requirements
-
Scalability: thousands of TPS at peak; p99 latency < 200 ms for authorize (excluding 3DS challenges).
-
Resilience: backpressure, queueing, retries with idempotency.
-
Availability: multi-region active-active. State your RPO/RTO objectives and data replication approach.
-
Observability: metrics, tracing, log correlation. Secure access control, PII/GDPR handling, key management.
-
Testing: strategy for unit/integration/load; simulators/mocks for external partners; handling timeouts/partial failures.
Deliverables
Provide a detailed design covering:
-
API design and exactly-once semantics.
-
End-to-end processing flows, tokenization, and PCI boundaries.
-
Risk/fraud controls and 3DS/SCA.
-
Data model and storage approach, including ledgers and audit logs.
-
Consistency, deduplication, orchestration (outbox/SAGA).
-
Settlement, reconciliation, currency conversion, fees, payouts.
-
Scalability, backpressure, HA/DR.
-
Observability, security, privacy, and key management.
-
Testing and failure-handling strategies.