通过metad中的信息取消条带订阅

2024-06-17 10:30:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在尝试通过解析stripe客户列表并在每个客户中搜索元数据是否匹配来取消订阅。在

目前这不起作用。在

customers = stripe.Customer.list(limit=100)
for c in customers.auto_paging_iter():
    if bool(c.metadata):
        try:
            if user.username == c.metadata.username:
                for s in c.subscriptions.data:
                    subscription = stripe.Subscription.retrieve(s['id'])
                    subscription.delete(at_period_end=True)
                commit()
                return jsonify(status=True)
        except:
            continue

我错过什么了吗?在


Tags: 数据intrue列表for客户ifusername