Payment Processing Cheat Sheet
Key concepts, trade-offs, and quick-reference notes for your interview prep.
Idempotency Key: DB UNIQUE Constraint Prevents Double Charges
#1💡 UNIQUE(merchant_id, idempotency_key) in same ACID txn as INSERT. 2ms overhead. Zero double charges.
Payment State Machine: 5 States, No Backward Transitions
#2💡 5 states, forward-only transitions, each change logged in ledger. 7-day capture window.
Two-Phase Capture: Authorize First, Capture Within 7 Days
#3💡 Authorize = hold, Capture = move money. 7-day window. Partial capture allowed.
Tokenization: Raw Card Numbers Never Touch App Servers
#4💡 Tokenize at edge. Vault is the only PAN handler. Audit scope: 1 vault, not 100 servers.
Double-Entry Ledger: Every Cent Accounted Twice
#5💡 Debit + credit for every txn. Append-only. 864M rows/day. Debits = Credits always.
Network Timeout: 2-Second Cap with Automatic Reversal
#6💡 2s timeout. Never retry on timeout. Mark unknown, reconcile T+1. Holds auto-expire.
Webhook Retry: Exponential Backoff + Dead Letter Queue
#7💡 Exponential backoff: 1m, 5m, 30m, 2h, 24h. DLQ after 5 retries. HMAC signature.
PCI-DSS: Encrypt at Rest + In Transit + Audit Log
#8💡 AES-256 at rest, TLS 1.2+ in transit, immutable audit logs, vault in isolated VPC.
Reconciliation: Batch Compare Gateway vs Network at T+1
#9💡 T+1 settlement file. Line-by-line comparison. 389 GB/run. 50 parallel workers. T+2/T+3 money movement.
Sharding by merchant_id: Co-locates All Merchant Data
#10💡 Shard by merchant_id. ACID txn stays on one shard. 8 shards for 10K TPS.