Skip to main content

Checkout

checkout is a Supporting bounded context of the Storefront area of the warehouse-systems fleet. It is the purchase saga: one transaction across price, payment and the retail network's promise confirmation. A shopper's cart becomes a checkout session; the saga authorizes the payment first (compensatable: it can be voided), then places the order with customer-ordering (the pivot that cannot be undone from here), and leaves the retriable steps to events. While the place-order outcome is unknown the session sits in PLACING, the semantic lock: there is no void and no new attempt until a definitive answer arrives.

The context holds a shopperId and a shipToAddressId reference and never PII (no address, name or e-mail); the stored placement request is PII-free so it can be replayed byte for byte under the same Idempotency-Key. Nothing in the domain knows the network's wire names: the only place that does is the Anti-Corruption Layer to customer-ordering (ADR 0003).

:::info What runs on develop Three binaries from one image. cmd/api is the composition root: REST (chi, RFC 9457 problem details, Idempotency-Key middleware), Postgres repositories with embedded migrations, a transactional outbox with an always-on Kafka relay, and five clock-driven saga policies, on real Postgres and real Kafka only. There is no in-memory mode and no log sink: DATABASE_URL, KAFKA_BROKERS and the five sibling base URLs are mandatory and the process exits at boot naming the missing one. cmd/mcp is a read-only MCP server (ADR 0005) and cmd/a2a a read-only A2A agent (ADR 0007); both read the same session through the same GetSession use case. There is no web remote, no analytical read side and no authentication on REST, MCP or A2A (a fleet-wide decision). Packaged as a Dockerfile that builds every cmd/* and the Helm chart charts/checkout; deployed on the fleet's local cluster by warehouse-infra. :::

What the context owns​

ConceptWhere it livesRule in one line
CheckoutSession (the one aggregate)internal/domain/checkoutsessionEight states (OPEN, AUTHORIZING, DECLINED, PLACING, REQUOTE_REQUIRED, COMPLETED, EXPIRED, FAILED); COMPLETED, EXPIRED, FAILED and REQUOTE_REQUIRED never change.
Step orderinternal/application/usecasesAuthorize, then place, then events. An outbound call is never inside a database transaction: the saga saves the state it acts from, calls out, then saves the outcome.
Semantic lockPLACINGWhile the place-order outcome is unknown there is no void and no new attempt (placement-in-doubt).
Stored placement requestcheckout_sessions.placement_bodyThe PII-free place-order body, replayed with the same key until a definitive answer; dropped 24 h after a closed state.
Compensation debt (voidOwed)checkout_sessions.void_authorization_idA rejected placement or a mismatching authorization is voided at once and retried every minute until it succeeds.
Binding totalPriceQuote fields on the sessionItems + delivery charge per group + tax, allocated per group so the allocations sum to the quote total exactly.
Anti-Corruption Layerinternal/adapters/outbound/customerorderingThe only code that knows the network's POST /checkout, offer-not-quotable and requotedOffers.

What it does not own​

Out of scopeOwned by
Item prices, delivery charges, tax, the binding quotepricing (checkout asks for a quote and records its id, totals and expiry)
Talking to the payment provider, card tokens, capture, release, refundcustomer-payments (capture and refund follow fulfilment facts, not checkout)
Delivery offers, capacity, promises and their confirmationthe network: delivery-promise and customer-ordering
The order record, the ship-to address, shopper PII, order historycustomer-ordering (checkout keeps references only)
The cart, its lines and its delivery selectionshopping-cart
Sign-in and credentialsdeferred: authentication is off fleet-wide

Classification and area​

  • Supporting subdomain. Checkout is the storefront's most complex context (a saga with a semantic lock) but a shopper never chooses a store for its saga: it must work, and working is not the differentiator. See Subdomain classification and the Core domain chart.
  • Storefront area, CloudEvents tier segment storefront: types look like com.retailnetwork.storefront.checkout.checkoutsession.<EventName>.
  • It consumes the retail network's Open Host Service routes and never calls a restricted or in-org network route; see Integration.

Main capabilities​

  1. Open a session from a ready cart: read the cart, pre-check that every selected delivery offer is still quotable with margin, obtain the binding price quote and persist the session OPEN (POST /checkout-sessions).
  2. Confirm it with a payment-method token: authorize the exact quote total with an allocation per shipment group, store the PII-free placement request, place the order, and settle the answer (POST /checkout-sessions/{sessionId}/confirmations).
  3. Settle every outcome: COMPLETED with the order id; a decline that keeps the session open for another token; REQUOTE_REQUIRED with the network's re-quoted offers; FAILED for a rejected request; PLACING (HTTP 202) when the outcome is unknown.
  4. Heal itself with five policies: resolve in-doubt placements (alert at 20 h, give up and void at 22 h), re-call stuck authorizations with the same key, retry owed voids, expire OPEN and DECLINED sessions with their quote, and purge stored placement requests.
  5. Read a session over REST, MCP (get_checkout_session) and A2A (checkout_session_status).
  6. Publish seven CloudEvents through the transactional outbox: CheckoutCompleted on retailnetwork.checkout.events (consumed by shopping-cart and customer-payments) and six analytics-only events on retailnetwork.checkout.analytics.

Where to go next​

You want toRead
See the layers, packages, binaries and the rules that police themArchitecture
Run it and make the first callsQuickstart
Know every settingConfiguration
Deploy and operate itRunbook, Observability
Fix something that brokeTroubleshooting
Know what tests and CI gates existTesting
See who talks to whomIntegration
See the use cases and their invariantsUse cases
Read the design as ddd-crew artifactsDDD artifacts, Ubiquitous language
Read the contractsAPI overview, Event catalogue, MCP tools
Read the decisionsADR index

Published at https://iqvo.github.io/checkout/.

Disclaimer

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic.