Tutorial

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

  1. The flow
  2. Where it lives
  3. Packages
  4. States, events and context
  5. The machine
  6. Serve it
  7. Check out
  8. Export the definition
  9. Test it

SDK Reference

Machine | Rules | AddStateMachines | Machines over GraphQL | UsePersistedOperations | trax CLI


Next: 12.1 The flow