Skip to main content

Customer Payments

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.

Generic

Customer Payments (customer-payments, code CP, tier storefront) moves money with the shipment facts. checkout asks it for one PaymentAuthorization per checkout session, split into allocations (one per shipment group). From then on the money follows the network's facts, not storefront commands: a shipped group is captured (CaptureOnShipment), a cancelled group is released (ReleaseOnCancellation), a lost or returned package is refunded (RefundOnLostPackage, RefundOnReturnToSender), and uncaptured allocations are re-authorized before the provider's authorization validity runs out (ReauthorizeBeforeExpiry). Because the shipment facts can arrive before the order is bound to its authorization, they are parked and applied on CheckoutCompleted (gap S4). The context speaks to the payment provider only through an Anti-Corruption Layer port (Authorize, Capture, Void, Refund, Reauthorize); the payment-provider simulator is the stand-in adapter. It never sees a card number, only PSP tokens.

This context's pages​

PageWhat it holdsddd-crew tool it follows
Business ContextThe problem, actors, decisions, relation to real storefronts, out of scope(narrative)
Ubiquitous LanguageTerms, code identifiers, terms not to confuseBounded Context Canvas (UL section)
Core Domain ChartWhy this context is GenericCore Domain Charts
Bounded Context CanvasPurpose, classification, roles, inbound and outbound messages, decisions, metricsBounded Context Canvas v5
Context MapEvery neighbour, direction and pattern, including the provider ACLContext Mapping
Aggregate Design CanvasPaymentAuthorization and Refund: states, invariants, commandsAggregate Design Canvas v1.1
Domain EventsPublished and consumed CloudEvents, with an example envelopeDomain Message Flow Modelling (message catalogue)
Domain Message FlowAuthorize, capture on shipment, release, refund, parked factsDomain Message Flow Modelling
EventStormingProcess-level boards with hotspotsEventStorming glossary & cheat sheet
Use CasesOne section per command: trigger, flow, errors, events, idempotency(application layer, fleet convention)
Class DiagramDomain model and hexagonal ports and adapters (the model's design, with the as-built packages)(UML, fleet convention)
Entity RelationshipPostgres schema as built (migration 0001)(fleet convention)
Sequence DiagramsAdapter to Kafka and provider for every command use case(UML, fleet convention)

Service and operations​

  • Service: IQVO/customer-payments on develop (054b3de, checked 2026-12-02): binaries cmd/api, cmd/mcp, cmd/a2a; REST contract apis/openapi.yaml, event contract apis/asyncapi.yaml, schema in internal/adapters/outbound/postgres/migrations/ (see Entity Relationship). 8 ADRs (0001 to 0008), listed in the ADR index.
  • Configuration: mandatory at boot (the service exits naming the missing variable): DATABASE_URL, KAFKA_BROKERS, PAYMENT_PROVIDER_URL, CHECKOUT_CONSUMER_GROUP, ORDER_SOURCING_CONSUMER_GROUP, SHIPPING_AND_TRACKING_CONSUMER_GROUP. There is no in-memory mode. Packaging: the Helm chart charts/customer-payments (on develop and in v0.1.4) renders the api and, both default off, an mcp and an a2a component with their own Services, routes and probes.
  • Deployment: released at v0.1.4 (tag commit ac6e6b3, which carries cmd/api, cmd/mcp, cmd/a2a and the chart) and applied to the k3s cluster: warehouse-infra develop (d12d05f, checked 2026-12-02) registers customer-payments in terraform/apps.yaml (with a database) and configures it in helm-values/customer-payments.yaml, with a dashboard and alert rules. REST goes through Kong at /api/customer-payments; the helm values give the three consumer groups customer-payments-checkout, customer-payments-order-sourcing and customer-payments-shipping-and-tracking and point PAYMENT_PROVIDER_URL at the in-cluster payment-provider-simulator. The A2A agent is switched on (a2a.enabled: true) behind the route /api/a2a/customer-payments through the Agent Router (Envoy Gateway agent-router, warehouse-infra ADR 0014). Checked 2026-12-02: customer-payments-a2a at 1/1; the api deployment at 0/1, its pod Pending on the NotReady node k3s-agent2. The MCP server is not deployed: see MCP.
  • Observability: service ADR 0004, Adopt the fleet observability standard (logs, metrics, traces), Accepted (2026-10-26). Logs, metrics and traces leave over OTLP/gRPC (OTEL_EXPORTER_OTLP_ENDPOINT, code default localhost:4317; OTEL_SERVICE_NAME); a collector that is down only drops telemetry. The Tier-2 business counter is payments.authorizations.decided (unit {authorization}, in internal/adapters/outbound/telemetry/payment_metrics.go), with attribute outcome = authorized, declined or failed and reason on the outcomes that are not a success. The warehouse-infra dashboard terraform/dashboards/contexts/customer-payments.json shows the gateway, the logs and the Go runtime; it does not query the counter.
  • MCP: cmd/mcp is a read-only MCP server: the official Go SDK over Streamable HTTP, MCP_ADDR (default :8090), /mcp and an open /healthz, no auth (the in-cluster boundary is the access control). Four tools, every one L1 inform (reads, changes nothing; the pinned registry internal/adapters/inbound/mcp/testdata/tool_registry.golden.json carries _meta com.warehouse/authority: L1 and readOnlyHint on each): get_payment_authorization (one authorization by id: state, allocations per shipment group with their capture state and tracking numbers, expiry, decline reason), list_payment_authorizations (the authorizations of one order or of one checkout session, declined attempts included, at most 1000), get_refund (one refund by id: state, reason, attempts, last failure code) and list_refunds (the refunds of one order, at most 1000). Each mirrors its REST read through the same use case; authorizing, voiding, capturing, releasing and refunding have no tool. Service ADR 0007, Agent authority levels and complete MCP surface (Accepted 2026-11-02), completes the surface with one scoped resource, warehouse://customer-payments/orders/{orderId}/payment-status (every authorization and refund of one order), and one prompt, investigate_order_payment (an operator's investigation procedure), and makes the handler stateless. The chart's mcp component (port 8090, route /api/mcp/customer-payments through the Agent Router, rewritten to /mcp) is default off and helm-values/customer-payments.yaml sets no mcp block: the MCP server is registered in warehouse-infra and switched off, so it is not deployed.
  • A2A: cmd/a2a is a read-only A2A agent (service ADR 0005, A2A inbound adapter, Accepted 2026-10-30; first commit 108cf49): the official A2A Go SDK, JSON-RPC 2.0 over HTTP, A2A_ADDR (default :8093), A2A_AGENT_URL mandatory (the absolute URL the Agent Card advertises), the card at /.well-known/agent-card.json with name customer-payments, version from SERVICE_VERSION, provider IQVO, streaming: false and no security schemes; no auth. Two skills, both tagged authority:L1 (inform): get_payment_status (Where does a payment stand: the authorizations of one checkout session or one order, or one authorization by id, with allocations, expiry and decline reason) and get_refund_status (How did a refund go: the refunds of one order, or one refund by id, with reason, attempts and failure code). Both read through the GetAuthorization, ListAuthorizations, GetRefund and ListRefunds use cases the REST and MCP adapters use; nothing here authorizes, voids, captures or refunds, and no PSP token or payment instrument is exposed. A2A is delegation only: facts still travel as CloudEvents on Kafka. Route /api/a2a/customer-payments through the Agent Router (rewritten to /), a2a.enabled: true in warehouse-infra; applied to the k3s cluster, customer-payments-a2a at 1/1 checked 2026-12-02.
  • Payment provider: reached over HTTP at PAYMENT_PROVIDER_URL; in development and tests that is payment-provider-simulator.

Elsewhere​

  • REST contract: storefront/apis/customer-payments/openapi.yaml (a copy of the service's spec on develop), rendered under the API reference.
  • The storefront-wide Context Map, Subdomain Classification and Ubiquitous Language.
  • The Model Gap Register tracks gap S4 (event order across topics: fulfilment facts for an unbound order are parked and applied on CheckoutCompleted) and, on the checkout side, gap S3 (requote after authorization: void, then re-quote).
  • order-sourcing publishes the FulfillmentShipped and FulfillmentCancelled facts and shipping-and-tracking the PackageLost and PackageReturned facts that drive capture, release and refund (Conformist).
  • checkout calls AuthorizePayment and VoidAuthorization and publishes CheckoutCompleted; shopping-cart is the other consumer of that event.