# Stripe Billing Core (3A) Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: superpowers:subagent-driven-development. Parallel waves use `isolation: worktree`; the controller integrates (cherry-pick/ff) and runs the gate between waves.

**Goal:** see spec `docs/superpowers/specs/2026-06-12-stripe-billing-core-design.md`.

**Waves (max parallelism, dependency-safe):**

- **Wave 1 (parallel ×3, worktrees):**
  - **T1 — Stripe bootstrap script**: `scripts/stripe-bootstrap.ts` (idempotent, lookup keys, USD+EUR currency_options, TEST mode) + run it against the test account; report lookup→price ids.
  - **T2 — Foundation**: deps (`@better-auth/stripe` + `stripe`, better-auth aligned exact), `env.ts` (+`STRIPE_WEBHOOK_SECRET`, `stripeEnabled`), `src/lib/billing/plans.ts` (grid + invariants test), auth plugin config (server+client, gated on `stripeEnabled`), schema (subscription table, stripeCustomerId ×2, org.trialEndsAt), migration **0031 `when`→`1781320000000`**, backfill existing orgs trial +14d, migrate dev+test.
  - **T4 — Billing catalogs**: `Billing` namespace complete (plans, statuses, trial countdown, locked page, portal/upgrade CTAs) + extended `Onboarding` plan-step keys, 4 langs, parity green.
- **Wave 2 (solo):** **T3 — Trial + status**: org-bootstrap first-org-only `trialEndsAt`, `src/lib/billing/status.ts` (`computeBillingStatus` pure + `getOrgBillingStatus` fresh-read), `authorizeReference` extracted testable, DB tests.
- **Wave 3 (parallel ×3, worktrees):**
  - **T5 — Gate + /billing-locked** page (plan cards → `subscription.upgrade`, super-admin bypass, outside `(app)`).
  - **T6 — Settings→Billing** page + settings-shell entry + nav-user links.
  - **T7 — Wizard plan-step rewrite** (real grid, default "Essai Pro 14 j", paid → Checkout post-wizard).
- **Controller:** integration after each wave (gate `bun run test:all` + build), live d3k verification (trial→app, expired→locked, Checkout 4242→unlocked, Portal), merge dev.

Task details live in the dispatch prompts (self-contained per subagent-driven-development); spec is the contract.
