Commercetools
Intermediate

Cart and Checkout State Machine

Design checkout as a controlled workflow over Carts, shipping, taxes, payment authorization, and order creation.

50 min
3 sections
carts
checkout
state
1
2
3

01. Carts are mutable transaction workspaces

Section 1 of 3

A Cart is where line items, prices, discounts, shipping, addresses, tax mode, customer context, and payment references come together before an Order is created. Checkout code should treat the Cart as a stateful transaction workspace with clear steps and conflict handling.

text
Checkout state machine:

CREATED
  -> ITEMS_CONFIRMED
  -> ADDRESS_CONFIRMED
  -> SHIPPING_SELECTED
  -> TAX_CALCULATED
  -> PAYMENT_AUTHORIZED
  -> ORDER_CREATED

Failure states:
- PRICE_CHANGED
- OUT_OF_STOCK
- PAYMENT_REQUIRES_ACTION
- TAX_PROVIDER_UNAVAILABLE
Back to Course