deriveBillingState (lib/billing.ts)

textbee · web/lib/billing.ts · typescript · MIT
payments

Transforms subscription data into a structured billing state object for UI display

// Source: https://github.com/textbee/textbee | License: MIT | Copyright 2022 - 2026 textbee.dev
// Provided via justclaw.it.com; keep this notice with the code.
import type { Subscription, SubscriptionStatus } from '@/lib/api/types'
import { PLAN_TIERS, findPlanTier, type PlanTier } from '@/lib/plans'

export type BillingState = {
  /** Display name for the current plan. Always populated. */
  planName: string
  /** The matching marketing tier, when the plan is one of ours. */
  tier: PlanTier | undefined
  /** True when the user has no subscription record at all. */
  isFree: boolean
  /** Present only for a real subscription. */
  status: SubscriptionStatus | undefined
  /** The tier to sell next, or undefined at the top of the ladder. */
  upgradeTier: PlanTier | undefined
  /** Whethe

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

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key