Digital storefront · Supporting domain · EventStorming board

checkout

Turns a ready cart into a placed order: a binding price, an authorized payment and an order handed on, with recovery when a step gives no clear answer.

GitHub ↗ · Documentation ↗ · Architecture check · Briefings

events published
7
commands
7
policies
11
read models
3
hot spots
4

The story in 5 key events

The pivotal events: the few that matter most, in the order they happen.

  1. Pivotal eventCheckoutOpened
  2. Pivotal eventCheckoutDeclined
  3. Pivotal eventCheckoutCompleted
  4. Pivotal eventCheckoutRequoteRequired
  5. Pivotal eventCheckoutFailed

Listens to (0): contexts whose events this one reacts to

none

Tells (2): contexts that react to its events

The board, row by row

11 rows, in the order the business story happens: the main path first, then how this context reacts to the others, then the clock. Rows are small stories; read each one left to right.

  • Event
  • Command
  • Actor
  • Aggregate
  • Policy
  • Read model
  • External system
  • Hot spot
  • Opportunity
  1. Open a checkout session

    The shopper starts checkout from a ready cart. Checkout checks that every chosen delivery offer is still valid, gets a binding price quote from pricing and opens a session that lasts as long as the quote.

    ActorShopper
    Read modelCart ready for checkout
    Read modelDelivery offers still valid
    Read modelBinding price quote
    CommandOpenSessionPOST /checkout-sessions
    AggregateCheckoutSession
    EventCheckoutOpenedanalytics stream only

    Source: application/usecases/open_session.go · domain/checkoutsession/open.go

  2. Confirm and place the order

    The shopper confirms with a payment method token. Checkout has the exact quote total authorized, then places the order. Once the order is accepted the session is complete.

    ActorShopper
    CommandConfirmSessionPOST /checkout-sessions/{sessionId}/confirmations
    AggregateCheckoutSession
    EventCheckoutCompleted
    Systemshopping-cart
    PolicyCloses the shopper's cart as checked out
    Systemcustomer-payments
    PolicyBinds the order to the payment authorization and applies facts that waited for it

    Source: application/usecases/confirm_session.go · application/usecases/settle.go · domain/checkoutsession/terminals.go

  3. Payment is declined

    The payment is refused, or the amount authorized is not the quote total, in which case the hold is released. The session is declined and the shopper may try another payment method until the quote runs out.

    ActorShopper
    CommandConfirmSessionPOST /checkout-sessions/{sessionId}/confirmations
    AggregateCheckoutSession
    EventCheckoutDeclinedanalytics stream only

    Source: application/usecases/confirm_session.go · domain/checkoutsession/transitions.go

  4. The order needs new delivery offers

    When the order is placed, an offer turns out to have changed and the order service sends new ones. The session ends as requote required with those offers and the payment hold is released.

    ActorShopper
    CommandConfirmSessionPOST /checkout-sessions/{sessionId}/confirmations
    AggregateCheckoutSession
    EventCheckoutRequoteRequiredanalytics stream only

    Source: application/usecases/settle.go · domain/checkoutsession/terminals.go · adapters/outbound/customerordering/gateway.go

  5. The order is refused

    The order service rejects the order outright. The session fails with a code, an alert is raised and the payment hold is released.

    ActorShopper
    CommandConfirmSessionPOST /checkout-sessions/{sessionId}/confirmations
    AggregateCheckoutSession
    EventCheckoutFailedanalytics stream only

    Source: application/usecases/settle.go · domain/checkoutsession/terminals.go

  6. The order service does not answer

    The order service gives no clear answer. The session stays locked in placing and the shopper is told the order is still being processed. This is announced once, on the first unclear answer.

    ActorShopper
    CommandConfirmSessionPOST /checkout-sessions/{sessionId}/confirmations
    AggregateCheckoutSession
    EventCheckoutPlacementInDoubtanalytics stream only

    Source: application/usecases/settle.go · domain/checkoutsession/transitions.go

  7. Settle an order that was in doubt

    A sweep replays the stored order request with the same key until the order service answers. It alerts at 20 hours, and at 22 hours gives up, fails the session and releases the payment hold.

    TimeOrder sweep
    PolicyEvery sweep, replay each unsettled order request and record the answer
    CommandResolveInDoubtPlacementsstarted by the clock
    AggregateCheckoutSession
    EventCheckoutCompleted
    EventCheckoutRequoteRequiredanalytics stream only
    EventCheckoutFailedanalytics stream only
    Systemshopping-cart
    PolicyCloses the shopper's cart as checked out
    Systemcustomer-payments
    PolicyBinds the order to the payment authorization and applies facts that waited for it

    Source: application/usecases/resolve_in_doubt.go · domain/checkoutsession/terminals.go

  8. Settle a payment that never answered

    A session left authorizing for over 2 minutes asks customer-payments again with the same key to learn the true outcome. The purchase then carries on as after a normal confirmation.

    TimePayment sweep
    PolicyEvery sweep, any session authorizing for over 2 minutes asks again, with the same key
    CommandResolveStuckAuthorizationsstarted by the clock
    AggregateCheckoutSession
    EventCheckoutDeclinedanalytics stream only
    EventCheckoutCompleted
    Systemshopping-cart
    PolicyCloses the shopper's cart as checked out
    Systemcustomer-payments
    PolicyBinds the order to the payment authorization and applies facts that waited for it

    Source: application/usecases/policies.go · application/usecases/confirm_session.go

  9. Release a payment hold that is still owed

    When an order is refused or needs a requote, releasing the payment hold is recorded as a debt on the session. A sweep retries every minute until it works.

    TimeRelease sweep
    PolicyEvery minute, retry each payment-hold release that is still owed
    CommandRetryOwedVoidsstarted by the clock
    AggregateCheckoutSession

    Source: application/usecases/policies.go · application/usecases/settle.go

  10. Let a session expire with its quote

    A sweep expires every open or declined session whose price quote has run out. A session that is authorizing or placing is not touched.

    TimeExpiry sweep
    PolicyEvery sweep, an open or declined session past its quote expiry becomes expired
    CommandExpireOnQuoteExpirystarted by the clock
    AggregateCheckoutSession
    EventCheckoutSessionExpiredanalytics stream only

    Source: application/usecases/policies.go · domain/checkoutsession/terminals.go

  11. Forget old order requests

    The stored order request is dropped 24 hours after a session closes. The session itself stays, and nothing is announced.

    TimePurge sweep
    PolicyEvery sweep, drop the stored order request of sessions closed over 24 hours ago
    CommandPurgeStoredPlacementsstarted by the clock
    AggregateCheckoutSession

    Source: application/usecases/policies.go · domain/checkoutsession/terminals.go

Hot spots and opportunities

Open questions and known gaps, each taken from a decision record or a document in the repository, never invented.

  • Hot spotHow the cart takes the requoted offers is open. Checkout only carries them; whether anything writes them into the cart is not verified here.

    Source: docs/ddd/bounded-context-canvas.md

  • Hot spotIf the order service never answers, the session stays locked for up to 22 hours before it fails and the payment hold is released.

    Source: adr/0002-checkout-assumptions.md

  • Hot spotOffers are checked only when the session opens. One that expires before confirmation surfaces later as a requote from the order service.

    Source: docs/ddd/eventstorming.md

  • Hot spotA failed release of a payment hold stays on the session as a debt, retried every minute. After an amount mismatch the shopper cannot confirm again until it clears.

    Source: adr/0002-checkout-assumptions.md

This board is a reconstruction from the code and documentation of checkout at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.