Subscriptions & Billing Cycles
Relevant source files
The following files were used as context for generating this wiki page:
- clients/apps/web/src/components/Landing/features/SubscriptionsPage.tsx
- clients/apps/web/src/components/Landing/features/UsageBillingPage.tsx
- clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts/dashboard/[organization]/(header)/products/new/ai/chat/route.ts)
- clients/apps/web/src/components/Settings/Billing/BillingSubscriptionCard.tsx
- server/polar/organization_review/analyzer.py
- handbook/docs.json
Polar provides an end-to-end subscription management system that handles the entire lifecycle of recurring revenue, from initial checkout to renewals, proration, and payment recovery. The system acts as a Merchant of Record, managing international sales taxes and compliance while automating the granting and revocation of customer benefits.
The architecture supports multiple billing models, including fixed-rate subscriptions, seat-based pricing, and usage-based billing driven by event ingestion. It integrates directly with a Customer Portal where subscribers can manage their plans, update payment methods, and handle cancellations.
Sources: clients/apps/web/src/components/Landing/features/SubscriptionsPage.tsx:18-35, clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:51-60
Subscription Lifecycle
A subscription is initiated when a customer checks out a product with a recurring price. Polar automates the generation of the first order, collects payment, and triggers the "Benefits" engine to grant access to digital goods or services.
Renewal and Automation
At the end of each billing cycle, Polar automatically advances the period and generates a new renewal order. This order includes applicable taxes and active discounts. The system then charges the saved payment method. If a charge fails, the subscription enters a "Payment Recovery" state.
Lifecycle Flow
The following diagram illustrates the standard progression of a subscription through active, past due, and terminal states:
The subscription state directly controls benefit access: while active or trialing, access is maintained; once canceled or unpaid, benefits are revoked.
Sources: clients/apps/web/src/components/Landing/features/SubscriptionsPage.tsx:37-49, clients/apps/web/src/components/Settings/Billing/BillingSubscriptionCard.tsx:14-30
Billing Models
Polar supports three primary recurring billing configurations that can be assigned to products.
Fixed and Tiered Pricing
- Fixed Price: A standard recurring fee (e.g., $10/month).
- Seat-Based Pricing: Pricing based on the number of users or "seats." This can follow "Fixed per seat," "Volume discounts" (one tier selected based on total), or "Graduated" (filling across multiple tiers) models.
Usage-Based Billing
Usage billing is driven by an asynchronous event ingestion pipeline. Applications post events to Polar, which are then aggregated by "Meters."
- Events: Immutable records containing customer IDs and metadata.
- Meters: Filters and aggregates the event stream (Sum, Count, Unique, Min, Max, Average).
- Metered Prices: Attached to products, Polar reads the meter balance at the end of the cycle to generate invoice line items.
Sources: clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:133-157, clients/apps/web/src/components/Landing/features/UsageBillingPage.tsx:32-47
Proration and Plan Changes
When customers upgrade or downgrade their subscriptions, Polar supports three distinct proration behaviors to manage the financial transition:
| Behavior | Description | Typical Use Case |
|---|---|---|
| Invoice Immediately | Charges the prorated difference instantly in the same API call. | Upgrades requiring immediate revenue. |
| Apply on Next Invoice | Changes the plan immediately but rolls the financial difference into the next renewal. | Routine plan changes. |
| Apply on Next Period | Schedules the change to take effect only at the start of the next cycle. | Downgrades to avoid partial refunds. |
Sources: clients/apps/web/src/components/Landing/features/SubscriptionsPage.tsx:71-87, handbook/docs.json:71
Payment Recovery (Dunning)
If a renewal charge fails, the system triggers a dunning sequence designed to restore the subscription before revoking access.
Retry Schedule
Polar executes a four-attempt retry schedule over 21 days (at 2, 5, 7, and 7-day intervals). The customer is notified via email at the first failure with a link to update their payment method in the Customer Portal.
Grace Periods
Organization owners can configure a grace period (0, 2, 7, 14, or 21 days). This allows customers to maintain benefit access while the system attempts to recover the failed payment.
Subscription Data Structures
The frontend represents subscription states using the OrganizationSubscription schema, which tracks intervals, pricing, and pending changes.
Subscription Status Reference
| Status | Description |
|---|---|
active | Payment successful, access granted. |
trialing | Within a defined trial period. |
past_due | Renewal charge failed; in retry sequence. |
canceled | Subscription terminated. |
unpaid | Retries exhausted without recovery. |
Sources: clients/apps/web/src/components/Settings/Billing/BillingSubscriptionCard.tsx:14-30, clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:159
Subscription Components
The system tracks several critical timestamps and metadata fields to manage the billing cycle:
started_at: The initial creation date of the subscription.current_period_end: The next renewal or termination date.recurring_interval: The cadence (e.g., month, year).pending_change: Details of a scheduled plan change or proration event.
Sources: clients/apps/web/src/components/Settings/Billing/BillingSubscriptionCard.tsx:114-135, clients/apps/web/src/components/Landing/features/SubscriptionsPage.tsx:112-118
Summary
The Subscriptions & Billing Cycles module is a core pillar of the Polar platform, enabling developers to automate complex recurring revenue workflows. By combining Merchant of Record capabilities with flexible pricing models (Fixed, Seat-based, and Usage-based), the system handles the heavy lifting of global tax compliance, automated renewals, and intelligent payment recovery, allowing businesses to focus on product development.