File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export async function POST(req: NextRequest) {
4444 const rawTier = Number ( body ?. tier )
4545 if ( ! rawTier || ! ( rawTier in SUBSCRIPTION_TIERS ) ) {
4646 return NextResponse . json (
47- { error : ' Invalid tier. Must be 100, 200, or 500.' } ,
47+ { error : ` Invalid tier. Must be one of: ${ Object . keys ( SUBSCRIPTION_TIERS ) . join ( ', ' ) } .` } ,
4848 { status : 400 } ,
4949 )
5050 }
Original file line number Diff line number Diff line change @@ -22,11 +22,15 @@ export async function POST(req: NextRequest) {
2222
2323 const userId = session . user . id
2424
25- const body = await req . json ( ) . catch ( ( ) => ( { } ) )
26- const rawTier = Number ( body . tier )
27- const tier = ( rawTier && rawTier in SUBSCRIPTION_TIERS
28- ? rawTier
29- : 200 ) as SubscriptionTierPrice
25+ const body = await req . json ( ) . catch ( ( ) => null )
26+ const rawTier = Number ( body ?. tier )
27+ if ( ! rawTier || ! ( rawTier in SUBSCRIPTION_TIERS ) ) {
28+ return NextResponse . json (
29+ { error : `Invalid tier. Must be one of: ${ Object . keys ( SUBSCRIPTION_TIERS ) . join ( ', ' ) } .` } ,
30+ { status : 400 } ,
31+ )
32+ }
33+ const tier = rawTier as SubscriptionTierPrice
3034
3135 const priceId = getPriceIdFromTier ( tier )
3236 if ( ! priceId ) {
@@ -77,7 +81,7 @@ export async function POST(req: NextRequest) {
7781 type : 'strong_subscription' ,
7882 } ,
7983 subscription_data : {
80- description : `Codebuff Strong — $${ tier } /mo unlimited coding sessions ` ,
84+ description : `Codebuff Strong — $${ tier } /mo` ,
8185 metadata : {
8286 userId,
8387 } ,
You can’t perform that action at this time.
0 commit comments