Upgrade User Subscription Plan From Trial (Stripe)
Currently i m experiencing challenge upgrading a user from a Trial account to a Paid or desired Plan. Also to downgrade from a particular plan to the desired plan. Currently it only tries to create new trial plans instead of cancelling the trial or upgrading to a paid one. How do i make this possible?
const session = await authClient.subscription.upgrade({
plan: planName.toLowerCase(), // Ensure consistent case
successUrl:
cancelUrl:
referenceId: orgId,
subscriptionId: currentSubscription.id,
metadata: {
conversion_type: 'trial_conversion',
plan_name: planName,
organization_id: orgId,
trial_subscription_id: currentSubscription.id,
stripe_customer_id: currentSubscription.stripeCustomerId,
is_trial_conversion: 'true'
}
});
const session = await authClient.subscription.upgrade({
plan: planName.toLowerCase(), // Ensure consistent case
successUrl:
${baseUrl}/subscription/success?plan=${encodeURIComponent(planName)}&orgId=${encodeURIComponent(orgId)}&from_trial=true,cancelUrl:
${baseUrl}/upgrade-from-trial?canceled=true,referenceId: orgId,
subscriptionId: currentSubscription.id,
metadata: {
conversion_type: 'trial_conversion',
plan_name: planName,
organization_id: orgId,
trial_subscription_id: currentSubscription.id,
stripe_customer_id: currentSubscription.stripeCustomerId,
is_trial_conversion: 'true'
}
});