Skip to content

FRD: Billing Page Recipe

FieldValue
IDFRD-044
OwnerDavid Holmes
StatusDraft
PriorityP1 — Recipes
SizeM (Recipe)
Target Releasev2.0.0
Last Updated2026-05-26
RelatedADR-027 (Default Tech Stack)

Document Summary

Create an MDX recipe in Storybook that teaches developers how to compose a Billing page using design system components. The recipe references existing components (usage-meter-panel.tsx, billing-history-table.tsx) alongside plan-picker and payment-form patterns, and covers renewal warnings, failed-payment states, usage tracking, and billing history. It provides copy-pasteable code for a realistic SaaS billing page.


Introduction

Overview

Billing pages are critical SaaS infrastructure — they handle plan selection, usage visibility, payment management, and invoice history. These pages have unique state complexity: renewal warnings, failed payment recovery flows, usage limit thresholds, and plan comparison. Without a canonical recipe, developers either build incomplete billing experiences or spend excessive time figuring out the correct component composition and state handling.

Goals

  • Provide a single MDX recipe showing the complete Billing page composition pattern.
  • Reference and integrate existing components: usage-meter-panel.tsx and billing-history-table.tsx.
  • Show plan-picker composition with current plan highlight, upgrade/downgrade flows, and feature comparison.
  • Show payment form integration points (card on file, update payment method).
  • Cover renewal warning states (upcoming renewal, payment method expiring, grace period).
  • Cover failed-payment states (past due, payment retry, account suspension warning).
  • Include usage meter visualization with threshold warnings.

Non-Goals

  • Implementing Stripe or other payment provider integration.
  • Building a pricing page (public-facing plan comparison is a different pattern).
  • Handling proration calculation logic.
  • Multi-currency support details.

Scope

In Scope

ItemDescription
MDX recipe pagesrc/docs/recipes/billing-page.mdx with Storybook sidebar entry
Plan picker sectionCurrent plan display, available plans comparison, upgrade/downgrade CTAs
Usage meter sectionIntegration with usage-meter-panel.tsx, threshold warnings, overage indicators
Billing history sectionIntegration with billing-history-table.tsx, invoice download links, status badges
Payment method sectionCard on file display, update payment method dialog
Renewal warningsUpcoming renewal banner, expiring card warning, grace period alert
Failed payment statesPast due alert, retry payment CTA, account suspension warning
Overview page updateAdd Billing recipe to src/docs/recipes/00-overview.mdx

Out of Scope

ItemReason
Payment provider SDK integrationVendor-specific; recipe shows the UI composition only
Tax calculation and displayBackend concern; recipe shows placeholder tax line items
Plan creation/management admin UIAdmin-side billing is a different pattern
Subscription lifecycle webhooksBackend infrastructure, not frontend composition

Users and Pain Points

UserPain Point
Application developerNo reference for how to compose a billing page from design system components
Application developerUnclear how to show failed payment recovery flow — what states exist and what actions to offer
Application developerUsage meters need threshold warnings but no pattern shows how to wire them
Application developerRenewal warnings have multiple severity levels — no guidance on which alert variant to use
Product managerInconsistent billing UX across products leads to support tickets

Definitions

TermDefinition
Plan pickerA UI section showing available subscription plans with comparison and selection
Usage meterA visual indicator of resource consumption against a plan limit
Renewal warningAn alert shown before a subscription renews, especially when action is needed
Failed paymentA state where the most recent payment attempt was declined or errored
Grace periodA time window after a failed payment before service is suspended

Current State

  • usage-meter-panel.tsx and billing-history-table.tsx are referenced in the roadmap as existing components to integrate.
  • The recipes overview lists billing-related patterns as planned.
  • Components available for composition: Alert, Badge, Button, Card, DataGrid (for billing history), Dialog, ProgressBar (for usage meters), Toast.
  • No recipe MDX file exists yet.

Proposed Solution

Create src/docs/recipes/billing-page.mdx with the following structure:

  1. Introduction — What this recipe builds, when to use it, when not to use it.
  2. Component inventory — Table listing all components with links, noting usage-meter-panel and billing-history-table as primary compositions.
  3. Page layout — Overall billing page structure with sections.
  4. Current plan and plan picker — Display current plan details, show available plans in a comparison layout, upgrade/downgrade CTAs with confirmation dialog.
  5. Usage metersusage-meter-panel integration showing current usage, limits, threshold warnings (80%, 90%, 100%), and overage state.
  6. Payment method — Card on file display (masked number, expiry), update payment method CTA opening a dialog.
  7. Billing historybilling-history-table integration showing invoices, status badges (Paid, Pending, Failed, Refunded), download links.
  8. Renewal warnings — Alert variants for upcoming renewal (info), expiring payment method (warning), grace period (destructive).
  9. Failed payment recovery — Alert with retry CTA, update payment method link, account status messaging.
  10. Full composition — Complete code block.

Requirements

