PayFanout API reference
    Preparing search index...

    Interface SubscriptionStore

    The persistence seam — implemented by the HOST over its own database. save upserts by record.id. Implementations must persist every field verbatim; the manager treats the store as the single source of truth.

    interface SubscriptionStore {
        get(id: string): Promise<SubscriptionRecord | undefined>;
        list(
            filter?: { pspCustomerId?: string; status?: SubscriptionStatus },
        ): Promise<SubscriptionRecord[]>;
        listDue?(
            input: { dueBefore: string; limit?: number },
        ): Promise<SubscriptionRecord[]>;
        save(record: SubscriptionRecord): Promise<void>;
    }

    Implemented by

    Index
    • Optional scale path for chargeDueSubscriptions: return records that are due — active/trialing with currentPeriodEnd <= dueBefore, or past_due with nextRetryAt <= dueBefore — never canceled or paused ones, in a stable order, at most limit of them. Push the predicate into a database index; the manager pages until a short batch and still re-checks due-ness per record, so this filter is an optimization, not a trust boundary. Without it the manager falls back to per-status list() scans.

      Parameters

      • input: { dueBefore: string; limit?: number }

      Returns Promise<SubscriptionRecord[]>