Skip to main content

Domain Events

Released at v0.1.4, applied to the k3s cluster

Derived from model/model.yaml. The customer-payments service is built on develop (IQVO/customer-payments at 054b3de, checked 2026-12-02), released at v0.1.4 and applied to the k3s cluster: the api and the A2A agent are deployed, the MCP server is registered in warehouse-infra and switched off. Every Err... name, REST route and CloudEvents type of this context named on this page exists in the service; where the built service differs from the model's design, the page says so (As built) or the context's Service and operations section lists it.

Every event this context publishes and consumes, from contexts[customer-payments].publishes and .consumes, with the producer's entry for each consumed event. The domain-wide rules are on Event standard: CloudEvents.

Envelope​

Every Kafka message is a CloudEvents 1.0 event in structured JSON mode (conventions.cloudevents):

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/customer-payments
typecom.retailnetwork.storefront.customer-payments.<entity>.<EventName> (tier storefront; entity paymentauthorization or refund from the publishes rows)
subjectthe aggregate root id (authorizationId or refundId)
timethe instant the fact happened, UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:customer-payments:events:<EventName>:v1
Kafka topicas built retailnetwork.customer-payments.events for every event (service ADR 0003, TopicEvents in internal/adapters/outbound/kafka/payloads.go); there is no .analytics topic. Every published event is still analytics-only (no integration consumer), so this departs from conventions.integration_rules, which routes analytics-only events to .analytics
Kafka keythe subject: authorizationId for authorization events, refundId for refund events, so one aggregate's events stay on one partition and in order

No payment event carries a card number, a PSP token or any shopper data: the payloads hold ids, amounts, reasons and timestamps only (meta.hard_boundary).

Published​

Every event is written to outbox_events in the same transaction as the aggregate save, and a relay publishes it. All eight events name their consumers as "analytics only" by design: they go to the .analytics topic and no storefront or network context subscribes to a payment fact (Context Map).

PaymentAuthorized​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentAuthorized
Topicretailnetwork.customer-payments.events
Subject / keyauthorizationId
Dataschemaurn:retailnetwork:customer-payments:events:PaymentAuthorized:v1
Producing command / use caseAuthorizePayment (accepted by the provider)
Consumersanalytics only
FieldTypeMeaning
authorizationIdstringThe new authorization.
checkoutSessionIdstringThe session it belongs to (unique).
currencystringThe configured ISO 4217 currency.
totalMinorintegerThe authorized total in minor units.
allocationsarrayOne entry per shipment group: groupNo and amountMinor.
expiresAttimestampWhen the provider's authorization stops being honoured.

PaymentReauthorized​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentReauthorized
Topicretailnetwork.customer-payments.events
Subject / keyauthorizationId
Dataschemaurn:retailnetwork:customer-payments:events:PaymentReauthorized:v1
Producing command / use caseReauthorizePayment (the ReauthorizeBeforeExpiry policy, 24 h before expiresAt); the state stays AUTHORIZED
Consumersanalytics only
FieldTypeMeaning
authorizationIdstringThe authorization that was re-authorized.
orderIdstringThe order the authorization is bound to.
expiresAttimestampThe new expiry of the provider's hold.
providerAuthorizationIdstringThe provider's id of the new hold (the design called it providerRef).

PaymentCaptured​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentCaptured
Topicretailnetwork.customer-payments.events
Subject / keyauthorizationId
Dataschemaurn:retailnetwork:customer-payments:events:PaymentCaptured:v1
Producing command / use caseCaptureAllocation (the CaptureOnShipment policy on FulfillmentShipped)
Consumersanalytics only (the future customer-notifications context would consume it)
FieldTypeMeaning
authorizationIdstringThe authorization captured from.
orderIdstringThe order bound to it.
groupNointegerThe shipment group whose allocation was captured.
amountMinorintegerThe captured amount in minor units.

PaymentReleased​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentReleased
Topicretailnetwork.customer-payments.events
Subject / keyauthorizationId
Dataschemaurn:retailnetwork:customer-payments:events:PaymentReleased:v1
Producing command / use caseReleaseAllocation (ReleaseOnCancellation on FulfillmentCancelled, ReleaseOnUnsourceable on FulfillmentUnsourceable) or VoidAuthorization (reason VOIDED)
Consumersanalytics only (the future customer-notifications context would consume it)
FieldTypeMeaning
authorizationIdstringThe authorization the allocation belongs to.
orderIdstringThe order bound to it.
groupNointegerThe group whose allocation was released.
amountMinorintegerThe released amount in minor units.
reasonstringWhy it was released: CANCELLED, UNSOURCEABLE, VOIDED or EXPIRED.

PaymentAuthorizationExpired​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentAuthorizationExpired
Topicretailnetwork.customer-payments.events
Subject / keyauthorizationId
Dataschemaurn:retailnetwork:customer-payments:events:PaymentAuthorizationExpired:v1
Producing command / use caseExpireAuthorization (raised when a provider decline on re-authorization moves the authorization to EXPIRED)
Consumersanalytics only
FieldTypeMeaning
authorizationIdstringThe authorization that expired.
orderIdstringThe order bound to it.
expiredAttimestampWhen the expiry was recorded.

PaymentDeclined​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentDeclined
Topicretailnetwork.customer-payments.events
Subject / keyauthorizationId (the DECLINED record's root id, repeated in the payload)
Dataschemaurn:retailnetwork:customer-payments:events:PaymentDeclined:v1
Producing command / use caseAuthorizePayment (declined by the provider; the DECLINED record is saved), or ReauthorizePayment (reason REAUTH_DECLINED; the authorization moves to EXPIRED)
Consumersanalytics only
FieldTypeMeaning
authorizationIdstringThe authorization record (the DECLINED row for a declined authorize).
checkoutSessionIdstringThe session whose authorize was declined; it stays open for another token.
reasonstringThe decline reason, translated by the ACL, or REAUTH_DECLINED.
attimestampWhen the decline happened.

RefundIssued​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.refund.RefundIssued
Topicretailnetwork.customer-payments.events
Subject / keyrefundId
Dataschemaurn:retailnetwork:customer-payments:events:RefundIssued:v1
Producing command / use caseRecordRefundOutcome (REQUESTED → SUCCEEDED)
Consumersanalytics only (the future customer-notifications context would consume it)
FieldTypeMeaning
refundIdstringThe refund.
orderIdstringThe order refunded.
groupNointegerThe shipment group refunded.
authorizationIdstringThe authorization the money was captured from.
amountMinorintegerThe refunded amount in minor units.
reasonstringLOST, RETURNED_TO_SENDER or MANUAL.

RefundFailed​

ItemValue
Full typecom.retailnetwork.storefront.customer-payments.refund.RefundFailed
Topicretailnetwork.customer-payments.events
Subject / keyrefundId
Dataschemaurn:retailnetwork:customer-payments:events:RefundFailed:v1
Producing command / use caseRecordRefundOutcome (REQUESTED → FAILED); the refund is then retryable by RetryRefund, max 5 attempts
Consumersanalytics only
FieldTypeMeaning
refundIdstringThe refund.
orderIdstringThe order whose refund failed.
authorizationIdstringThe authorization whose capture was being refunded.
groupNointegerThe shipment group of the refunded capture.
codestringThe failure code, translated by the ACL.
attemptsintegerHow many provider attempts were made so far.
finalbooleantrue when the retries are exhausted and no further attempt follows.

Consumed​

Every consumer is idempotent on the CloudEvents id: the id is inserted into processed_events in the same transaction as the effect, and a duplicate is acknowledged without effect. Consumers dispatch on the full type string, never on a suffix. Consumer group names come from mandatory environment variables (CHECKOUT_CONSUMER_GROUP, ORDER_SOURCING_CONSUMER_GROUP, SHIPPING_AND_TRACKING_CONSUMER_GROUP; the service refuses to start without them); the names the design suggests: customer-payments.checkout, customer-payments.order-sourcing, customer-payments.shipping-and-tracking.

From checkout (retailnetwork.checkout.events, Customer/Supplier)​

EventFull typeFields usedWhat this context does
CheckoutCompletedcom.retailnetwork.storefront.checkout.checkoutsession.CheckoutCompletedsessionId, orderId, authorizationId, groupsRuns BindOrderOnCheckoutCompleted: binds orderId to the authorization, then applies any parked fulfilment facts for that order.

From order-sourcing (retailnetwork.order-sourcing.events, Conformist)​

EventFull typeFields usedWhat this context does
FulfillmentShippedcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedorderId, groupNo, trackingNumbersRuns CaptureOnShipment: captures that group's allocation (PaymentCaptured) and stores the tracking number on the group's allocation. Parked if the order is not yet bound.
FulfillmentCancelledcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelledorderId, groupNo, reasonRuns ReleaseOnCancellation: releases that group's allocation (PaymentReleased, reason CANCELLED). Parked if the order is not yet bound.
FulfillmentUnsourceablecom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceableorderId, groupNo, reasonRuns ReleaseOnUnsourceable: releases that group's allocation (PaymentReleased, reason UNSOURCEABLE). Parked if the order is not yet bound.

From shipping-and-tracking (retailnetwork.shipping-and-tracking.events, Conformist)​

EventFull typeFields usedWhat this context does
PackageLostcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageLostorderId, trackingNumberRuns RefundOnLostPackage: refunds the affected group's captured amount (found by tracking number), reason LOST. Parked if the order is not yet bound.
PackageReturnedcom.retailnetwork.logistics.shipping-and-tracking.journey.PackageReturnedorderId, trackingNumberRuns RefundOnReturnToSender: refunds the affected group's captured amount (found by tracking number), reason RETURNED_TO_SENDER. Parked if the order is not yet bound.

Ordering. The three topics have no order between them (gap S4). CheckoutCompleted is keyed by sessionId upstream, FulfillmentShipped, FulfillmentCancelled and FulfillmentUnsourceable by the assignment, and PackageLost and PackageReturned by the tracking number, so nothing links an order's facts across topics. A fact whose orderId is not bound to an authorization yet is stored in ParkedFulfillmentFacts and applied on the bind; the inbox on the CloudEvents id makes a redelivery safe, and the aggregate refuses what the state does not allow (ErrOverCapture, ErrCaptureAfterExpiry, ErrOverRefund). Parked facts are retained 30 days and then purged, and a gauge reports the parked count, so an order that never binds cannot grow the table without bound.

Example envelope​

PaymentCaptured, the event the correctness target measures (all ids synthetic):

{
"specversion": "1.0",
"id": "b5d2c9a0-71e4-4c38-a6f1-0d3e8b7c5a92",
"source": "/retailnetwork/customer-payments",
"type": "com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentCaptured",
"subject": "auth-7c1e2a",
"time": "2026-10-26T14:03:09Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:customer-payments:events:PaymentCaptured:v1",
"data": {
"authorizationId": "auth-7c1e2a",
"orderId": "ord-90f4d1",
"groupNo": 1,
"amountMinor": 4290
}
}

No card number, token or shopper reference appears in any payment event: the events carry ids and amounts only, and the PSP token never leaves the provider port (conventions.no_auth — the storefront stores no PII).