IDRequirementPriority
REQ-01Recipe is a single MDX file in src/docs/recipes/Must
REQ-02Recipe integrates usage-meter-panel.tsxMust
REQ-03Recipe integrates billing-history-table.tsxMust
REQ-04Recipe shows plan picker with current plan and upgrade flowMust
REQ-05Recipe shows renewal warning states (info, warning, destructive)Must
REQ-06Recipe shows failed payment recovery flowMust
REQ-07All code blocks are copy-pasteable and self-containedMust
REQ-08Recipe shows payment method display and update flowShould
REQ-09Recipe documents usage threshold warning levelsShould

Functional Requirements

IDDescriptionAcceptance
FR-01MDX file renders in Storybook without errorspnpm build-storybook succeeds
FR-02All code blocks compile when extractedManual verification
FR-03Renewal warning shows correct Alert variant per severityCode example demonstrates info/warning/destructive
FR-04Failed payment state shows retry and update-payment actionsCode example includes both CTAs
FR-05Usage meter shows threshold-based color changesCode example demonstrates 80/90/100% thresholds

Non-Functional Requirements

IDDescriptionTarget
NFR-01Recipe page load timeUnder 2 seconds
NFR-02Individual code block line countUnder 80 lines per block
NFR-03Recipe covers the most common billing states without being exhaustive80/20 rule — cover 80% of use cases

API/Interface Requirements

InterfaceRequirement
MDX fileMust use “
usage-meter-panelRecipe must show its props interface and usage pattern
billing-history-tableRecipe must show its data shape and column configuration
Payment formRecipe shows the integration point (dialog shell) without provider-specific code

Accessibility Requirements

IDRequirement
A11Y-01Usage meters must have text alternatives — screen readers must hear the percentage and limit, not just see the visual bar
A11Y-02Renewal and failed payment alerts must use role="alert" for screen reader announcement
A11Y-03Plan picker must be keyboard-navigable with clear focus indicators
A11Y-04Invoice download links must include the invoice date/number in their accessible name

Content and Documentation Requirements

IDRequirement
DOC-01Update src/docs/recipes/00-overview.mdx to add Billing recipe
DOC-02Document the state machine for payment status (Active, Past Due, Grace Period, Suspended)
DOC-03Include a “Which alert variant to use” decision table for billing states

Dependencies

DependencyTypeRisk
usage-meter-panel.tsxInternalMust exist and be stable before recipe references it
billing-history-table.tsxInternalMust exist and be stable before recipe references it
Alert componentInternalMust support info, warning, and destructive variants
Card componentInternalUsed for plan picker cards
ProgressBar componentInternalUsed within usage meter for visual fill

Risks and Tradeoffs

RiskImpactMitigation
usage-meter-panel and billing-history-table may not exist yetRecipe references non-existent componentsVerify component existence before authoring; create stubs if needed
Payment form integration is provider-specificRecipe cannot show a working payment formShow the dialog shell and note where provider SDK integration goes
Billing state complexity is highRecipe may be too longFocus on the 4 most common states; link to a “Billing States Reference” for edge cases

Open Questions

#QuestionStatus
1Do usage-meter-panel.tsx and billing-history-table.tsx currently exist in the codebase?Open — need to verify or create
2Should the recipe show a Stripe Elements integration example as an optional section?Open
3Should plan comparison use a ComparisonTable or custom Card layout?Open
4Should the recipe cover annual vs. monthly billing toggle?Open

Acceptance Criteria

  • src/docs/recipes/billing-page.mdx exists and renders in Storybook.
  • Recipe appears in sidebar under “Docs/Best Practices/Recipes/Billing Page”.
  • Recipe references usage-meter-panel and billing-history-table components.
  • Recipe shows plan picker with current plan highlight and upgrade CTA.
  • Recipe shows renewal warning alerts in info, warning, and destructive variants.
  • Recipe shows failed payment recovery with retry and update-payment actions.
  • Recipe shows usage meter with threshold-based warnings.
  • All code blocks compile when extracted.
  • pnpm build-storybook succeeds.

LLM Handoff Instructions

When an LLM agent picks up this FRD:

  1. Read src/docs/recipes/00-overview.mdx for recipe conventions.
  2. Search for usage-meter-panel.tsx and billing-history-table.tsx in the codebase. If they exist, read their props interfaces. If not, check if they need to be created first (separate FRD).
  3. Read component source for: Alert, Badge, Button, Card, Dialog, ProgressBar, Toast, ComparisonTable.
  4. Create src/docs/recipes/billing-page.mdx with the section structure from the Proposed Solution.
  5. Sample data: “Pro Plan” subscription at $49/month, usage of API calls (8,500/10,000), storage (7.2GB/10GB), team members (4/5). Billing history with 6 months of invoices.
  6. State scenarios to cover: Active + healthy, Renewal upcoming (7 days), Payment method expiring, Failed payment (past due), Grace period, Usage at 90%.
  7. All code blocks must use public package import paths.
  8. After creating, run pnpm build-storybook to verify.
  9. Update src/docs/recipes/00-overview.mdx.

Decision Log

DateDecisionRationale
2026-05-26Reference existing usage-meter-panel and billing-history-table rather than inliningThese are reusable compositions that belong as components, not recipe-only code
2026-05-26Show payment form as a dialog shell without provider SDK codeProvider integration varies; recipe focuses on the UI composition

Document History

DateVersionAuthorChanges
2026-05-260.1David HolmesInitial draft