我尝试在Checkout Stripe新界面上付款后收到客户的电子邮件。条带Webhook发布的JSON始终会发送具有空值的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"
}
答案 0 :(得分:1)
客户输入的电子邮件实际上位于CheckoutSession链接到的Customer对象上。 [0] customer_email
字段是其他字段(这是您的代码可能已设置为将电子邮件预填充到会话中的字段)。
因此,从API(cus_FoWzBx2yusHfs9
)中检索Customer对象,并检查其中的email
字段;或检索会话对象和expand the Customer field.
[0]-https://stripe.com/docs/api/customers/object#customer_object-email