fix(billing): send the plan name from route params under Next 16#245
Merged
Conversation
/checkout/pro and /checkout/scale failed with "Plan cannot be purchased" for every user since the Next 16 upgrade (ea1b00c). The checkout page still typed `params` as a plain object and read `params.planName` synchronously. Next 16 removed the sync compat shim, so the value was undefined, axios dropped the key, and the API ran findOne({ name: undefined }). Mongoose 9 returns null for that where older versions stripped the key, so the guard threw a message about a misconfigured plan for a request that never named one. Plan data and Polar product ids were correct throughout. - unwrap params with React's use() and drop the `as string` cast that suppressed the type error - split the conflated guard into PLAN_NAME_REQUIRED, PLAN_NOT_FOUND and the existing unpurchasable case, each logged server side - stop retrying a rejected checkout twice: a 400 is not transient - mark the Polar product id indexes sparse, they have been failing to build with E11000 on every boot because most plans leave them unset Checkout now defaults to yearly. A URL that names an interval still redirects straight through, so the marketing funnel is unchanged; the in-app CTAs that name none get an interval chooser with yearly preselected instead of a silent monthly default. Also redesigns the checkout states, which were the only place in the dashboard hardcoding gray-100/white and so rendering a light slab in dark mode, and the plan picker, which painted the accent on every tier. Tests: a checkout e2e spec asserting the request body carries planName, which is what would have caught this, plus API cases pinning the three guard failures apart. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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.
/checkout/pro and /checkout/scale failed with "Plan cannot be purchased" for every user since the Next 16 upgrade (ea1b00c).
The checkout page still typed
paramsas a plain object and readparams.planNamesynchronously. Next 16 removed the sync compat shim, so the value was undefined, axios dropped the key, and the API ran findOne({ name: undefined }). Mongoose 9 returns null for that where older versions stripped the key, so the guard threw a message about a misconfigured plan for a request that never named one. Plan data and Polar product ids were correct throughout.as stringcast that suppressed the type errorCheckout now defaults to yearly. A URL that names an interval still redirects straight through, so the marketing funnel is unchanged; the in-app CTAs that name none get an interval chooser with yearly preselected instead of a silent monthly default.
Also redesigns the checkout states, which were the only place in the dashboard hardcoding gray-100/white and so rendering a light slab in dark mode, and the plan picker, which painted the accent on every tier.
Tests: a checkout e2e spec asserting the request body carries planName, which is what would have caught this, plus API cases pinning the three guard failures apart.