Skip to main content

Carts

Cart lifecycle and reads (Cart aggregate).

📄️Introduction

REST contract of the shopping-cart bounded context of the digital storefront, derived from storefront/model/model.yaml (contexts[shopping-cart].rest) and the FINAL model-gap decisions (H1-H6 and checkout H10). The cart holds a shopper's intent: lines, destination postal prefix, the delivery quote delivery-promise returned for the cart (per shipment group, with offers and expiry), the shopper's tier selection per group, and a labelled, non-binding estimate (effective prices + selected tier charges + tax band) so the total cost is visible up front. Without a destination the estimate shows the item subtotal only and estimateComplete is false. One line per item; adding an existing item merges quantities. Any line or destination change clears the quote and the selections. Errors are RFC 9457 problem details (application/problem+json) whose type is /problems/<slug>; shared types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422), plus one kebab-case slug per Err of the model, and the idempotency problems idempotency-key-required and idempotency-key-invalid (400) and idempotency-key-reused (409). Every POST takes an Idempotency-Key header: a retry with the same key and the same request replays the stored answer (Idempotency-Replayed: true). A 2xx is stored for 24 hours, and so is a refusal that is final for the request (malformed-request, quantity-out-of-range, validation-failed, cart-closed); a refusal that depends on state that can change (not-found, concurrent-update, stale-delivery-selection, item-not-purchasable, too-many-lines, no-destination, merge-target, illegal-transition) and a 5xx are never stored: the key is released, the same Idempotency-Key runs the request again, and another request under it is a new request. Otherwise the same key with another request is 409 idempotency-key-reused. PUT and DELETE are idempotent by method. GET /carts is keyset-paged ({items, nextCursor}; invalid-limit, invalid-cursor and unknown-query-parameter are 400). No authentication; shopperId is optional (guest-first).

📄️Write the offers of a checkout requote into the cart

AcceptRequotedOffers. Checkout reports REQUOTE_REQUIRED with the requotedOffers it obtained for the groups it had selected; the BFF writes them here. The supplied set REPLACES the cart's delivery quote (one offer per group) and each offer is the selection of its group, WITHOUT calling delivery-promise. A group keeps the lineNos of the previous quote's group of the same number (a single-group quote spans every line). Lines and destination are untouched. Checkout re-verifies every offer with its pre-authorize check, so nothing is trusted here. Publishes nothing.