#emmann_48287

1 messages · Page 1 of 1 (latest)

outer falconBOT
honest river
#

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)

iron loom
#

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

honest river
#

Then you can see if they already have or had a Subscription in the past and evaluate from there

iron loom
#

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?

outer falconBOT
iron loom
#

to test that user already have a subscription plan

#

?

honest river
#

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

iron loom
#

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?

honest river
#

Sure then you change the Checkout Session creation to not include the trial

iron loom
#

well i understand but i don't get it on the implementation side.

honest river
#

What are you confused about exactly?

iron loom
#

based on the code provided

honest river
#

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"

iron loom
#

i get it now. Thank you