warehouse-systems fleet · executive briefing

customer-payments

Moves shopper money in step with what ships, gets cancelled or comes back
eight capabilitys8 events out · 6 in7 recorded decisions

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic. · November 2026

the short version · read this if nothing else

Customer payments charges only for what ships and refunds what is lost, with the provider behind one port

1

Money follows shipment facts: capture on ship, release on cancel, refund on loss or return.

2

The provider sits behind one port, so a real provider can replace the simulator cleanly.

3

It never sees a card number, only provider tokens; its agent and MCP tools can read, not move money.

The ask

Swap the payment-provider simulator for a real provider adapter behind the existing port.

why it exists

Shoppers should pay for what ships and get back what never arrives

Customer Payments moves money with the shipment facts: it authorizes the quote total at checkout, captures each shipment group's allocation when it ships, releases on cancellation, refunds lost or returned packages, and re-authorizes uncaptured allocations before the provider's authorization validity expires…

Today

It authorizes at checkout, captures per shipment group on shipping, and releases, refunds or re-authorizes as facts arrive.

The catch

A simulator stands in for a real provider, so partial captures, provider timeouts and reconciliation go untested.

what it does

Six money moves follow every order from checkout to refund

Authorize at checkout

Holds the quote total for each checkout session, or declines it.

Capture on shipment

Charges each shipment group's share only when it actually ships.

Release on cancellation

Frees held money when fulfilment is cancelled or cannot be sourced.

Refund lost or returned

Refunds lost or returned packages, never more than was charged.

Re-authorize before expiry

Renews uncaptured holds before the provider's authorization lapses.

Bind orders to payments

Links each completed checkout's order to its authorization and allocations.

who it talks to

It listens to three contexts and, so far, nobody listens back

LISTENS TO · 6 EVENT TYPESIS HEARD BY · 0 CONTEXTSorder-sourcing3shipping-and-tracking2checkout1No downstream consumer yetcustomerpaymentsbadge = event types on that edge · derived from the CloudEvents types each repo declares
the shared language

One authorization per checkout, split into allocations per shipment

