PayFanout API reference
    Preparing search index...

    Interface SubscriptionManagerOptions

    interface SubscriptionManagerOptions {
        catchUpLimit?: number;
        generateId?: () => string;
        now?: () => number;
        onEvent?: (event: SubscriptionEvent) => void | Promise<void>;
        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: concurrent chargeDueSubscriptions runs converge on charges at the PSP (deterministic idempotency keys) 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.

    retryDelaysHours?: number[]

    Dunning policy: hours to wait before each renewal retry. The Nth failure schedules a retry after retryDelaysHours[N-1]; failing with the schedule exhausted cancels the subscription. Default [24, 72] (3 attempts total).