簡體   English   中英

Python Stripe-獲取所有未訂閱特定計划的客戶

[英]Python Stripe - Get all customers that unsubscribed from a specific plan

假設我有一個名為'pro-plan' ,列出其所有現有訂戶非常簡單

for subscriber in stripe.Subscription.all().auto_paging_iter():
    # do something with this subscriber

我想知道的是,如何確定在給定時間內未訂閱的用戶?

例如,給定start_timestampend_timestamp如何找到未訂閱特定計划的用戶?

Stripe允許您在列出訂閱時傳遞status=canceled檢索已status=canceled 訂閱 (盡管您必須使用2016-07-06版或更高版本的API才能這樣做)。

然后,您需要使用每個訂閱的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM