Skip to main content

Domain Events

Every event this context publishes, with the consuming contexts for the one integration event. Checkout consumes no event. The catalogue is pinned by apis/asyncapi.yaml and checked by TestEventCatalogueMatchesContract; the short form is on the event catalogue. The domain-wide rules are on Event standard: CloudEvents.

Envelope​

Every Kafka message is a CloudEvents 1.0 event in structured JSON mode (internal/adapters/kafka/cloudevents/cloudevents.go):

AttributeValue for this context
specversion1.0
ida UUID minted once when the event is written to the outbox; a redelivery carries the same id
source/retailnetwork/checkout
typecom.retailnetwork.storefront.checkout.checkoutsession.<EventName> (tier storefront, entity checkoutsession)
subjectthe aggregate root id (sessionId)
timethe instant the fact happened, UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:checkout:events:CheckoutCompleted:v1 for the integration event; the six analytics-only events carry urn:retailnetwork:checkout:analytics:<EventName>:v1 (ADR 0004, encoder goldens)
Kafka topicretailnetwork.checkout.events for CheckoutCompleted; retailnetwork.checkout.analytics for the six analytics-only events
Kafka keysessionId, so one session's events stay on one partition and in order

Published​

Every event is written to outbox_events in the same transaction as the aggregate save, and a relay publishes it. CheckoutCompleted is the only integration event; the other six name their consumers as "analytics only" (Context Map).

CheckoutCompleted​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutCompleted
Topicretailnetwork.checkout.events
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:events:CheckoutCompleted:v1
Producing command / use caseRecordPlaced, after customer-ordering accepted the order (first call, or a replay by ResolveInDoubtPlacements)
Consumersshopping-cart, customer-payments
FieldTypeMeaning
sessionIdstringThe completed session.
orderIdstringThe order the network recorded.
shopperIdstringA reference to the shopper; no PII.
cartIdstringThe cart the session came from.
authorizationIdstringThe authorization held for the quote total.
currencystringThe one configured ISO 4217 currency.
totalMinorintegerThe quote total in minor units.
groupsarrayOne entry per shipment group: groupNo, tier, amountMinor (the allocation).
completedAttimestampWhen the session completed.

CheckoutOpened​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutOpened
Topicretailnetwork.checkout.analytics
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:analytics:CheckoutOpened:v1
Producing command / use caseOpenSession
Consumersanalytics only
FieldTypeMeaning
sessionIdstringThe session opened.
cartIdstringThe cart it was opened from.
shopperIdstringA reference to the shopper.
totalMinorintegerThe binding quote total.
openedAttimestampWhen the session opened.

CheckoutDeclined​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutDeclined
Topicretailnetwork.checkout.analytics
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:analytics:CheckoutDeclined:v1
Producing command / use caseRecordDecline (customer-payments declined the authorization), or RecordAuthorization when the authorized amount or currency is not the quote's (reason authorization-mismatch)
Consumersanalytics only
FieldTypeMeaning
sessionIdstringThe session whose authorization was declined.
reasonstringThe decline reason: payment-<state> (for example payment-declined) when customer-payments answers 201 in a state other than AUTHORIZED, authorization-rejected: <slug> on a 422, declined when none was given, or authorization-mismatch.
attimestampWhen the decline was recorded.

CheckoutRequoteRequired​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutRequoteRequired
Topicretailnetwork.checkout.analytics
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:analytics:CheckoutRequoteRequired:v1
Producing command / use caseRecordRequoteRequired (a definitive 409 from the network, after the authorization was voided)
Consumersanalytics only
FieldTypeMeaning
sessionIdstringThe session that needs a requote.
requotedOffersarrayThe re-quoted offers: offerId, groupNo, tier, deliverByEarliest, deliverByLatest, expiresAt.
attimestampWhen the requote was recorded.

CheckoutFailed​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutFailed
Topicretailnetwork.checkout.analytics
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:analytics:CheckoutFailed:v1
Producing command / use caseRecordFailure: a 400 or 422 from the network, a contract bug (code place-order-rejected), or the 22 h give-up of an in-doubt placement (code placement-unresolved). The authorization is voided and an alert is raised.
Consumersanalytics only
FieldTypeMeaning
sessionIdstringThe session that failed.
codestringThe failure code stored on the session: place-order-rejected or placement-unresolved.
attimestampWhen the failure was recorded.

CheckoutSessionExpired​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutSessionExpired
Topicretailnetwork.checkout.analytics
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:analytics:CheckoutSessionExpired:v1
Producing command / use caseExpireSession (policy ExpireOnQuoteExpiry, from OPEN or DECLINED)
Consumersanalytics only
FieldTypeMeaning
sessionIdstringThe session that expired.
attimestampWhen the expiry was recorded.

The payload is {sessionId, at} only (internal/adapters/outbound/kafka/testdata/CheckoutSessionExpired.golden.json).

CheckoutPlacementInDoubt​

ItemValue
Full typecom.retailnetwork.storefront.checkout.checkoutsession.CheckoutPlacementInDoubt
Topicretailnetwork.checkout.analytics
Subject / keysessionId
Dataschemaurn:retailnetwork:checkout:analytics:CheckoutPlacementInDoubt:v1
Producing command / use caseRecordPlacementInDoubt (timeout or 503 from the network; the session stays PLACING)
Consumersanalytics only
FieldTypeMeaning
sessionIdstringThe session whose place-order outcome is unknown.
placingSincetimestampWhen the session entered PLACING (the clock of the 20 h alert and the 22 h give-up).
attimestampWhen the in-doubt outcome was recorded.

ConfirmSession and RecordAuthorization raise no event: CheckoutCompleted already covers the outcome. Expiry and an in-doubt placement are operator facts, published analytics-only.

Consumed​

None. Checkout has no consumer, no consumer group, no DLQ and no inbox: the session reacts to the synchronous answer of each call it makes. The two consumers of CheckoutCompleted are other services; the group names they use are theirs (in warehouse-infra they are shopping-cart-checkout and customer-payments-checkout) and are not set by this repository.

What the consumers do with CheckoutCompleted​

This is the consumers' behaviour as their own contracts describe it; it is not built in this repository.

ConsumerFields usedWhat it does
shopping-cartcartId, sessionIdRuns CloseOnCheckoutCompleted: OPEN → CHECKED_OUT, publishing CartCheckedOut (analytics).
customer-paymentssessionId, orderId, authorizationId, groupsRuns BindOrderOnCheckoutCompleted: binds the orderId to the session's authorization, then applies any parked fulfilment facts (gap S4).

Ordering. CheckoutCompleted is keyed by sessionId, not cartId and not orderId; per-session order holds, nothing more is promised across topics. Fulfilment facts for the new order may reach customer-payments before this event does; that consumer parks them until the bind (gap S4 on the Model Gap Register). A session publishes CheckoutCompleted at most once, because COMPLETED has no transition out (ErrSessionClosed); a redelivery carries the same id, so consumers de-duplicate on it.

Example envelope​

CheckoutCompleted, the one fact the cart and payments follow. This is the golden file the encoder test pins (shown re-indented):

{
"specversion": "1.0",
"id": "3f6c2a9e-8b1d-4c7a-9e55-0d2f6b7a1c40",
"source": "/retailnetwork/checkout",
"type": "com.retailnetwork.storefront.checkout.checkoutsession.CheckoutCompleted",
"subject": "sess-1",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:checkout:events:CheckoutCompleted:v1",
"time": "2026-10-23T10:15:30.123456Z",
"data": {
"sessionId": "sess-1",
"orderId": "order-1",
"shopperId": "shopper-1",
"cartId": "cart-1",
"authorizationId": "auth-1",
"currency": "USD",
"totalMinor": 2100,
"groups": [
{"groupNo": 1, "tier": "NEXT_DAY", "amountMinor": 1365},
{"groupNo": 2, "tier": "STANDARD", "amountMinor": 735}
],
"completedAt": "2026-10-23T10:15:30.123456Z"
}
}

Source: internal/adapters/outbound/kafka/testdata/CheckoutCompleted.golden.json (re-indented here), internal/adapters/outbound/kafka/payloads.go.

The event carries references only: shopperId, orderId and authorizationId. No address, name, e-mail or card data appears in any checkout event; the stored placement request that holds shipToAddressId never leaves the aggregate. The Kafka message also carries the content-type header and, when the request had a span, traceparent and tracestate.