Payment gateway design part 2: 9-step flow and explicit state machine

goyalshaliniuk · x · 2026-12-06

Part 2 of the 'design a Stripe-like payment gateway' series, covering a reliable payment processing workflow.

9-step flow: customer initiates → merchant sends request → API gateway authenticates → payment service validates → fraud detection evaluates risk → orchestrator selects processor → processor talks to banking network → system records result and updates status → merchant receives final status via API/webhook.

Example states: CREATED, REQUIRESACTION, PROCESSING, AUTHORIZED, CAPTURED, FAILED, CANCELLED, REFUNDED. Not every payment follows the same path: some require additional customer authentication, others are declined or remain pending. Explicit states make workflows easier to debug and trace.

Related event: Engineering a Stripe-Style Payment Gateway: Architecture Deep Dive(2 posts)→

Original post →

More from coding & agent

coding & agent channel →