[英]how to add trial period in Checkout session in Stripe
I have this code:我有这个代码:
const session = await stripe.checkout.sessions.create({
billing_address_collection: 'auto',
payment_method_types: ['card'],
customer_email: email,
line_items: [
{
price: priceID,
// For metered billing, do not pass quantity
quantity: 1,
},
],
// subscription_data:
mode: 'subscription',
success_url: `${YOUR_DOMAIN}/gen_trainerclientlist`,
cancel_url: `${YOUR_DOMAIN}/cancel.html`,
});
and I want to add this:我想补充一点:
subscription_data: {
trial_end=1605387163
}
but whereever I put it, it doesn't work?但无论我把它放在哪里,它都不起作用? How do i fix this?
我该如何解决?
For future reference, what I was doing wrong was the way I was defining trial_end
.为了将来参考,我做错的是我定义
trial_end
的方式。
this is the function at a whole:这是 function 的整体:
var priceID = "price_1K6dU7IPT89VeZtCF2YLsVNo"
console.log(priceID)
const session = await stripe.checkout.sessions.create({
billing_address_collection: 'auto',
payment_method_types: ['card'],
customer_email: email,
line_items: [
{
price: priceID,
// For metered billing, do not pass quantity
quantity: 1,
},
],
subscription_data: {
trial_end: Math.floor(+new Date() / 1000) + 15 * 24 * 60 * 60,
},
mode: 'subscription',
success_url: `${YOUR_DOMAIN}/success`,
cancel_url: `${YOUR_DOMAIN}/login`,
});
res.redirect(303, session.url)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.