---
issue: 066
title: "Backend: payout/confirm and release/confirm need canonical terminal status — DEC-32"
severity: high
domain: Payment
labels: [bug, backend, state-machine]
status: open
created: 2026-05-30
source: Full Codebase Audit 2026-05-30
---

# Backend: payout/confirm and release/confirm need canonical terminal status — DEC-32

**Severity:** high
**Domain:** Payment
**Labels:** bug, backend, state-machine

## Description

NB-29 was applied as an interim fix (setting `status:'completed'`), but the correct terminal status for a released/paid-out payment has not been decided. The enum currently has no `'released'` value. Until DEC-32 is resolved, the interim `'completed'` value may be incorrect for payments that need to be distinguished from non-released completions.

## Options

1. Add `'released'` to the Payment status enum and update all status-dependent logic (dashboards, filters, cleanup).
2. Map release/payout to the existing `'completed'` status plus a separate `releasedAt`/payout flag.
3. Introduce a dedicated escrow/payout sub-state field instead of overloading `status`.

## Recommendation

Decide the canonical representation (likely add `'released'` to the enum or a dedicated payout state) and update dashboards/filters consistently. The NB-29 interim fix uses `'completed'` — verify this does not cause dashboard overcounting or misclassification.

## Affected Files

- `backend/src/services/payment/requestNetwork/requestNetworkRoutes.ts:526`
- `backend/src/models/Payment.ts` — enum definition

## References

- [Full Codebase Audit 2026-05-30](../09%20-%20Audits/Full%20Codebase%20Audit%20-%202026-05-30.md) — DEC-32
