Architecture Pattern Guide

Trust, Evidence, and Controlled State Transitions

Goal

Start the walkthrough with the problem that makes finance architecture different: a system must control every meaningful state change and preserve enough evidence to explain it later.

The durable idea is:

Payments architecture starts with trusted evidence and controlled transitions, because every step can affect money, records, and reconciliation.

The Short Version

A customer sees one checkout action. The platform sees a sequence of financial decisions that can happen at different times:

requested -> authorized -> captured -> settled -> reconciled
                  |            |
                  |            +-> refunded / disputed
                  +-> expired / voided

These labels are not interchangeable. An authorization can indicate that a provider accepted a request and may have reserved funds. Capture asks the provider to complete the charge. Settlement records later movement through provider or banking processes. Reconciliation compares that external evidence with the platform's records.

The system therefore needs more than a paid = true flag. It needs an explicit state model, rules for allowed transitions, stable operation identifiers, timestamps, actor identity, provider correlation, amounts and currency, and the reason for any correction.

The exact legal and accounting treatment depends on the business and jurisdiction. The architecture lesson is provider-neutral: do not allow important financial meaning to hide inside a generic status field or an untraceable API response.

Model The Transition, Not Just The Current Value

A current-state field answers, "What does the system believe now?" A transition record answers several harder questions:

  • What was requested?

  • Who or what requested it?

  • Which rule allowed the change?

  • Which dependency handled it?

  • Was the result confirmed, rejected, pending, or unknown?

  • What evidence should a later refund, dispute, or reconciliation process use?

A practical model separates the business operation from each attempt to perform it.

RecordExampleWhy It Exists
Business operationCapture order O-4815 for NZD 240.00.Gives the financial action one stable identity.
AttemptProvider call attempt 1 timed out.Preserves execution history without inventing a new business operation.
External correlationProvider reference P-9271.Connects internal evidence to external evidence.
State transitioncapture_pending to captured.Shows the accepted movement through the state model.
EvidenceRequest hash, amount, currency, timestamp, result, actor.Supports investigation, audit, recovery, and reconciliation.

This distinction is small on a diagram and enormous during an incident. If a timeout occurs after the provider accepted a capture, the business operation still exists. Retrying should continue or query that operation, not silently create another one.

The Evidence Path

The money path and the evidence path are related, but they are not identical.

flowchart LR
    A["Customer or operator request"] --> B["Financial command<br/>stable operation ID"]
    B --> C["Policy and state checks"]
    C --> D["Provider or financial action"]
    D --> E["Controlled state transition"]
    E --> F["Ledger, settlement, and reconciliation records"]

    B -.-> G["Evidence<br/>actor, amount, currency, time"]
    C -.-> G
    D -.-> G
    E -.-> G
    F -.-> G

The evidence path should be durable enough to answer business questions without relying on a support engineer reconstructing events from application logs. Logs remain useful for technical diagnosis, but controlled financial records should explain the business state.

Evidence does not mean storing every raw payload forever. Sensitive data should be minimized, access-controlled, and retained according to explicit policy. Keep what is needed to correlate, prove, reconcile, and recover; avoid turning observability stores into an uncontrolled copy of payment data.

Guard The State Machine

A controlled state transition has four properties:

  1. The starting state is known. A capture cannot be treated as valid merely because a caller asked for it.

  2. The transition is allowed. Business rules determine whether the order, authorization, amount, currency, and actor make the action valid.

  3. The operation is uniquely identified. A repeated request can resolve to the existing operation rather than creating a duplicate.

  4. The result is recorded honestly. A timeout produces an unknown or pending state until evidence resolves it; it does not automatically mean failure.

An honest unknown state is safer than a convenient but invented answer. It gives the workflow a place to pause, query the provider, escalate for review, or wait for reconciliation.

Example: One Order, Several Financial Moments

A customer buys a laptop from a marketplace seller.

At checkout, the platform creates a payment operation and requests authorization. The authorization is recorded with the order, amount, currency, provider correlation, and result. Checkout can now proceed, but the platform does not claim that settlement is complete.

When the warehouse confirms that fulfillment has started, a separate capture command is created. The capture uses its own stable identifier and must pass the order and authorization state rules. The provider response times out. The workflow records capture_unknown and schedules a status query rather than submitting a fresh capture under a new identity.

The provider later confirms the original capture. The system records the transition, creates the appropriate financial evidence, and allows downstream invoice and seller-balance work to continue. Days later, settlement data arrives. Reconciliation connects the provider reference to the internal operation and confirms the expected amount.

If the customer returns the laptop, the refund is another controlled operation. It does not erase the capture. It adds a new, explainable transition with its own authorization, evidence, and reconciliation outcome.

Architecture Review Questions

For every financial transition, ask:

QuestionStrong Signal
What is the stable business operation ID?Retries and support actions converge on one operation.
Which states can precede this action?Invalid transitions are rejected explicitly.
What counts as confirmation?Provider response, internal record, and later settlement evidence are distinguished.
What happens after a timeout?The design uses pending or unknown state and a resolution path.
Who may initiate or approve it?Human and workload identities have scoped permissions.
What evidence survives?Amount, currency, actor, time, correlation, result, and reason are traceable.
How is the state reconciled?External and internal records have a matching process and exception owner.

Common Mistakes

  • Treating payment state as a boolean. It collapses authorization, capture, settlement, refund, and dispute into one ambiguous value.

  • Equating an HTTP response with financial truth. The response is evidence, but it is not the complete business record.

  • Assuming a timeout means failure. The dependency may have completed the action even though the response was lost.

  • Mutating history to make reports look correct. Corrections should be explicit and traceable.

  • Logging raw sensitive payloads as the evidence strategy. Evidence needs deliberate data minimization, protection, and retention.

  • Allowing support tools to bypass the same transition rules used by automated workflows.

If Someone Asks You

Why do payments need controlled state transitions?

A good answer is:

A financial action can affect customers, providers, ledgers, settlement, and later reconciliation at different times. I give each operation a stable identity, define allowed states, record provider correlation and evidence, and preserve pending or unknown outcomes when confirmation is incomplete. That makes retries safer and the final result explainable.

What You Should Remember

Trust in financial systems comes from evidence-backed state change.

Questions to Check Understanding

  1. Why should a timeout produce an unknown state instead of an automatic failure?

  2. What is the difference between a business operation and an execution attempt?

  3. Which evidence would you retain for a capture or refund transition?