Stripe Billing integration covering recurring subscriptions (monthly/annual), trial management (free trial with or without credit card requirement), plan upgrades and downgrades with proration calculated by Stripe, usage-based metering via Stripe Billing Meters API (report usage events, Stripe aggregates and bills at period end), and invoice generation with custom line items for one-time charges. Stripe webhook events consumed and idempotently processed: invoice.payment_succeeded (activate/extend subscription), invoice.payment_failed (dunning sequence initiation), customer.subscription.deleted (account downgrade/deactivation), customer.subscription.updated (plan change acknowledgement). Dunning sequence: Day 1 automated email with Stripe-hosted payment update link, Day 3 in-app banner, Day 7 account suspension warning, Day 14 account suspended with data retention guarantee.
Feature flags by plan tier: LaunchDarkly or Unleash (self-hosted) gates features at the application layer with the customer's current plan stored as a context attribute. When a feature is requested by a customer on the wrong tier, the API returns HTTP 402 with a structured body ({ "upgrade_required": true, "feature": "advanced_analytics", "current_plan": "starter", "required_plan": "growth" }) that the frontend uses to render an upgrade prompt. This allows plan-gating any feature without a code deployment, add a feature flag to the plan configuration and the feature gate propagates immediately. For Stripe alternatives: Lago (open-source billing engine, self-hosted, supports complex usage-based pricing models that Stripe Billing doesn't natively handle) available as an option where Stripe's pricing model flexibility is insufficient.