Repository navigation
Prepaid code: switch off is a no-op on the portal, resume checks for another live plan (switch stays off) - #26173
Merged
Conversation
…another live plan With PREPAID_CODE_REDEEM off and no prepaid marker on the stored row, the portal makes no extra Stripe read. A resumed redemption refuses when another live plan exists, ignoring the prepaid subscription this same code created.
kodjima33
marked this pull request as ready for review
November 23, 2026 21:24
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.
What changed and why
Follow-up to #26171 from its review. Backend only.
PREPAID_CODE_REDEEMstaysoffand nobody is added to the cohort.PREPAID_CODE_REDEEMis off and the stored row has no prepaid marker, the read is skipped. The newconfig.prepaid_code_redeem.mode()is an env read with no I/O. Those readers get exactly the session they got before Redeem a prepaid Omi Pro code with no card, behind PREPAID_CODE_REDEEM (default off) #26146 (customerandreturn_urlonly).cohortoronmode the read turns itself back on for any row that isn't a live paid plan._resumechecks for another live plan. If the first create never reached Stripe and the reader bought a card-billed plan in between, a retry could create a prepaid plan next to it. Portal and cancel would then return 409, so the reader couldn't cancel the card-billed plan in the app. Now:redeemed_promotion_code_idequal to this promotion code, plus the stored row when it points at that subscription.409 has_planwith no Stripe write.Money-safety: changed lines
backend/config/prepaid_code_redeem.py:mode(), whichenabled_fornow uses (same behaviour).backend/routers/payment.pycreate_customer_portal_endpoint: the read also requiresmode() != 'off'.backend/utils/prepaid_code_redemption.py:_has_live_plan(..., own_promotion_code_id)and_open_stripe_subscriptions, which replace_has_open_stripe_subscription;_resume.How it was verified
tests/unit/test_prepaid_code_redemption.py(66), covering:customerandreturn_url;cohortoron, with a free row and a marked Stripe subscription: refused;mode()is an env read only;409 has_plan, with no Stripe write and the promotion code unredeemed; it finishes once that plan has ended.test.shtiming guard passes, andbackend/scripts/typecheck.shhas 0 errors.Not verified
Product invariants affected
none
Line-count exceptions
Line-Count-Exception: backend/routers/payment.py | 2445 -> 2447 | the switch-off skip belongs in the portal endpoint it guards