#Sq
1 messages · Page 1 of 1 (latest)
hi, this is the code that im using currently
app.post('/create-checkout-session', async (req, res) => {
const priceId = req.body.priceId
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price: priceId,
quantity: 1,
},
],
mode: 'subscription',
allow_promotion_codes: true,
success_url: `${URL}/auth/subscription/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${URL}/auth/subscription/cancel`,
});
res.json({ id: session.id });
});
how do i add a trial for it?
heya @modern swallow! yes, it's possible, you would add this parameter : https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-trial_period_days
oh trial period days
thank you so much
sorry is this the correct way of coding?
subscription_data: {trial_period_days: 7},
looks correct to me, try it out and let me know if you run into any issues