【问题标题】:Is there a way to bulk delete a list of customers using the Stripe API?有没有办法使用 Stripe API 批量删除客户列表?
【发布时间】:2019-04-04 19:52:27
【问题描述】:

在公司分拆后,我们需要从我们的条带帐户中删除约 1200 名老客户的列表。我目前正在尝试通过他们的 API 使用 python 来做到这一点。通过 API 删除客户的代码如下所示:

import stripe
stripe.api_key = "test-api-key"

cu = stripe.Customer.retrieve("customer_id")
cu.delete()

我有一个包含所有 1200 个客户的 csv,我想从我的条带帐户中删除,但如果我将它们粘贴到 customer_id 字段中,API 不会将它们作为列表读取。有没有办法运行这个批量删除,还是我必须一个一个地删除我的所有客户?

【问题讨论】:

    标签: python stripe-payments


    【解决方案1】:

    您可以通过列表理解来执行此操作:

    import stripe
    stripe.api_key = "test-api-key"
    
    list_of_customers = ['customer_1','customer_2','customer_3']
    [stripe.Customer.retrieve(i).delete() for i in list_of_customers]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-29
      • 1970-01-01
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多