【问题标题】: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"
}

【问题讨论】:

    标签: stripe-payments webhooks


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-18
      • 2021-03-26
      • 1970-01-01
      • 2021-03-07
      • 1970-01-01
      • 1970-01-01
      • 2019-09-11
      • 2019-11-25
      相关资源
      最近更新 更多