Skip to content

fix(billing): preserve plan intent through org creation flow - #876

Merged
unjica merged 2 commits into
developfrom
cursor/fix-plan-intent-no-org-eb83
Oct 27, 2026
Merged

unjica merged 2 commits into
developfrom
cursor/fix-plan-intent-no-org-eb83

Conversation

@unjica

@unjica unjica commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Base branch: develop

Refs #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:

  1. User clicks "Start with Pro" → registers → lands on /dashboard/settings/billing?plan=pro
  2. Billing page shows "Create an organization..." error (no org yet)
  3. Link to org settings dropped ?plan param
  4. After org creation, stayed on org settings (plan lost)
  5. Checkout never triggers

Now fixed (refined flow):

  1. User clicks "Start with Pro" → registers → lands directly on /dashboard/settings/organization?plan=pro (skips billing error page)
  2. User creates organization
  3. After org creation, redirects to /dashboard/settings/billing?plan=pro
  4. Existing BillingPlanIntent component triggers Checkout once ✓

Changes:

  1. RegisterPageForm: Redirect new registrations with plan intent to organization settings instead of billing

    • With plan, no invite: /dashboard/settings/organization?plan=pro (new)
    • With invite: /dashboard/overview (unchanged)
    • No plan: /dashboard/settings/organization (unchanged)
  2. Organization settings page: Accept searchParams, parse plan, pass planIntent prop to form

  3. CreateOrganizationForm: Accept planIntent prop, redirect to billing with plan after creation

    • With plan: router.push(/dashboard/settings/billing?plan=pro)
    • Without plan: router.refresh() (existing behavior)
  4. Billing page: Preserve ?plan in "Go to Organization settings" link when no org exists (fallback path)

    • Softer copy: "Create an organization to view billing..." (less error-like)
  5. Middleware: Signed-in users on /register?plan=... still redirect to billing (unchanged - existing accounts skip org creation)

No changes to:

  • Stripe integration, billing business logic, or webhooks
  • Invite or other auth flows
  • Middleware behavior for existing users

How to test

Local:

pnpm lint && pnpm test && pnpm build

All checks pass (435 tests including 5 new).

Manual verification (preview deploy):

Flow 1: New user with plan intent (primary fix)

  1. Logged-out /pricing → "Start with Pro" → register as new user
  2. After registration, lands directly on /dashboard/settings/organization?plan=pro (skips billing error!)
  3. Create organization with any name
  4. After creation, redirects to /dashboard/settings/billing?plan=pro
  5. "Redirecting to Stripe Checkout..." appears, then Checkout loads for Pro tier ✓

Flow 2: Existing user with plan intent (via middleware - unchanged)

  1. Sign in as existing user with org
  2. Visit /register?plan=pro while authenticated
  3. Middleware redirects to /dashboard/settings/billing?plan=pro (skips org settings)
  4. Checkout triggers ✓

Flow 3: Fallback (billing page link preserves plan)

  1. If user somehow lands on /dashboard/settings/billing?plan=pro with no org
  2. "Create an organization to view billing..." message shown (softer copy)
  3. "Go to Organization settings →" link includes ?plan=pro
  4. Same flow as primary: create org → redirects to billing → Checkout ✓

Edge cases:

  • Creating org without plan: stays on org settings (no redirect) ✓
  • Invite acceptance: goes to overview, ignores plan ✓

Code review (Bugbot)

Paused: GitHub bugbot-review is currently a no-op. /review-bugbot is optional.

  • For billing/auth changes: considered running /review-bugbot (optional while paused)

Checklist

  • Tests pass (pnpm test - 435 tests, +5 new)
  • Lint passes (pnpm lint)
  • Build succeeds (pnpm build)
  • CHANGELOG.md updated under [Unreleased] (will update on merge)
  • Documentation updated (N/A - internal flow fix)
  • New code follows existing style
  • No breaking changes

Security / privacy

No security or privacy implications. Plan intent is client-side query param only, no changes to Stripe session creation or data handling.

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 27, 2026 09:18
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants