Skip to content

Cancel the provider subscription when a project picks Free - #718

Merged
tonyalaribe merged 1 commit into
masterfrom
fix/free-plan-cancels-subscription
Oct 25, 2026
Merged

tonyalaribe merged 1 commit into
masterfrom
fix/free-plan-cancels-subscription

Conversation

@tonyalaribe

Copy link
Copy Markdown
Contributor

Choosing Free in the plan picker (pricingUpdateH, no order id) cleared sub_id but never cancelled the Stripe/LemonSqueezy subscription, so the customer kept being billed. It now calls cancelProjectSubscription first (an already-ended Stripe sub 404s and is logged at info).

Test: freePlanChoice_cancelsTheRunningStripeSubscription (Stripe Billing specs 15/15).

🤖 Generated with Claude Code

Choosing Free in the plan picker cleared sub_id but never cancelled the Stripe or
LemonSqueezy subscription, so the customer kept being billed for a plan they left.
@tonyalaribe
tonyalaribe merged commit a55d34b into master Oct 25, 2026
9 checks passed
@tonyalaribe
tonyalaribe deleted the fix/free-plan-cancels-subscription branch October 25, 2026 21:58
@claude

claude Bot commented Oct 25, 2026

Copy link
Copy Markdown

Review: LGTM, one simplification.

  • Pages/Projects.hs: project is already bound by Projects.sessionAndProject pid at the top of pricingUpdateH, so whenJustM (Projects.projectById pid) (...) is an extra DB query and an unneeded Maybe. Use Settings.cancelProjectSubscription envCfg project instead. That's shorter, and the cancel then acts on the same snapshot that handleOnboarding uses.
  • Ordering: cancelling before updatePricing is the right call. The provider call is best-effort, because failures are logged at attention level and never thrown, so a provider outage can't block the downgrade. The cost is that a failed cancel leaves the sub billing with no sub_id pointing at it. The logAttention line is what surfaces that, and it's adequate.
  • Test: covers the Stripe path and the resulting Free plan. It's a good regression guard. Optionally add a LemonSqueezy case, since cancelProjectSubscription branches on provider. That's low priority.

🤖 Generated with Claude Code

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.

1 participant