[英]retrieve customer email on stripe after checkout session node.js
我有這個:
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
為什么會發生這種情況,我該如何解決?
Checkout Session 的customer_email
屬性用於創建一個帶有預填充電子郵件的 Checkout 會話 [1]。 要查看您的客戶在結帳表單中輸入的電子郵件,請檢查會話的customer_details.email
屬性 [2]。
[1] https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer_email
[2] https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer_details-email
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.