在 Stripe 中查找自动取消的订阅?
Find automatically cancelled subscriptions in Stripe?
我已将我的 Stripe 订阅设置为在 3 次付款尝试失败后自动取消。
1) 有没有办法从订阅删除的 webhook 中判断订阅是因为付款尝试失败而被 stripe 删除,还是因为我们提出的 API 取消请求而被我们删除?
2) 我可以使用 api 或仪表板查找一些被 Stripe 自动取消的示例订阅吗?
1) 是的,通过检查 event object's request
属性。如果事件是 API 请求的结果,则 request
将具有非空值。如果事件是 Stripe 自动操作的结果,那么 request
将为空。
因此对于 customer.subscription.deleted
events, request
will be non-null if you used the API to cancel the subscription,如果在支付失败次数过多后自动取消订阅,则为 null。
2) 不是通过仪表板,而是使用 API,您可以 list all events with type
设置为 customer.subscription.deleted
,然后过滤结果以仅保留 request=null
的事件.
请记住,所有 "list" 每次调用仅 return 有限数量的资源(默认情况下为 10 个,使用 limit
parameter). You might need to use issue several calls with pagination parameters in order to retrieve the entire list. Most of Stripe's official language libraries support an auto-pagination 功能最多可达到 100 个,以简化此过程.
我已将我的 Stripe 订阅设置为在 3 次付款尝试失败后自动取消。
1) 有没有办法从订阅删除的 webhook 中判断订阅是因为付款尝试失败而被 stripe 删除,还是因为我们提出的 API 取消请求而被我们删除?
2) 我可以使用 api 或仪表板查找一些被 Stripe 自动取消的示例订阅吗?
1) 是的,通过检查 event object's request
属性。如果事件是 API 请求的结果,则 request
将具有非空值。如果事件是 Stripe 自动操作的结果,那么 request
将为空。
因此对于 customer.subscription.deleted
events, request
will be non-null if you used the API to cancel the subscription,如果在支付失败次数过多后自动取消订阅,则为 null。
2) 不是通过仪表板,而是使用 API,您可以 list all events with type
设置为 customer.subscription.deleted
,然后过滤结果以仅保留 request=null
的事件.
请记住,所有 "list" 每次调用仅 return 有限数量的资源(默认情况下为 10 个,使用 limit
parameter). You might need to use issue several calls with pagination parameters in order to retrieve the entire list. Most of Stripe's official language libraries support an auto-pagination 功能最多可达到 100 个,以简化此过程.