为什么 Stripe checkout Webhooks 将 customer_email 发送到 null? [英] Why does Stripe checkout Webhooks send customer_email to null?

查看:21
本文介绍了为什么 Stripe checkout Webhooks 将 customer_email 发送到 null?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Checkout Stripe 新界面上付款后收到客户的电子邮件.stripe Webhook 发布的 JSON 总是发送带有 null 值的 customer_email.

I try to get the customer email after a payment on Checkout Stripe new interface. The JSON posted by stripe Webhook always send customer_email with null value.

stripe Checkout 页面要求提供客户电子邮件,所以我不明白为什么 Stripe 将此值发送回 null.

The stripe Checkout page ask for customer email so I don't understand why Stripe send back this value to null.

不过,客户价值不为空.

Though, customer value is not 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"
}

推荐答案

客户输入的电子邮件实际上位于 CheckoutSession 链接到的 Customer 对象上.[0] customer_email 字段是别的东西(它是您的代码可能已设置为将电子邮件预填充到会话中的字段).

The email the customer entered is actually on the Customer object that the CheckoutSession links to. [0] The customer_email field is something else(it's the field that your code might have set to prefill an email into the Session).

因此从 API (cus_FoWzBx2yusHfs9) 中检索 Customer 对象并检查那里的 email 字段;或检索 Session 对象并展开客户字段.

So retrieve the Customer object from the API (cus_FoWzBx2yusHfs9) and check the email field there; or retrieve the Session object and expand the Customer field.

[0] - https://stripe.com/docs/api/客户/对象#customer_object-email

这篇关于为什么 Stripe checkout Webhooks 将 customer_email 发送到 null?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