[英]Python Stripe - Get all customers that unsubscribed from a specific plan
Say I have a plan called 'pro-plan'
, listing all its existing subscribers is quite straightforward 假设我有一个名为'pro-plan'
,列出其所有现有订户非常简单
for subscriber in stripe.Subscription.all().auto_paging_iter():
# do something with this subscriber
What I was wondering, is how can figure out users that unsubscribed in a given timeframe? 我想知道的是,如何确定在给定时间内未订阅的用户?
For example, given start_timestamp
and end_timestamp
how can I find users who have unsubscribed from a specific plan? 例如,给定start_timestamp
和end_timestamp
如何找到未订阅特定计划的用户?
Stripe lets you retrieve canceled subscriptions by passing status=canceled
when listing subscriptions (though you need to be on API version 2016-07-06 or more recent to do so). Stripe允许您在列出订阅时传递status=canceled
检索已status=canceled
订阅 (尽管您必须使用2016-07-06版或更高版本的API才能这样做)。
You'd then need to filter on your end to keep the subscriptions that were canceled during the timeframe you're interested in, using each subscription's canceled_at
attribute. 然后,您需要使用每个订阅的canceled_at
属性在一端进行过滤,以保留在感兴趣的时间段内被取消的订阅。
subscriptions = stripe.Subscription.list(plan='pro-plan', status='canceled')
for subscription in subscriptions.auto_paging_iter():
if start_timestamp <= subscription.canceled_at <= end_timestamp:
# Do something with subscription
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.