Skip to content

Fix TT-030: Abandoned checkout shows portal instead of Checkout - #883

Merged
unjica merged 2 commits into
developfrom
cursor/fix-abandoned-checkout-portal-eb83
Oct 27, 2026
Merged

unjica merged 2 commits into
developfrom
cursor/fix-abandoned-checkout-portal-eb83

Conversation

@unjica

@unjica unjica commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Refs #882 (TT-030)

Problem

Regression from v1.22.18: A FREE org that once opened Stripe Checkout and abandoned it (has stripe_customer_id but NO subscription) incorrectly sees "Change to Pro/Business" buttons on Organization settings, which open the Customer Portal with nothing to select.

Expected behavior (v1.22.17): Should show "Upgrade to Pro/Business" and open Checkout.

Root Cause

Organization settings page (/dashboard/settings/organization/page.tsx) was still using hasStripeCustomer instead of hasStripeSubscription based on actual subscription status. This caused it to treat abandoned-checkout orgs as if they had active subscriptions.

Fix

Updated organization settings page to compute hasStripeSubscription using the same logic as:

Logic: Only treat as "has subscription" if stripeSubscriptionStatus is one of:

  • active
  • trialing
  • past_due
  • incomplete
  • unpaid

This ensures:

  • ✅ Abandoned checkout (customer, no subscription) → Shows "Upgrade to" + Opens Checkout
  • ✅ Active subscription → Shows "Change to" + Opens Portal
  • ✅ No customer, no subscription → Shows "Upgrade to" + Opens Checkout

Changes

Code

  1. Organization settings page (page.tsx line 123-135):
    • Computes hasStripeSubscription based on subscription status
    • Passes it to OrganizationUsageCard (maintains hasStripeCustomer prop name for component interface compatibility)
    • No changes needed to OrganizationBillingActions component (already uses the prop correctly)

Tests

  1. New regression test suite (organization-billing-actions-abandoned-checkout.test.tsx):
    • ✅ FREE org with NO subscription → "Upgrade to" + Checkout
    • ✅ FREE org WITH subscription → "Change to" + Portal
    • ✅ PRO org WITH subscription → "Change to Business" + Portal
    • ✅ "Manage billing" button shown only when subscription exists
    • ✅ No "Manage billing" for abandoned checkout orgs

Testing

Local:

pnpm lint && pnpm test && pnpm build

All pass ✅

Manual verification (once deployed):

  1. Create FREE org
  2. Open Checkout, then abandon (close tab)
  3. Navigate to Organization settings
  4. Verify: Shows "Upgrade to Pro/Business" (not "Change to")
  5. Click button → Verify: Opens Checkout (not Portal)

Behavioral Changes

None for properly functioning orgs. Only fixes the broken abandoned-checkout case.

Org State Before (broken) After (fixed)
FREE, no customer "Upgrade to" → Checkout ✅ "Upgrade to" → Checkout ✅
FREE, customer, NO sub (abandoned) ❌ "Change to" → Portal (empty) ✅ "Upgrade to" → Checkout
FREE, customer, active sub "Change to" → Portal ✅ "Change to" → Portal ✅
PRO, active sub "Change to Business" → Portal ✅ "Change to Business" → Portal ✅

Security / Privacy

No security or privacy implications. Only affects button text and action routing based on subscription state.

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 27, 2026 11:38
Regression from v1.22.18 where FREE org with abandoned checkout (Stripe
customer but no subscription) incorrectly shows 'Change to Pro/Business'
and opens Customer Portal with nothing to select.

Fix: Organization settings page now computes hasStripeSubscription based
on subscription status (active/trialing/past_due/incomplete/unpaid) instead
of hasStripeCustomer. This matches the API guard logic from #879 and ensures:
- Abandoned checkout orgs (customer, no sub) → 'Upgrade to' + Checkout ✓
- Active subscription orgs → 'Change to' + Portal ✓

Tests added:
- Dashboard unit tests for OrganizationBillingActions with abandoned checkout
- Verifies button text ('Upgrade to' vs 'Change to')
- Verifies correct action (Checkout vs Portal)
- Tests FREE no-sub, FREE with-sub, and PRO with-sub scenarios

Refs #882

Co-authored-by: Sanja Malovic <[email protected]>
@unjica
unjica merged commit 07b0373 into develop Oct 27, 2026
7 checks passed
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