Skip to main content

Bounded Context Canvas

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.

Following the ddd-crew Bounded Context Canvas v5. Every message row comes from contexts[customer-payments] (inbound, consumes, publishes, rest, sync_calls) or from a neighbour's entry that names this context.

Canvas at a glance​

Two pictures of the sections below, laid out like the ddd-crew canvas: first the inbound collaborators feeding this context (purpose, domain roles and the business decisions it enforces), then the outbound collaborators it calls and notifies. Arrows follow the message type: solid blue commands (cmd), dotted green queries (qry), thick orange events (evt); each arrow names its channel and the messages it carries. Box shapes mark the collaborator kind: rounded = people, UI or any client; blue = sibling bounded context; red = network context. Channel names on the arrows are abbreviated; the Inbound and Outbound Communication tables carry the exact route, topic and CloudEvents type for every message.

Inbound​

Outbound​

Derived from: model.yaml → contexts[customer-payments].inbound, .publishes, .consumes, .sync_calls, .purpose, .roles, .business_decisions; contexts[checkout].sync_calls (AuthorizePayment, VoidAuthorization) and .publishes (CheckoutCompleted consumer row); external[payment-provider].

The diagrams omit assumptions, verification metrics, open questions and the ubiquitous language (sections below) and the relationship pattern per message (see the tables). The synchronous replies to checkout and storefront ops, and the provider's answers, are the only synchronous traffic. The AI clients collaborator is as built (cmd/mcp and cmd/a2a, service ADRs 0007 and 0005): the model has no agent row, and the agent surface is the four reads only.

Name​

Customer Payments (customer-payments, code CP, CloudEvents tier storefront).

Purpose​

To move money with the shipment facts. The context:

  • authorizes the quote total once per checkout session, split into one allocation per shipment group, with a PSP token and never a card number;
  • captures a group's allocation when the group ships (CaptureOnShipment), and stores the tracking number against the group;
  • releases a group's allocation when the group is cancelled (ReleaseOnCancellation) and voids an authorization before any capture;
  • refunds the captured amount of a group whose package is lost or returned (RefundOnLostPackage, RefundOnReturnToSender), or on a manual ops request;
  • re-authorizes uncaptured allocations 24 h before expiresAt (ReauthorizeBeforeExpiry) and voids an authorization that no CheckoutCompleted bound within 24 h (VoidUnboundAuthorizations);
  • parks fulfilment facts for orders not yet bound to an authorization and applies them on BindOrderOnCheckoutCompleted (gap S4).

Strategic Classification​

AxisVerdict
DomainGeneric subdomain. See the Core Domain Chart.
Business ModelRevenue collection (buy a PSP).
EvolutionCommodity.

Domain Roles​

RoleApplies?Evidence in the model
Execution (authorize, capture, void, refund)Yes, primaryThe PaymentAuthorization and Refund aggregates and the five provider verbs; ErrOverCapture and ErrOverRefund guard the money moving.
Enforcer (never two holds for one session)YesErrDuplicateAuthorization: one authorization per checkout session; a sequential replay returns the existing one (200), the error is raised only on the concurrent-insert race (409).
AnalysisNoThe only read model, ParkedFulfillmentFacts, holds facts to apply, not a verdict others consume.
SpecificationNoThe amounts are decided by pricing and carried by checkout; this context never computes a price.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
checkoutAuthorizePaymentCommandREST POST /payment-authorizationsCustomer/Supplier (we are the Supplier)
checkoutVoidAuthorizationCommandREST POST /payment-authorizations/{authorizationId}/voidsCustomer/Supplier (we are the Supplier)
checkoutGetAuthorizationQueryREST GET /payment-authorizations/{authorizationId}Customer/Supplier (we are the Supplier)
Storefront ops (human)RequestRefundCommandREST POST /refundsUI
Storefront ops (human)ListAuthorizationsQueryREST GET /payment-authorizations?orderId=|checkoutSessionId=UI
Storefront ops (human)ListRefundsQueryREST GET /refunds?orderId=UI
AI clients (agents; as built, not in the model)GetAuthorization, ListAuthorizations, GetRefund, ListRefundsQuery, the A2A delegation entriesMCP tools get_payment_authorization, list_payment_authorizations, get_refund, list_refunds at /api/mcp/customer-payments (switched off in warehouse-infra); A2A skills get_payment_status, get_refund_status at /api/a2a/customer-payments through the Agent Router (deployed)Open Host Service, read-only, L1 inform
checkoutCheckoutCompletedEventKafka retailnetwork.checkout.events, com.retailnetwork.storefront.checkout.checkoutsession.CheckoutCompletedCustomer/Supplier (we are the Customer)
order-sourcing (network)FulfillmentShippedEventKafka retailnetwork.order-sourcing.events, com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedConformist
order-sourcing (network)FulfillmentCancelledEventKafka retailnetwork.order-sourcing.events, com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentCancelledConformist
shipping-and-tracking (network)PackageLostEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.journey.PackageLostConformist
shipping-and-tracking (network)PackageReturnedEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.journey.PackageReturnedConformist

