PayFanout API reference
    Preparing search index...

    Interface SubscriptionManagerOptions

    interface SubscriptionManagerOptions {
        catchUpLimit?: number;
        generateId?: () => string;
        now?: () => number;
        onEvent?: (event: SubscriptionEvent) => void | Promise<void>;
        replayDelaysMinutes?: number[];
        replayWindowHours?: number;
        retryDelaysHours?: number[];
        service: PaymentService;
        store: SubscriptionStore;
    }
    Index
    catchUpLimit?: number

    How many overdue periods one chargeDueSubscriptions run may collect per subscription. Default 1 — a long-dead cron must not surprise-charge a customer several periods in one instant.

    generateId?: () => string

    Injected id generator; defaults to crypto.randomUUID.

    now?: () => number

    Injected clock (ms since epoch) for tests.

    onEvent?: (event: SubscriptionEvent) => void | Promise<void>

    Observability: fired on every lifecycle transition. Errors are swallowed. Delivery is at-least-once: overlapping chargeDueSubscriptions runs that send the same renewal converge on one PSP charge (deterministic idempotency keys; see chargeDueSubscriptions for runs that send another request under the same key) but may each emit the same transition — dedupe on (subscription.id, type, currentPeriodEnd), never on occurredAt (it differs per delivery), if exactly-once matters to the host.

    replayDelaysMinutes?: number[]

    Minutes to wait before each replay of a renewal charge that ended without a definitive answer (see RenewalReplay). Default [5, 30, 120, 360, 720], about 20.5 hours in all. Once the schedule is spent, or when the next replay would fall outside replayWindowHours, the charge is frozen until resolvePendingRenewal settles it; [] freezes it at the first uncertain answer.

    replayWindowHours?: number

    How long after the first send a replay may still go out. A replay dedupes only while the PSP holds the idempotency key: Stripe lets clients retry "within 24 hours" and may prune a key after that. Default 24.

    retryDelaysHours?: number[]

    Dunning policy: hours to wait before each renewal retry. The Nth failed attempt schedules a retry after retryDelaysHours[N-1]; failing with the schedule exhausted cancels the subscription. Default [24, 72] (3 attempts total). Only definitive failures count: a charge without a definitive answer is replayed (replayDelaysMinutes) and counts once it is settled as failed, or at once on a store that does not persist renewalAttempt.