#Sq

1 messages · Page 1 of 1 (latest)

inland swallow
modern swallow
#

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?

inland swallow
modern swallow
#

oh trial period days

#

thank you so much

#

sorry is this the correct way of coding?

#

subscription_data: {trial_period_days: 7},

inland swallow
#

looks correct to me, try it out and let me know if you run into any issues

modern swallow
#

great its working now!

#

i was trying just trial_period_days: 7 initially and it broke the app haha

#

thank you for your help