Route-to-command note: the six rest routes map onto the commands and queries above, with two exceptions that are by design. CaptureAllocation, ReleaseAllocation, ExpireAuthorization, ReauthorizePayment, BindOrder and RecordRefundOutcome have no route: they arrive through events, policies and provider answers, never as REST writes. RequestRefund is both the ops route and the command the two refund policies issue. As built, the four MCP tools and the two A2A skills are the same four reads (GetAuthorization, ListAuthorizations, GetRefund, ListRefunds), served by two read-only binaries (cmd/mcp, cmd/a2a); no agent surface authorizes, voids, captures, releases or refunds.

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
payment-provider (external)Authorize, Capture, Void, Refund, ReauthorizeCommandProvider port (ACL); the adapter calls the payment-provider simulatorAnti-Corruption Layer; we are the Customer of an external system
analytics onlyPaymentAuthorizedEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentAuthorizedanalytics stream
analytics onlyPaymentCapturedEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentCapturedanalytics stream
analytics onlyPaymentReleasedEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentReleasedanalytics stream
analytics onlyPaymentAuthorizationExpiredEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentAuthorizationExpiredanalytics stream
analytics onlyPaymentDeclinedEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.paymentauthorization.PaymentDeclinedanalytics stream
analytics onlyRefundIssuedEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.refund.RefundIssuedanalytics stream
analytics onlyRefundFailedEventKafka retailnetwork.customer-payments.events, com.retailnetwork.storefront.customer-payments.refund.RefundFailedanalytics stream

What the neighbours do with them: nobody in the storefront or the network consumes a payment event. All seven are analytics-only, so retailnetwork.customer-payments.events carries nothing (open question below). checkout learns the outcome of an authorize from the synchronous reply (AUTHORIZED or DECLINED) and the order reaches the authorization through CheckoutCompleted. The model names the future customer-notifications context as the first consumer of PaymentCaptured, PaymentReleased and RefundIssued. Relationship evidence: Context Map.

Ubiquitous Language​

Full glossary: Ubiquitous Language. Top terms: Payment Authorization, Capture (not the authorize hold), Release (one allocation; not Void, the whole authorization), Refund (captured money back), Reauthorization, Payment Method Token (never a card number).

Business Decisions​

  1. One authorization per checkout session; a replayed authorize returns the existing one (ErrDuplicateAuthorization).
  2. Allocations sum to the authorized total and name the session's groups (ErrAllocationMismatch); a capture or release names an existing group (ErrUnknownGroup).
  3. Capture is per allocation (shipment group): captured per group never exceeds the allocation (ErrOverCapture), and no capture follows expiresAt (ErrCaptureAfterExpiry). Targets: zero captures without FulfillmentShipped, zero expired authorizations on shipped groups.
  4. Refunds of an order never exceed its captured total (ErrOverRefund).
  5. Fulfilment facts for a not-yet-bound order are parked and applied on BindOrderOnCheckoutCompleted (gap S4).
  6. Provider idempotency keys are deterministic per (operation, authorizationId, groupNo).
  7. A declined authorize is a terminal record; the checkout session stays open for another token (DECLINED has no transition into it).

Assumptions​

  • checkout mints <sessionId>:auth:<authAttempt> and <sessionId>:void as the Idempotency-Key of its two writes (checkout's sync_calls notes); a replay of the same key returns the stored response of the first call.
  • checkout calls VoidAuthorization only after a definitive rejection of the place-order step, never while the outcome is in doubt.
  • The PSP token arrives in the authorize request (paymentMethodToken in the REST contract); the context never receives card data.
  • The provider honours the idempotency key it is given, which is what makes a retried capture or refund safe.
  • Every consumed event is applied once (inbox on the CloudEvents id), and consumers dispatch on the full type string.
  • One configured currency everywhere; money is {amountMinor, currency}.
  • The simulator's deterministic outcomes per test token (approve, decline, timeout, expire-early) are the only provider behaviour the study exercises.

Verification Metrics​

MetricTarget (proposed)Source
Captures without a matching FulfillmentShipped0 (model correctness target)PaymentCaptured joined to consumed shipment facts
Shipped groups whose authorization expired uncaptured0 (model correctness target)PaymentAuthorizationExpired against shipped groups
Authorize decline ratetracked; separates declines from provider outagesPaymentDeclined / PaymentAuthorized
Provider call latency (p95) and timeout rate per verbtracked; alert on a drop in successadapter metrics
Authorizations AUTHORIZED within 24 h of expiresAt and not yet re-authorized0payment_authorizations.expires_at vs ReauthorizeBeforeExpiry run
Authorizations with no orderId older than 24 h0 after VoidUnboundAuthorizationspayment_authorizations.order_id
Parked facts waiting for a bindtracked; the age of the oldest parked factparked_facts.received_at
Refunds REQUESTED and not settledtracked; oldest agerefunds.state
Outbox age of the oldest unpublished payment eventbelow 5 soutbox_events.created_at

Open Questions​

  • ReauthorizePayment and VoidAuthorization publish nothing. Both are commands of PaymentAuthorization, but no event names them, and the model does not say how a reauthorization is recorded (expiresAt, provider reference, the new hold's validity). Hotspot H1 on EventStorming.
  • Nothing triggers ExpireAuthorization. The command and its two transitions exist, but no policy, inbound row or provider callback says what raises it (hotspot H2).
  • What is the state after every allocation is released? ReleaseAllocation has no row in transitions, AUTHORIZED → CAPTURED is missing for a one-group authorization, and CAPTURED is not defined for a mix of captured and released groups (hotspot H3).
  • The provider port has no partial release. The five verbs are Authorize, Capture, Void, Refund, Reauthorize; releasing one allocation of a multi-group authorization has no provider verb (hotspot H4).
  • FulfillmentCancelled and an unsourceable group. The policy ReleaseOnCancellation says the event covers a customer cancellation or an unsourceable group; the network publishes a separate FulfillmentUnsourceable event that this context does not consume; the reason field of PaymentReleased has no named values either (hotspot H5).
  • Lost and returned packages name a tracking number, not a group. The model says the tracking number is stored against the group on capture, but no value object holds it (hotspot H6).
  • retailnetwork.customer-payments.events carries nothing. All seven events are analytics-only; the future customer-notifications context would be the first consumer (hotspot H9).