Stripe Webhook 事件 - 匹配客户 ID?

Stripe Webhook Events - Matching Customer IDs?

我正在使用 stripe listen --forward-to ... 测试订阅产品并在本地触发事件。我相信我的端点设置正确,因为它可以侦听和接收事件。

问题:事件中的客户 ID 不匹配。

例如customer.created中的id为cus_J6l***Yu0

customer.subscription.created中的id是cus_J6l***yVb

此外,customer.subscription.createdcustomer.subscription.updated 中的订阅 ID 不匹配。 sub_J6l***ikYsub_J6l***ufT 分别。

我不清楚如何将这些事件相互联系起来。在生产环境中,我可以同时让许多不同的客户创建订阅。我的期望是有一个键可以关联客户和他们创建的订阅(或订阅和订阅更新)。

每个 Subscription 完全属于一个 Customer,参见 https://stripe.com/docs/api/subscriptions/object#subscription_object-customer. However, a Customer can have one or more Subscription which probably explains why you see a difference in the subscription ids, i.e. the events are fired for different Subscription but for the same Customer. To view the full list of Subscriptions for a given Customer, see https://stripe.com/docs/api/customers/object#customer_object-subscriptions(注意这是一个 expandable 字段)。