#emmann_48287
1 messages · Page 1 of 1 (latest)
Hello
mode: 'subscription',
line_items: [
{
price: premiumPriceId,
quantity: 1,
},
],
subscription_data: {
trial_settings: {
end_behavior: {
missing_payment_method: 'cancel',
},
},
trial_period_days: 30,
},
customer: customer !== '' ? customer.id : user.seller.stripeCustomerId,
//payment_method_collection: 'if_required',
success_url: ${process.env.BASE_URL}/seller/plano,
cancel_url: ${process.env.BASE_URL}/payment/seller/cancel,
});```
You said: ```basically i want one time 30 days free, no matter user cancel or renew the plan.
So yeah what you need to do here is to authenticate your customer before redirecting them to Checkout and check whether they already have (or had) a Subscription on trial
Then you would show them an error instead of redirecting
(If they previously canceled and are trying to create another Sub with trial)
well i have before users get into the process they are authenticated, user only can purchase a plan after authentication, this why i can't figured out what is really the issue
Yeah so you want to list their Subscriptions before you redirect them to Checkout: https://stripe.com/docs/api/subscriptions/list
Then you can see if they already have or had a Subscription in the past and evaluate from there
okay get it, on what data should i test subscription list, ex: data array in should be empty array or what would you suggest exactly plz?
Yeah I mean that depends on how you want to handle it
If you don't want them to start a new Sub at all if they had any past Subs (canceled or active) then you would want that list to return as empty
okay, but let me be more explicit on handle that, if an user had already any subscription plan in the past with our application, we want to allow him only to renew without 30days granted
you get it now?
Sure then you change the Checkout Session creation to not include the trial
well i understand but i don't get it on the implementation side.
What are you confused about exactly?
based on the code provided
Before the code you provided you would list Subs as we talked about. Then you can have a conditional that says "if they had a past Sub then create a Checkout Session without Trial, otherwise create a Checkout Session with trial"
i get it now. Thank you