DEV Community

Cover image for Settled, Available, Final: Modeling Funds State Across Payment Rails
Jarrod Wright for Chargebacks911

Posted on

Settled, Available, Final: Modeling Funds State Across Payment Rails

Most payment bugs that cost real money come from one shortcut: a single paid boolean.

A payment can be settled (money moved between institutions), available (you are allowed to spend it), and final (nobody can pull it back). These are three separate facts. Each payment rail produces them on its own schedule and under its own rules. Collapse them into one flag and you will eventually ship goods, pay out a seller, or credit a wallet against money that later leaves.

This gap gets more attention as banks add blockchain-based settlement next to their existing rails. A ledger that settles in seconds sounds like it removes the problem. It does not. For broader context on how banks actually use these ledgers, see Blockchain Banking: What Banks Actually Run on Blockchain & What It Means for Merchants. This article covers the engineering side: how to model funds state so your system stays correct no matter which rail the money arrived on.

The three states, defined precisely

Settled. The interbank or ledger movement has completed. For ACH, the settlement date has passed. For a card, the acquirer has funded you. For a blockchain transfer, the transaction is included in a block, and for proof-of-stake chains, that block is finalized.

Available. Your bank, processor, or your own risk policy lets the funds be used. This is a business decision layered on top of settlement. A processor might hold settled ACH funds for several days.

Final. Every reversal path has closed. Return windows have expired, dispute windows have expired, and no third party keeps a unilateral right to claw back or freeze the funds.

The key point: speed of settlement and reversibility are independent. A rail can settle slowly and become irreversible quickly, or settle instantly and stay reversible for months. Reversibility comes from the rules of whoever runs the payment, not from the ledger technology.

Why faster settlement doesn't fix availability

Take ACH debits. Under Nacha rules, most return reasons (such as R01, insufficient funds) must come back within two banking days. An unauthorized-debit return on a consumer account (R10) can come back up to 60 calendar days after settlement. That long tail is why processors hold ACH funds. Settlement speed is not the bottleneck.

Now move the same transaction onto a bank's private blockchain as a tokenized deposit. Settlement drops to near real time. But if the funding instruction was a consumer debit that can still be disputed, the risk is unchanged. The ledger records the movement faster. It does not change who may reverse it.

Instant credit-push rails like RTP and FedNow show the opposite case. They settle in seconds and are irrevocable at the protocol level. You can request a return, but the sender's bank cannot force one. They become final fast without any blockchain.

A decision table by rail

Rail Typical settlement Protocol-level reversal? Who can reverse/freeze Reversal window drives availability?
ACH debit (consumer) ~same day to 1–2 banking days Yes (returns) Receiver's bank via return codes Yes: short window for NSF, long window for unauthorized
ACH credit (received) ~same day to 1–2 banking days Limited (reversals for errors) Originator, narrow conditions Mostly short
Card (CNP) 1–3 days to merchant Yes (chargebacks) Issuer under card network rules Yes: dispute windows commonly ~120 days
RTP / FedNow Seconds No (request-for-return only) Nobody unilaterally Rarely
Bank tokenized deposit Near real time Governed by bank agreements The issuing bank Depends on contract and funding source
Public-chain stablecoin Minutes (to finality) No Issuer can freeze addresses Freeze risk persists, no dispute process
Native crypto on public chain Minutes (to finality) No Nobody (barring deep reorgs) Finality depth only

Treat these timings as configuration you verify against your processor agreement, not constants you hardcode.

Modeling it in code

Start by making rail policy data, not branching logic.

type DayType = 'banking' | 'calendar';

interface ReversalWindow {
  code: string;          // e.g. 'ACH_R01', 'ACH_R10', 'CARD_DISPUTE'
  length: number;
  dayType: DayType;
  anchor: 'settlement' | 'transaction' | 'delivery';
}

interface RailPolicy {
  rail: string;
  reversalWindows: ReversalWindow[];
  holdUntil: 'settlement' | 'shortest_window' | 'all_windows' | number; // number = custom days
  issuerFreezeRisk: boolean; // stablecoins: never fully final
}
Enter fullscreen mode Exit fullscreen mode

Then store funds state as an explicit state machine with timestamps, not a flag:

type FundsState =
  | 'initiated'
  | 'settled'
  | 'available'
  | 'final'
  | 'reversed';

interface PaymentLedgerEntry {
  id: string;
  rail: string;
  amountMinor: bigint;
  state: FundsState;
  settledAt?: Date;
  availableAt?: Date;
  finalAt?: Date;       // computed, may be null forever (freeze risk)
  reversedAt?: Date;
  reversalCode?: string;
}
Enter fullscreen mode Exit fullscreen mode

Allowed transitions:

initiated -> settled -> available -> final
               |            |
               +-> reversed <+
Enter fullscreen mode Exit fullscreen mode

reversed must stay reachable from available. That edge is the one teams forget, and it is where money is lost.

Computing finality

function computeFinalAt(p: PaymentLedgerEntry, policy: RailPolicy, cal: BankCalendar): Date | null {
  if (policy.issuerFreezeRisk) return null; // never fully final; track as residual risk
  if (!p.settledAt) return null;
  let latest = p.settledAt;
  for (const w of policy.reversalWindows) {
    const end = w.dayType === 'banking'
      ? cal.addBankingDays(p.settledAt, w.length)
      : addCalendarDays(p.settledAt, w.length);
    if (end > latest) latest = end;
  }
  return latest;
}
Enter fullscreen mode Exit fullscreen mode

BankCalendar must know federal holidays and weekends. Banking-day math done with calendar days is a classic off-by-several bug.

Measuring exposure

The number your finance and risk teams actually care about is reversible exposure: money you have treated as usable that could still leave.

SELECT rail, SUM(amount_minor) AS exposure_minor
FROM payment_ledger
WHERE state = 'available'
  AND (final_at IS NULL OR final_at > now())
GROUP BY rail;
Enter fullscreen mode Exit fullscreen mode

If this number grows faster than your reserves, your availability policy is too loose.

Worked example: one order, three rails

A customer buys $2,000 of equipment. Your fulfillment ships on available.

Paid by ACH debit, Monday. Settles Tuesday. Your policy holds until the shortest window closes: two banking days after settlement, so Thursday. You ship Thursday. finalAt lands roughly 60 calendar days out because of R10. For that whole period the $2,000 counts toward exposure. That is a deliberate, measured risk, not an accident.

Paid by card. Funded by the acquirer around T+2. You ship on settlement. finalAt sits about four months out. Exposure is real but well understood, and your representment evidence (delivery confirmation, IP, AVS results) is what protects it. Store those artifacts keyed to the payment ID at fulfillment time, not when the dispute shows up.

Paid in a USD stablecoin on a proof-of-stake chain. On-chain finality arrives in minutes. There is no chargeback. But the issuer can freeze tokens at an address, so issuerFreezeRisk = true and finalAt stays null. Your treasury process should sweep or convert received stablecoins promptly, and your exposure report should list them as a separate risk class.

One order, three very different risk profiles, and a blockchain is only directly involved in one of them.

Common mistakes and how to catch them

1. Single paid flag. Search the codebase for is_paid, status = 'complete', and similar. Every consumer of that flag needs to state which of the three states it actually requires.

2. Confusing confirmation with finality on-chain. "1 confirmation" is not finality. On Ethereum, use the finalized block tag rather than counting blocks. On proof-of-work chains, pick a confirmation depth based on the value at risk.

3. Assuming the outer rail's rules apply to the inner one. If a customer funds a stablecoin purchase with a card at an on-ramp, the on-ramp carries the chargeback risk. If you accept a card and settle internally on a tokenized-deposit ledger, the card chargeback still reaches you. Card rules follow the card, not the ledger.

4. No reverse edge from available. Write a test that settles, releases, then injects a late return. Assert that balances go negative correctly and trigger recovery workflows instead of throwing.

5. Hardcoded windows. Return and dispute windows differ by reason code, account type (consumer vs. corporate), and network. Keep them in versioned config so a rules update is a data change.

Testing with a controllable clock

Inject a clock and a bank calendar, then run property-style tests:

  • For any payment, settledAt <= availableAt <= finalAt whenever all three exist.
  • Advancing the clock past finalAt never makes a reversal legal.
  • Advancing across a holiday weekend never shortens a banking-day window.
  • For any rail with issuerFreezeRisk, finalAt is always null.

Replay a month of production events through the state machine with a simulated clock and compare the computed exposure with your actual returns and disputes. Gaps between the two usually point to a misconfigured window.

Takeaway

New settlement technology changes the settled timestamp. It rarely changes available and almost never changes final, because those come from the rules of the network, the issuer, and your own risk appetite. Model the three states explicitly, make reversal windows configuration, and track reversible exposure as a first-class metric. Your system will then handle a slow ACH debit and an instant ledger transfer with the same correct logic.

Being accurate in this area is important unless you simply want to fake reviews like Chargeflow apparently does.

Top comments (0)