THE LANGUAGEOF THE DOMAINPayment AuthorizationAllocationCaptureReleaseVoidRefundReauthorizationPSP Token
REST8 operations over 6 paths on :8080
MCPRead-only MCP server (cmd/mcp, :8090…
A2ARead-only A2A agent (cmd/a2a, :8093): skills…
how it is built

A hexagonal core with the provider behind one swappable port

DRIVERS · INBOUNDOUTBOUND · ADAPTERSREST API :80808 operations over 6 pathsMCP tools :8090Read-only MCP server…Kafka consumer · 6 eventsFulfillmentCancelledFulfillmentShippedDOMAIN COREPayment AuthorizationAllocationCaptureReleasePostgreSQLPostgreSQLKafka producer · 8 eventsPaymentAuthorizationExpiredPaymentAuthorizedTransactional outboxrelay · DLQ on x-dlq-*commands inevents inevents outstorage / infra
event traffic · CloudEvents 1.0 on Kafka

Six incoming facts trigger eight money outcomes

CONSUMED · BY SOURCE · 6PUBLISHED · BY ENTITY · 8order-sourcing 3shipping-and-tracking 2checkout 16 paymentauthorization2 refundFulfillmentCancelledFulfillmentShippedFulfillmentUnsourceablePackageLostPackageReturnedCheckoutCompletedPaymentAuthorizationExpiredPaymentAuthorizedPaymentCapturedPaymentDeclinedPaymentReauthorizedPaymentReleasedRefundFailedRefundIssued
how we know it is healthy

Dead-letter topics and idempotent provider keys make retries safe

OpenTelemetry SDK -> OTLP/gRPC -> in-cluster Collector -> Jaeger (traces) and Prometheus (metrics); stdout JSON logs shipped by Alloy to Loki (fleet observability standard ADR)

What we watch

  • /healthz (liveness) and /readyz (readiness dials Postgres and Kafka) probes per binary
  • OTLP/gRPC trace + metric export that never blocks the request path (collector outage costs telemetry, not traffic)
  • stdout JSON structured logs collected via Alloy to Loki
  • inbound requestlog adapter records every API request

What stops a bad change

  • make check / check-all (fmt + vet + golangci-lint + unit + coverage)
  • coverage gate >= 90% on domain + application packages
  • make arch-test (arch-go hexagonal fitness functions)
  • make mutation / mutation-full (gremlins gate, thresholds efficacy 85, mutant-coverage 85: below the 99/99 fleet standard)
by the numbers

Seven decisions and five feature files back two lean aggregates

7
Architecture decisions
#40 of 45 in the fleet
1
DB migrations
#32 of 45 in the fleet
5
BDD feature files
#40 of 45 in the fleet
8
Events published
#14 of 45 in the fleet

Ranked against all 45 briefed repositories (dot = one repository, highest on the left).

One-command workflows (make)

helpbuildvetfmtfmt-checklinttestcoverageintegrationbddarch-testmutationmutation-fullvuln
what comes next

Next: a real provider, reconciliation, a first release, stronger gates

NOW1Swap in a realpayment providerSwap thepayment-provider-simulatorfor a real PSP adapterbehind the existingAuthorize/Capture/Void/Refund/ReauthorizeportNEXT2Add a providerreconciliationreportAdd a provider-statementreconciliation report(authorizations vscaptures vs refunds) tothe ops runbookNEXT3Ship the checklistand tag a firstreleaseShip thebefore-first-releasechecklist and tag thefirst release (REST specis 0.1.0)LATER4Raise the mutationgate to the 99/99standardRaise the mutation gatefrom efficacy 85 /mutant-coverage 85 tothe 99/99 fleet standard(.gremlins.yaml:30-31)LATER5Move theparked-facts gaugeonto OTelMove the parked-factsgauge onto the OTelpipeline and add anoutbox-lag instrument:the gauge is ahand-written /metricsendpoint and noqueue-depth or …
what could go wrong · and what we do about it

The simulator hides how a real provider will misbehave

A simulator stands in for the real provider

The simulator stands in for a real PSP: partial captures, provider timeouts and webhook-style reconciliation are unexercised

→

Swap in a real provider adapter behind the existing Authorize, Capture, Void, Refund, Reauthorize port.

A missed logistics event can strand held money

Money moves on consumed facts - a missed logistics event strands allocations until the expiry / reauthorization policy catches them

→

Expiry and re-authorization policies catch stranded allocations; a reconciliation report is planned.

A provider outage leaves refunds to manual retries

Refunds cap at 5 attempts with an over-refund invariant; a PSP outage leaves operator-driven REST retries as the only path

→

Operators can retry over REST, and deterministic provider keys keep those retries idempotent.

No authentication; authority levels are labels, by decision

Every REST, MCP and A2A endpoint is unauthenticated by decision (fleet-wide auth revert 2026-09-11, TestNoAuthMiddlewareReintroduced)…

→

No mitigation on the roadmap yet: this one needs an owner.

the decision we need

Swap the payment-provider simulator for a real provider adapter behind the existing port.

WHAT ISIt authorizes at checkout, capturesper shipment group on shipping, andreleases, refunds or re-authorizesas facts arrive.THE CATCHA simulator stands in for a realprovider, so partial captures,provider timeouts and reconciliationgo untested.WHAT COULD BEReal provider flows exercised end toend, a reconciliation report in therunbook, a first tagged release andmoney metrics in OTel.
Why it matters

Customer payments charges only for what ships and refunds what is lost, with the provider behind one port

appendix · for the engineers in the room

The fine print: how it is put together

StyleHexagonal (ports and adapters) with two aggregates (PaymentAuthorization, Refund), event-driven policies, transactional outbox + inbox, PSP Anti-Corruption Layer
Layoutcmd/{api (REST :8080, outbox relay, 3 consumer groups, clock-driven policy loop), mcp (read-only MCP :8090), a2a (agent :8093)}…
StoragePostgreSQL (payment_authorization + refund aggregates, transactional outbox, inbox, idempotency; golang-migrate) + Kafka (produces 8 event types…
TestingUnit tests over domain, use cases and adapters (httptest over the real chi router), godog BDD (5 feature files), repository-contract suite, golden CloudEvents…
REST8 operations over 6 paths on :8080: /payment-authorizations, /payment-authorizations/{authorizationId}…
Go 1.27chiPostgreSQL + pgx v5KafkaCloudEvents 1.0MCP go-sdka2a-goOpenTelemetrygodog Cucumber BDDtestcontainers