Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 by cubic
Preserves existing Stripe discounts across subscription updates and plan switches by sending the correct params, and ensures checkout sessions only use coupon/promo code. Prevents new discount creation and duration resets.
Bug Fixes
Tests
Written for commit 50f0257. Summary will update on new commits.
Greptile Summary
This PR fixes a critical bug in discount handling during subscription updates. Previously, when customers upgraded/downgraded between products or performed cancel/uncancel operations, their discount durations were being reset instead of preserved.
Key Changes
Bug fixes:
{ discount: id }instead of{ coupon: id }for existing discountsstripeDiscountsToCheckoutParamsfunctionImprovements:
The fix ensures that if a customer has a 3-month discount and uses 1 month, they retain only 2 months remaining after product changes - rather than getting a fresh 3-month discount.
Confidence Score: 5/5
{ discount: id }) and checkout sessions (which only support{ coupon }or{ promotion_code }). Type safety ensuressource.couponalways exists on discount objects, and comprehensive test coverage validates all critical scenarios including edge cases like deleted coupons and phase transitions.Important Files Changed
stripeDiscountsToParamsfor subscription updates (preserves existing discount IDs) andstripeDiscountsToCheckoutParamsfor checkout sessions (only supports coupon/promo code). Core fix that prevents discount duration from being reset.stripeDiscountsToCheckoutParamsinstead ofstripeDiscountsToParams, correctly handling checkout session discount format restrictions.Last reviewed commit: 50f0257