Course map

Project 08

Payment processing

Idempotency, payment reliability

Start after Part 8

Key topics 38, 116, 139

Architecture Services

Published reference Stripe, "Designing robust and predictable APIs with idempotency" (Brandur Leach, 22 Feb 2017)

Brief

A payment service mediating between order systems and external providers: authorize, capture, refund; provider webhooks; retries; reconciliation; PCI-aware design.

Targets

500 payments/sec · never double-charge · 99.99% availability · every payment's state always determinable · provider failover under 1 minute.

Must cover

  • Idempotent requests and unknown outcomes after timeouts (→ 38, 116).
  • Reconciliation against provider settlement reports (→ 81).
  • Compensation — refunds and releases as saga steps (→ 139).
  • Authorization, capture, refunds and settlement as an explicit state machine (P).
  • PCI DSS scope minimization through tokenization (P; → 171).

Design challenges

  1. Idempotency end to end (→ 38, 116): client keys → stored attempt records → provider keys; prove the double-click case and the timeout-retry case.
  2. The uncertain state: the provider call timed out — charged or not? A state machine with PENDING_UNKNOWN and the reconciliation job that resolves it (→ 126, 81).
  3. Webhooks (→ 40): duplicated, reordered, delayed provider callbacks; signature verification.
  4. Provider abstraction with failover routing; circuit breaker per provider (→ 47 Strategy; → 151 — ahead, Part 9).
  5. The refund/cancellation flow as compensating transactions in the order saga (→ 139).
  6. Tokenization so card data never touches your servers — PCI scope minimization (→ 164, 171).

Out of scope

The ledger itself (Project 9); fraud scoring (integration point noted in step 21).

Search the guide