Repository navigation
Refuse a second Pro checkout while a paid period is still open - #167
Closed
Programcode wants to merge 1 commit into
Closed
Programcode wants to merge 1 commit into
Programcode wants to merge 1 commit into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Note 🎁 Summarized by CodeRabbit Free
Comment |
Owner
Author
This branch was successfully deployed
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.
create-checkoutnever 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 whosecurrent_period_endis 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, orpast_duedoes 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 503Not run: a live Stripe Checkout session. No production data was touched.