Skip to main content

Domain events

Customer Payments publishes eight events on retailnetwork.customer-payments.events and consumes six from three topics. Field-by-field payloads, the CloudEvents envelope and an example message are on Events; this page shows how the events relate to the aggregates and flows.

Published​

EventAggregateRaised byReasons / variants
PaymentAuthorizedPaymentAuthorizationAuthorizePaymentnone
PaymentDeclinedPaymentAuthorizationAuthorizePayment, ReauthorizeBeforeExpiryprovider code (CARD_DECLINED ...) or REAUTH_DECLINED
PaymentCapturedPaymentAuthorizationcapture of a shipped groupnone
PaymentReleasedPaymentAuthorizationrelease of a group, or VoidAuthorizationCANCELLED, UNSOURCEABLE, VOIDED, EXPIRED
PaymentAuthorizationExpiredPaymentAuthorizationexpiry (lapsed hold or declined re-authorization)none
PaymentReauthorizedPaymentAuthorizationReauthorizeBeforeExpirynone
RefundIssuedRefundRequestRefund, RetryRefund, ProcessRequestedRefunds, lost / returned policiesreasons LOST, RETURNED_TO_SENDER, MANUAL
RefundFailedRefundsamefinal true on the fifth failed attempt

Subject and Kafka key: the authorizationId (payment events) or refundId (refund events). Types: com.retailnetwork.storefront.customer-payments.paymentauthorization.<Event> and ...refund.<Event>. Source: internal/domain/paymentauthorization/events.go, internal/domain/refund/events.go, internal/adapters/outbound/kafka/payloads.go.

Source: internal/application/usecases/authorization.go, facts.go, policies.go, refund.go.

Consumed​

EventTopicEffect
CheckoutCompletedretailnetwork.checkout.eventsbind the order, replay parked facts
FulfillmentShippedretailnetwork.order-sourcing.eventscapture the group
FulfillmentCancelled, FulfillmentUnsourceableretailnetwork.order-sourcing.eventsrelease the group
PackageLost, PackageReturnedretailnetwork.shipping-and-tracking.eventsrefund the group by tracking number

Source: internal/adapters/inbound/kafka/handlers.go.

Guarantees​

  • Publish: transactional outbox, at-least-once; the CloudEvents id is fixed when the row is written, so redelivery repeats the same id. Consumers must dedupe on it.
  • Order: per aggregate (key = subject, one partition); none across aggregates.
  • Consume: the inbox claim and the effect commit together; the offset is committed after.
  • Evolution: a breaking payload change is a new .v2 type; the dataschema is urn:retailnetwork:customer-payments:events:<EventName>:v1.