PayFanout API reference
    Preparing search index...

    Function derivePayZenSubscriptionStatus

    • The V4/Subscription object has NO status field — the unified status is derived from the facts it does carry, first match wins:

      1. cancelDate set → "canceled" (Subscription/Cancel stamps it);
      2. totalPaymentsNumber > 0 and pastPaymentsNumber has reached it → "completed" (a finite rrule — COUNT/UNTIL — ran all installments; open-ended subscriptions report totalPaymentsNumber 0 and never complete);
      3. effectDate in the future → "pending" (created, not yet billing);
      4. otherwise → "active".

      Parameters

      • sub: Pick<
            PayZenSubscriptionLike,
            "cancelDate"
            | "effectDate"
            | "pastPaymentsNumber"
            | "totalPaymentsNumber",
        >
      • nowMs: number

      Returns
          | "unknown"
          | "canceled"
          | "pending"
          | "trialing"
          | "active"
          | "past_due"
          | "paused"
          | "completed"