File tree Expand file tree Collapse file tree
packages/ui/src/contexts/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -328,7 +328,7 @@ export const usePlansContext = () => {
328328 clerk . __internal_openCheckout ( {
329329 planId : plan . id ,
330330 // if the plan doesn't support annual, use monthly
331- planPeriod : planPeriod === 'annual' && ! plan . annualMonthlyFee ? 'month' : planPeriod ,
331+ planPeriod : determinePlanPeriod ( plan , planPeriod ) ,
332332 for : subscriberType ,
333333 onSubscriptionComplete : ( ) => {
334334 revalidateAll ( ) ;
@@ -364,3 +364,19 @@ export const usePlansContext = () => {
364364 revalidateAll,
365365 } ;
366366} ;
367+
368+ function determinePlanPeriod ( plan : BillingPlanResource , period : BillingSubscriptionPlanPeriod ) {
369+ if ( ( period === 'month' && plan . fee ) || ( period === 'annual' && plan . annualMonthlyFee ) ) {
370+ return period ;
371+ }
372+
373+ if ( period === 'month' && ! plan . fee ) {
374+ return 'annual' ;
375+ }
376+
377+ if ( period === 'annual' && ! plan . annualMonthlyFee ) {
378+ return 'month' ;
379+ }
380+
381+ return period ;
382+ }
You can’t perform that action at this time.
0 commit comments