Repository navigation
fix(billing): preserve plan intent through org creation flow - #876
Merged
Merged
Conversation
Refs #875 When a new user registers with plan intent (?plan=pro|business), they have no organization yet and land on the billing page showing the 'Create an organization' error state. The link to organization settings was dropping the plan param, and after org creation the user stayed on org settings. Changes: - Billing page: preserve ?plan in 'Go to Organization settings' link when no org - Organization settings page: accept plan query param and pass to CreateOrganizationForm - CreateOrganizationForm: redirect to /dashboard/settings/billing?plan=... after org creation when plan intent exists, so BillingPlanIntent triggers Checkout - Add tests: CreateOrganizationForm redirect behavior with/without plan intent Flow now: 1. Register with ?plan=pro → billing shows no-org error 2. Click 'Go to Organization settings' → preserves ?plan=pro 3. Create org → redirects to billing with ?plan=pro 4. BillingPlanIntent auto-triggers Checkout once (existing behavior) Zero changes to Stripe/billing business logic. Co-authored-by: Sanja Malovic <[email protected]>
Skip the billing no-org error page for brand-new users: - RegisterPageForm: redirect to /dashboard/settings/organization?plan=... instead of billing when registering with plan intent (no invite) - After org creation, the form already redirects to billing with plan, so Checkout triggers normally - Middleware signed-in /register?plan=... → billing redirect unchanged (existing accounts go straight to billing) - Soften no-org billing copy: 'Create an organization to view billing...' instead of 'No organization selected' (less error-like) - Update register test expectations: org settings, not billing Flow now: 1. Register with ?plan=pro → /dashboard/settings/organization?plan=pro 2. Create org → redirects to billing with plan (from earlier commit) 3. BillingPlanIntent triggers Checkout once All tests pass (435). Co-authored-by: Sanja Malovic <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Base branch:
developRefs #875
Summary
Fixes a bug where brand-new users registering from "Start with Pro/Business" CTAs lose their plan intent during organization creation. The issue occurs because registration doesn't create an organization automatically—users must create one manually.
Original broken flow:
/dashboard/settings/billing?plan=pro?planparamNow fixed (refined flow):
/dashboard/settings/organization?plan=pro(skips billing error page)/dashboard/settings/billing?plan=proBillingPlanIntentcomponent triggers Checkout once ✓Changes:
RegisterPageForm: Redirect new registrations with plan intent to organization settings instead of billing
/dashboard/settings/organization?plan=pro(new)/dashboard/overview(unchanged)/dashboard/settings/organization(unchanged)Organization settings page: Accept
searchParams, parse plan, passplanIntentprop to formCreateOrganizationForm: Accept
planIntentprop, redirect to billing with plan after creationrouter.push(/dashboard/settings/billing?plan=pro)router.refresh()(existing behavior)Billing page: Preserve
?planin "Go to Organization settings" link when no org exists (fallback path)Middleware: Signed-in users on
/register?plan=...still redirect to billing (unchanged - existing accounts skip org creation)No changes to:
How to test
Local:
All checks pass (435 tests including 5 new).
Manual verification (preview deploy):
Flow 1: New user with plan intent (primary fix)
/pricing→ "Start with Pro" → register as new user/dashboard/settings/organization?plan=pro(skips billing error!)/dashboard/settings/billing?plan=proFlow 2: Existing user with plan intent (via middleware - unchanged)
/register?plan=prowhile authenticated/dashboard/settings/billing?plan=pro(skips org settings)Flow 3: Fallback (billing page link preserves plan)
/dashboard/settings/billing?plan=prowith no org?plan=proEdge cases:
Code review (Bugbot)
/review-bugbot(optional while paused)Checklist
pnpm test- 435 tests, +5 new)pnpm lint)pnpm build)[Unreleased](will update on merge)Security / privacy
No security or privacy implications. Plan intent is client-side query param only, no changes to Stripe session creation or data handling.