为啥 Stripe checkout Webhooks 会将 customer_email 发送为 null?
Posted
技术标签:
【中文标题】为啥 Stripe checkout Webhooks 会将 customer_email 发送为 null?【英文标题】:Why does Stripe checkout Webhooks send customer_email to null?为什么 Stripe checkout Webhooks 会将 customer_email 发送为 null? 【发布时间】:2020-01-16 12:19:15 【问题描述】:我尝试在 Checkout Stripe 新界面上付款后获取客户电子邮件。 stripe Webhook 发布的 JSON 总是发送带有 null 值的 customer_email。
stripe Checkout 页面要求提供客户电子邮件,所以我不明白为什么 Stripe 会将此值发送回 null。
虽然,客户价值不为空。
"id": "evt_1FItv8Kj5elW7ZcvEuY6",
"object": "event",
"api_version": "2019-03-14",
"created": 1568539286,
"data":
"object":
"id": "cs_test_123123123",
"object": "checkout.session",
"billing_address_collection": null,
"cancel_url": "https://www.example.fr/canceled",
"client_reference_id": null,
"customer": "cus_FoWzBx2yusHfs9",
"customer_email": null,
"display_items": [
"amount": 1000,
"currency": "eur",
"quantity": 1,
"sku":
"id": "sku_1234567",
"object": "sku",
"active": true,
"attributes":
"name": "Product test"
,
"created": 1568538814,
"currency": "eur",
"image": null,
"inventory":
"quantity": null,
"type": "infinite",
"value": null
,
"livemode": false,
"metadata":
,
"package_dimensions": null,
"price": 1000,
"product": "prod_FoWr00dX3",
"updated": 1568538814
,
"type": "sku"
],
"livemode": false,
"locale": null,
"mode": "payment",
"payment_intent": "pi_1FItj5elW70Z2",
"payment_method_types": [
"card"
],
"setup_intent": null,
"submit_type": null,
"subscription": null,
"success_url": "https://www.example.fr/success"
,
"livemode": false,
"pending_webhooks": 1,
"request":
"id": null,
"idempotency_key": null
,
"type": "checkout.session.completed"
【问题讨论】:
【参考方案1】:客户输入的电子邮件实际上位于 CheckoutSession 链接到的客户对象上。 [0] customer_email
字段是其他内容(您的代码可能设置了该字段以将电子邮件预填充到会话中)。
所以从 API (cus_FoWzBx2yusHfs9
) 中检索 Customer 对象并检查那里的 email
字段;或检索 Session 对象和expand the Customer field.
[0] - https://stripe.com/docs/api/customers/object#customer_object-email
【讨论】:
以上是关于为啥 Stripe checkout Webhooks 会将 customer_email 发送为 null?的主要内容,如果未能解决你的问题,请参考以下文章
使用 Python Flask 自定义 Stripe Checkout
如何在 Stripe 的 Checkout 会话中添加试用期
Stripe - 如何在 Checkout.Session 中获取账单地址信息