Digital storefront · Generic domain · EventStorming board
customer-payments
Holds the shopper's money: authorizes the total at checkout, captures it as groups ship, releases it on cancellation and refunds lost or returned packages.
- events published
- 8
- commands
- 13
- policies
- 10
- read models
- 4
- hot spots
- 4
The story in 4 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventPayment
Authorized - Pivotal eventPayment
Captured - Pivotal eventPayment
Released - Pivotal eventRefund
Issued
Listens to (3): contexts whose events this one reacts to
Tells (0): contexts that react to its events
none
The board, row by row
14 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
-
Authorize a payment
Checkout asks for the quote total to be held on the shopper's payment method, split by shipment group. The payment provider's answer decides: held or declined. A session that already has a live hold gets it back unchanged.
ActorCheckout, for a shopperRead modelPayment provider's answerCommandAuthorizePayment POST /payment-authorizationsAggregatePaymentAuthorization EventPaymentAuthorized EventPaymentDeclined Source: application/usecases/authorization.go · domain/paymentauthorization/create.go
-
Cancel a hold that was never captured
Checkout cancels a hold before anything has been captured. The payment provider voids it and every amount still waiting is released.
ActorCheckout, for a shopperRead modelPayment provider's answerCommandVoidAuthorization POST /payment-authorizations/{authorizationId}/voidsAggregatePaymentAuthorization EventPaymentReleased Source: application/usecases/authorization.go · domain/paymentauthorization/commands.go
-
Tie the hold to the order
checkout reports that the order was placed. The order is attached to the hold, and any shipping or tracking news that arrived before the order was known is now applied.
SystemcheckoutEventCheckoutCompleted PolicyWhenever a checkout completes, bind its order to the hold and apply the facts that waitedRead modelFacts waiting for their orderCommandBindOrder started by the policyAggregatePaymentAuthorization Source: application/usecases/consume.go · domain/paymentauthorization/commands.go · adapters/inbound/kafka/handlers.go
-
Take the money when a group ships
order-sourcing says a shipment group has shipped. Its share of the hold is captured at the payment provider and the tracking numbers are kept. If the order is not tied yet, the news waits.
Systemorder-sourcing EventFulfillmentShipped PolicyWhenever a group ships, capture its share of the holdCommandCaptureOn started by the policyShipment AggregatePaymentAuthorization EventPaymentCaptured Read model · kept up to dateFacts waiting for their orderSource: application/usecases/facts.go · application/usecases/consume.go · domain/paymentauthorization/commands.go
-
Release the money of a cancelled group
order-sourcing says a group was cancelled. Its share of the hold is released and the hold at the payment provider shrinks, or is voided when nothing is left.
Systemorder-sourcing EventFulfillmentCancelled PolicyWhenever a group is cancelled, release its share of the holdCommandReleaseOn started by the policyCancellation AggregatePaymentAuthorization EventPaymentReleased Read model · kept up to dateFacts waiting for their orderSource: application/usecases/facts.go · application/usecases/consume.go · domain/paymentauthorization/commands.go
-
Release the money of a group nobody can fill
order-sourcing says no source can fulfil a group. It is handled like a cancellation: its share of the hold is released.
Systemorder-sourcing EventFulfillmentUnsourceable PolicyWhenever a group cannot be sourced, release its share of the holdCommandReleaseOn started by the policyCancellation AggregatePaymentAuthorization EventPaymentReleased Read model · kept up to dateFacts waiting for their orderSource: application/usecases/facts.go · application/usecases/consume.go · domain/paymentauthorization/commands.go
-
Refund a lost package
shipping-and-tracking says a package was lost. What was captured for the group that carried it goes back to the shopper, less anything already refunded.
Systemshipping-and- tracking EventPackageLost PolicyWhenever a package is lost, refund what was captured for its groupRead modelCaptured amount of the groupCommandRefundOn started by the policyLost Package AggregateRefundEventRefundIssued EventRefundFailed Source: application/usecases/facts.go · application/usecases/refund.go · domain/refund/refund.go
-
Refund a returned package
shipping-and-tracking says a package came back to the sender. What was captured for its group is refunded, less anything already refunded.
Systemshipping-and- tracking EventPackageReturned PolicyWhenever a package is returned, refund what was captured for its groupRead modelCaptured amount of the groupCommandRefundOn started by the policyReturn To Sender AggregateRefundEventRefundIssued EventRefundFailed Source: application/usecases/facts.go · application/usecases/refund.go · domain/refund/refund.go
-
Refund by hand
Operations request a refund for an order or one of its groups. It can never exceed what was captured. The payment provider is asked once; if it is unreachable the refund waits.
ActorStorefront operationsRead modelCaptured amount of the orderCommandRequestRefund POST /refundsAggregateRefundEventRefundIssued EventRefundFailed Source: application/usecases/refund.go · domain/refund/refund.go
-
Try a failed refund again
Operations send a failed refund back to the payment provider. A refund gets at most five attempts in all.
ActorStorefront operationsCommandRetryRefund POST /refunds/{refundId}/retriesAggregateRefundEventRefundIssued EventRefundFailed Source: application/usecases/refund.go · domain/refund/commands.go
-
Finish refunds left waiting
A sweep picks up refunds that sat requested for 30 seconds because the payment provider could not be reached, and asks the provider again.
TimeRefund sweepPolicyEvery sweep, any refund requested for over 30 seconds is sent to the provider againCommandProcessRequested started by the clockRefunds AggregateRefundEventRefundIssued EventRefundFailed Source: application/usecases/refund.go · cmd/api/policies.go
-
Renew a hold before it lapses
A sweep asks the payment provider for a fresh hold 24 hours before the old one ends. If the provider declines, or the hold already lapsed, the authorization expires and what was still waiting is released.
TimeHold sweepPolicyEvery sweep, a hold within 24 hours of its end is renewed or, failing that, expiredCommandReauthorizeBefore started by the clockExpiry AggregatePaymentAuthorization EventPaymentReauthorized EventPaymentAuthorization Expired EventPaymentDeclined EventPaymentReleased Source: application/usecases/policies.go · domain/paymentauthorization/commands.go · cmd/api/policies.go
-
Void holds nobody claimed
A hold that no completed checkout tied to an order within 24 hours is voided. It is the safety net behind checkout's own give-up.
TimeUnclaimed-hold sweepPolicyEvery sweep, a hold with no order after 24 hours is voidedCommandVoidUnbound started by the clockAuthorizations AggregatePaymentAuthorization EventPaymentReleased Source: application/usecases/policies.go · cmd/api/policies.go
-
Tidy the facts that never found an order
Facts still waiting for their order after 24 hours are escalated with an alert and never silently dropped. Facts older than 30 days are deleted.
TimeHousekeeping sweepPolicyEvery sweep, escalate facts waiting over 24 hours and purge those older than 30 daysCommandMaintainParked started by the clockFacts Read model · kept up to dateFacts waiting for their orderSource: application/usecases/policies.go · application/parked/parked.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 spotAll eight events are analytics-only. No other context reacts to a payment or refund event.
Source: docs/ddd/eventstorming.md
- Hot spotNo alerting on declines, waiting facts, unpublished events or failed refunds. Only error log lines flag them.
Source: docs/operations/observability.md
- Hot spotA lost package whose shipment news never arrived is never refunded automatically. Its fact waits 24 hours, then is escalated.
Source: docs/ddd/eventstorming.md
- Hot spotA provider outage longer than the 24-hour lead lets a hold lapse. The next pass expires it without asking the provider.
Source: docs/ddd/eventstorming.md
This board is a reconstruction from the code and documentation of customer-payments at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.