简体   繁体   English

有没有一种使用Stripe API批量删除客户列表的方法?

[英]Is there a way to bulk delete a list of customers using the Stripe API?

Following a company spinoff, we need to delete a list of ~1200 old customers from our stripe account. 公司分拆之后,我们需要从我们的条带化帐户中删除约1200个老客户的列表。 I'm currently trying to do it using python via their API. 我目前正在尝试通过其API使用python做到这一点。 The code to delete a customer via the API looks like this: 通过API删除客户的代码如下所示:

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

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

I have a csv of all 1200 customers I'd like to delete from my stripe account, but the API won't read them as a list if I paste them into the customer_id field. 我要从条带化帐户中删除所有1200个客户的csv,但是如果我将它们粘贴到customer_id字段中,API不会将它们作为列表读取。 Is there a way to run this bulk delete, or do I have to remove all of my customers one by one? 有什么方法可以运行此批量删除,还是我必须一个一个地删除所有客户?

You could just perform this with a list comprehension: 您可以通过列表理解来执行此操作:

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM