Repository navigation
feat(payments): redeem a promotion code onto an existing subscription - #23588
Merged
Merged
Conversation
A code with a minimum amount can't be entered at a free-trial checkout: Stripe checks the minimum against today's total, which is zero during the trial. POST /v1/payments/redeem-code checks the code against the plan price and attaches its coupon to the caller's subscription, so the discount lands on the first invoice after the trial. A Firestore claim keeps each code single-use. The web app's plan settings get a Redeem a code field.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
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.
Summary
Refs #23299. Unlimited yearly activation codes carry a minimum order amount. A first-time buyer's checkout starts with a 7-day free trial, so the total due today is zero, and Stripe rejects the code against that zero in every currency ("your order doesn't meet the minimum amount"). Stripe also refuses codes with a minimum on subscription updates.
This adds
POST /v1/payments/redeem-code(routers/redeem_code.py). The buyer starts the plan (trial or paid) without the code, then redeems the code onto that subscription:The web app's plan settings get a "Redeem a code" field while a subscription exists, so this works without an app release.
Product invariants
none
Test plan
tests/unit/test_promotion_redemption.py: trial redemption attaches the coupon and uses up the code; monthly (below the minimum), another product, unknown, used and expired codes, a lost claim race, canceled or canceling subscriptions and an existing discount are refused; a failed Stripe update gives the code back; the endpoint returns refusals as client errors.tests/unit/test_payment_checkout_trial.pyorigin/mainbun run typecheck, vitestsrc/components/settingsFailure-Class: none
🤖 Generated with Claude Code