What checkout coordinates
Checkout transforms a cart into a confirmed order. It touches many services: address, inventory, pricing, payment, and order creation. Each step can fail, so checkout must be designed for partial failure.
The typical steps
- Validate cart: confirm items still exist and stock is available.
- Compute totals: apply current prices, taxes, shipping, and promotions.
- Reserve inventory: hold the units so they are not sold to someone else mid checkout.
- Authorize payment: get the payment provider to approve the charge.
- Create order: persist the order and confirm to the shopper.
Designing for failure
If payment fails, the inventory reservation must be released. If the order record write fails after a successful charge, you need a reconciliation process or the charge gets refunded. Idempotency keys prevent a retried checkout from charging twice.
Key idea
Checkout is a multi step pipeline where each step can fail, so use reservations, idempotency, and reconciliation to stay correct.