---
id: TST-ACC-TRX-124
title: Settlement retry suite
kind: integration
product_area: accounting
module: transactions
revision: 1
status: draft
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
repository: services-accounting
files:
  - >-
    modules/transactions/tests/integration/services/settlements/settlement-retry.integration.spec.js
implements:
  - ATS-ACC-TRX-009-05
implements_parts:
  - scenario: ATS-ACC-TRX-009-05
    assertion: >-
      it runs a new attempt under the key: a new settlement, completed with a
      payment, stored under the key with its attempt number
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/settlements/settlement-retry.integration.spec.js#it
      runs a new attempt under the key: a new settlement, completed with a
      payment, stored under the key with its attempt number
  - scenario: ATS-ACC-TRX-009-05
    assertion: 'it charged once: the invoice paid by the second attempt’s payment'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/settlements/settlement-retry.integration.spec.js#it
      charged once: the invoice paid by the second attempt’s payment
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 3
isolation: >-
  Suite-marked records in the prepared local test database; fixture teardown
  removes owned records.
provenance: test
source: >-
  services-accounting:modules/transactions/tests/integration/services/settlements/settlement-retry.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/settlements/settlement-retry.integration.spec.js
    assertion_titles:
      - a failed settlement frees its idempotency key (integration)
      - 'a card declined, then another card under the same key'
      - >-
        refuses the first attempt with the decline and leaves its settlement
        failed under the key, as history
      - >-
        runs a new attempt under the key: a new settlement, completed with a
        payment, stored under the key with its attempt number
      - 'charged once: the invoice paid by the second attempt’s payment'
      - >-
        answers a replay of the second attempt with its own settlement, not the
        failed one
      - >-
        refuses the key with another amount once a settlement holds it
        (idempotency_key_reused)
      - the same card declined twice under one key
      - 'runs a second attempt each time, both refused with the decline'
      - >-
        keeps one failed record per attempt, each with its failure code, and the
        invoice still owing
      - a lost answer
      - >-
        keeps the key reserved while the sweeper decides: the key is refused
        another body, no second attempt
      - a settlement the sweeper failed
      - >-
        frees the key at the next send: the same key and body runs a new attempt
        with its own record
    imports:
      - >-
        const { manualClock } =
        require('@rhythmsoftware/macroservice-time/clock');
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { TEST_NOW } =
        require('@rhythmsoftware/macroservice-testing/execution-context');
      - >-
        const { sweepProcessingIntents } =
        require('../../../../services/payments/intent-sweeper');
      - >-
        const { findSettlementOfKey, settle } =
        require('../../../../services/settlements/settlement-commands');
      - '} = require(''../../payments-fixtures'');'
      - "\t\t\tconst { refusal, failed } = run.require();"
      - "\t\t\tconst { failed, retried } = run.require();"
      - "\t\t\tconst { invoice } = run.require();"
      - "\t\t\tconst { invoice, retried } = run.require();"
      - "\t\t\tconst { invoice } = run.require();"
      - "\t\t\tconst { first, second } = run.require();"
      - "\t\t\tconst { invoice } = run.require();"
    test_double_declarations: []
---

# Settlement retry suite

## Verification Boundary

The suite exercises transaction commands and database protections in the local prepared test environment. Registration records the existing executable file; it does not report a run or establish product approval.

## What This Suite Proves

Its cited assertions contribute evidence for definite failure releases value for retry. The structured assertion bindings identify which parts of combined scenarios it executes.

## What It Does Not Prove

Local commands and route invocations do not establish deployed routing, live processor guarantees or the complete staff browser experience. An unbound feature chain remains proposed, and this registration carries no execution result.

## Real Dependencies and Test Doubles

The suite uses the imported commands, route handlers or persistence code against the local test database. Fixture helpers supply accounting context; any stepped clock, dummy processor or substituted external client is retained in the evidence declarations.

## Must Not Be Doubled

The command or persistence behavior under assertion and its relevant database protections must remain real. Substituting the final financial result removes evidence of transactional effects.
