Glossary: System Design Beyond the Basics in Java
Payment state machine
Payments are always in one state (created, authorized, captured or failed), with a list of allowed moves. Other moves are refused, so a late retry can't capture a failed payment.