12. Checkout is a state machine
So far an order arrives whole: lines, payment token and all, in one request. A real checkout takes several steps, in an order, with rules about which step may come next: nothing can be paid for until there is something in the cart and somewhere to send it, and a cart left alone for two hours is cleared. In this chapter checkout becomes a state machine: a set of states, the events that move between them, and the rules on each move, which the server applies and stores.
This chapter starts from the end of chapter 11.
In this chapter
- The flow
- Where it lives
- Packages
- States, events and context
- The machine
- Serve it
- Check out
- Export the definition
- Test it
SDK Reference
Machine | Rules | AddStateMachines | Machines over GraphQL | UsePersistedOperations | trax CLI
Next: 12.1 The flow