Skip to main content

Events

The event catalogue of Customer Payments, per apis/asyncapi.yaml and the code. Every message is a CloudEvents 1.0 event in structured content mode (ADR 0003).

Envelope​

AttributeValue
Kafka header content-typeapplication/cloudevents+json; charset=UTF-8
specversion1.0
idUUID v4, minted once when the event is encoded and stored with the outbox row, so a relay retry republishes the same id
source/retailnetwork/customer-payments
typecom.retailnetwork.storefront.customer-payments.<entity>.<EventName>; <entity> is paymentauthorization or refund
subjectthe authorizationId (payment events) or the refundId (refund events); it is also the Kafka message key, so one aggregate's events stay ordered on one partition
datacontenttypeapplication/json
dataschemaurn:retailnetwork:customer-payments:events:<EventName>:v1
timethe domain occurrence time, UTC
datacamelCase JSON; instants RFC 3339 UTC; amounts integer minor units; optional fields omitted when absent, never null; arrays always present

A breaking payload change is a new .v2 type, never a mutation. Source: internal/adapters/kafka/cloudevents/cloudevents.go, internal/adapters/outbound/kafka/encoder.go.

Example (the golden file testdata/PaymentAuthorized.golden.json):

{"specversion":"1.0","id":"7a2c9e41-5f0b-4c3d-9e6a-1b8d4f0c2a55","source":"/retailnetwork/customer-payments","type":"com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentAuthorized","subject":"pay-1","datacontenttype":"application/json","dataschema":"urn:retailnetwork:customer-payments:events:PaymentAuthorized:v1","time":"2026-10-24T09:00:00.123456Z","data":{"authorizationId":"pay-1","checkoutSessionId":"cs-1","currency":"BRL","totalMinor":10000,"allocations":[{"groupNo":1,"amountMinor":7000},{"groupNo":2,"amountMinor":3000}],"expiresAt":"2026-10-31T09:00:00.123456Z"}}

Besides the CloudEvents attributes, the relay publishes the W3C traceparent / tracestate headers stored with the outbox row (see Observability).

Published: retailnetwork.customer-payments.events​

Written through the transactional outbox (state and encoded events in one database transaction, then an always-on relay, at-least-once). The asyncapi document states that every published event is analytics-only for its consumers: no sibling context reacts to them.

EventRaised whendata fieldsRaised by
PaymentAuthorizedthe provider approved the holdauthorizationId, checkoutSessionId, currency, totalMinor, allocations[] (groupNo, amountMinor), expiresAtAuthorizePayment
PaymentDeclinedthe provider declined an authorization, or a re-authorization (reason = REAUTH_DECLINED)authorizationId, checkoutSessionId, reason (the provider's decline code, e.g. CARD_DECLINED), atAuthorizePayment, ReauthorizeBeforeExpiry
PaymentCaptureda group's allocation was capturedauthorizationId, orderId (omitted if absent), groupNo, amountMinorConsumer.ApplyFact (FulfillmentShipped)
PaymentReleasedan allocation was let go; reason is CANCELLED, UNSOURCEABLE, VOIDED or EXPIREDauthorizationId, orderId (omitted), groupNo, amountMinor, reasonConsumer.ApplyFact (FulfillmentCancelled, FulfillmentUnsourceable), VoidAuthorization (one event per allocation)
PaymentAuthorizationExpiredthe hold lapsed with money still uncapturedauthorizationId, orderId (omitted), expiredAtReauthorizeBeforeExpiry
PaymentReauthorizedthe hold was renewed before expiryauthorizationId, orderId (omitted), expiresAt, providerAuthorizationIdReauthorizeBeforeExpiry
RefundIssuedthe provider returned the moneyrefundId, orderId, authorizationId, groupNo (omitted for an order-level refund), amountMinor, reason (LOST, RETURNED_TO_SENDER, MANUAL)RequestRefund, RetryRefund, ProcessRequestedRefunds, the lost / returned policies
RefundFailedthe provider refused the refundrefundId, orderId, authorizationId, groupNo (omitted), code, attempts, final (true on the fifth failed attempt)same as RefundIssued

The Go types are in internal/domain/paymentauthorization/events.go and internal/domain/refund/events.go; the wire payloads in internal/adapters/outbound/kafka/payloads.go. The golden files cover the eight types plus the variants PaymentReleasedUnbound (no orderId) and RefundIssuedManual.

A second, non-CloudEvents topic exists for operators: retailnetwork.customer-payments.unbound-facts.dlq carries a plain JSON copy of a fulfilment fact whose order stayed unbound for 24 h (see the Runbook); it is not part of the asyncapi contract.

Consumed​

Dispatch is on the full type; unknown types are logged and skipped; duplicates are dropped by the inbox on the CloudEvents id. Only the fields the service reads are listed; unknown fields are ignored.

TopicEvent typeFields readEffect
retailnetwork.checkout.eventscom.retailnetwork.storefront.checkout.checkoutsession.CheckoutCompletedsessionId, orderId, authorizationIdbinds the order to the authorization, then applies the parked facts of that order
retailnetwork.order-sourcing.eventscom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedorderId, groupNo, trackingNumbers, shippedAtcapture the group's allocation, store the tracking numbers
retailnetwork.order-sourcing.events...assignment.FulfillmentCancelledorderId, groupNorelease the allocation (CANCELLED)
retailnetwork.order-sourcing.events...assignment.FulfillmentUnsourceableorderId, groupNorelease the allocation (UNSOURCEABLE)
retailnetwork.shipping-and-tracking.eventscom.retailnetwork.logistics.shipping-and-tracking.journey.PackageLostorderId, trackingNumberrefund the captured amount of the group that carried the tracking number (LOST)
retailnetwork.shipping-and-tracking.events...journey.PackageReturnedorderId, trackingNumberthe same, reason RETURNED_TO_SENDER

The type strings are constants in internal/adapters/inbound/kafka/handlers.go. Failure handling (retry, five attempts, <topic>.dlq) is described in the Runbook. Per-event integration notes: Integration.