@@ -69,45 +69,30 @@ export function Subscription({ onOpenChange }: SubscriptionProps) {
6969 const currentUrl = window . location . origin + window . location . pathname
7070
7171 try {
72- if (
73- 'upgrade' in betterAuthSubscription &&
74- typeof betterAuthSubscription . upgrade === 'function'
75- ) {
76- const upgradeParams : any = {
77- plan : targetPlan ,
78- referenceId,
79- successUrl : currentUrl ,
80- cancelUrl : currentUrl ,
81- seats : targetPlan === 'team' ? 1 : undefined ,
82- }
83-
84- // Add subscriptionId if we have an existing subscription to ensure proper plan switching
85- if ( currentSubscriptionId ) {
86- upgradeParams . subscriptionId = currentSubscriptionId
87- logger . info ( 'Upgrading existing subscription' , {
88- targetPlan,
89- currentSubscriptionId,
90- referenceId,
91- } )
92- } else {
93- logger . info ( 'Creating new subscription (no existing subscription found)' , {
94- targetPlan,
95- referenceId,
96- } )
97- }
72+ const upgradeParams : any = {
73+ plan : targetPlan ,
74+ referenceId,
75+ successUrl : currentUrl ,
76+ cancelUrl : currentUrl ,
77+ seats : targetPlan === 'team' ? 1 : undefined ,
78+ }
9879
99- await betterAuthSubscription . upgrade ( upgradeParams )
80+ // Add subscriptionId if we have an existing subscription to ensure proper plan switching
81+ if ( currentSubscriptionId ) {
82+ upgradeParams . subscriptionId = currentSubscriptionId
83+ logger . info ( 'Upgrading existing subscription' , {
84+ targetPlan,
85+ currentSubscriptionId,
86+ referenceId,
87+ } )
10088 } else {
101- logger . warn ( 'Stripe upgrade not available - development mode or missing configuration ', {
89+ logger . info ( 'Creating new subscription (no existing subscription found) ', {
10290 targetPlan,
10391 referenceId,
104- betterAuthSubscription : typeof betterAuthSubscription ,
10592 } )
106-
107- alert (
108- `Upgrade to ${ targetPlan } plan - Stripe integration not available in development mode`
109- )
11093 }
94+
95+ await betterAuthSubscription . upgrade ( upgradeParams )
11196 } catch ( error ) {
11297 logger . error ( 'Failed to initiate subscription upgrade:' , error )
11398 alert ( 'Failed to initiate upgrade. Please try again or contact support.' )
0 commit comments