Skip to content

Refuse a second Pro checkout while a paid period is still open - #167

Closed
Programcode wants to merge 1 commit into
mainfrom
cursor/checkout-already-subscribed-791b
Closed

Programcode wants to merge 1 commit into
mainfrom
cursor/checkout-already-subscribed-791b

Conversation

@Programcode

Copy link
Copy Markdown
Owner

create-checkout never looked for a subscription that was already active or trialing. A student who already pays could open Checkout and buy Pro again.

After the success and cancel URLs are validated, the function reads subscriptions. An active or trialing row whose current_period_end is still in the future returns 409 with "You already have an active Pro subscription." The existing checkout error toast shows that text. A past period, a canceled row, or past_due does not block a new checkout. If the lookup itself errors, the function returns 503 and does not open Stripe.

No layout change. The only new student-facing text is that error, shown in the existing checkout error toast.

Verified locally (GitHub Actions is out of minutes, so this is not a CI pass):

  • deno test supabase/functions/create-checkout/auth_test.ts (5 passed): the old auth cases still return 400 before any database call, a future active period returns 409 without calling Stripe, and a failed lookup returns 503

Not run: a live Stripe Checkout session. No production data was touched.

Open in Web Open in Cursor 

create-checkout never looked for an active or trialing subscription, so a
paying student could buy Pro again. A future period now returns 409, and a
failed lookup fails closed instead of opening Stripe.

Co-authored-by: Gáborjáni-Szabó Ádám <Programcode@users.noreply.github.com>
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
debate-navigator Ready Ready Preview Oct 22, 2026 11:11am UTC
debatelab-staging Ready Ready Preview Oct 22, 2026 11:11am UTC

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

@Programcode

Copy link
Copy Markdown
Owner Author

Replaced by #161, which is now merged. Both stop a second Pro checkout. #161 also blocks past_due, unpaid and paused subscriptions, which can still bill, so it is the safer of the two.

This branch was successfully deployed

2 active deployments
Preview – debate-navigator — b8adfd86 Deployed Oct 22, 2026 by vercel[bot]
Preview – debatelab-staging — b8adfd86 Deployed Oct 22, 2026 by vercel[bot]
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