Component evidence

Charge Settlement Driver (src/charge-settlement.ts)

agent-blackbox · apps/shared/src/charge-settlement.ts · typescript · MIT
paymentsautomationtag:charge-settlement

Polls billing charge status until settled, failed, refused, or timeout, using configurable intervals and retry caps.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/umanitek/agent-blackbox | License: MIT | Copyright 2025 Nous Research
// Provided via justclaw.it.com; keep this notice with the code.
import { refusalPolicy } from './billing-policy.js'
import type { BillingChargeStatusResponse } from './billing-types.js'

export interface SettlementDeps {
  fetchStatus(): Promise<BillingChargeStatusResponse>
  sleep(ms: number): Promise<void>
  isCancelled(): boolean
  now(): number
}

export type SettlementOutcome =
  | { kind: 'settled'; status: BillingChargeStatusResponse }
  | { kind: 'failed'; status: BillingChargeStatusResponse }
  | { kind: 'refused'; error: string; status: BillingChargeStatusResponse }
  | {
      kind: 'ambiguous'
      error: string
      status?: BillingChargeStatusResponse
      cause?: unknown
 

... (truncated -- full source via MCP)