【发布时间】:2021-12-23 10:36:41
【问题描述】:
我有这个:
app.get('/create-checkout-session', async (req, res) => {
let customer = {
price: req.query.price,
quantity: req.query.number,
page: req.query.page
}
let successurl = 'http://localhost:1111/' + customer.page + ''
let failedurl = 'http://localhost:1111/' + customer.page + ''
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'cad',
product_data: {
name: 'Giveaway Entry',
},
unit_amount: customer.price,
},
quantity: customer.quantity,
},
],
mode: 'payment',
success_url: successurl,
cancel_url: failedurl,
});
console.log(session)
res.redirect(303, session.url);
});
它工作得很好。除了结帐会话完成后,它会将我重定向回我的页面。但它不会将他们输入的电子邮件地址(在条带结帐页面上)存储在会话对象中。所以我是这样记录的:
console.log(session)
然后它返回:
customer_email: null
为什么会发生这种情况,我该如何解决?
【问题讨论】:
标签: javascript node.js stripe-payments