Last active
June 1, 2022 14:37
-
-
Save Dzhuneyt/b183a488874bfa7055b9167f9a889578 to your computer and use it in GitHub Desktop.
Delete all Customers in a Stripe account - through the Stripe SDK for JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Stripe} from 'stripe'; | |
const STRIPE_API_KEY = process.env.STRIPE_API_KEY; | |
const s = new Stripe(STRIPE_API_KEY, { | |
apiVersion: "2020-08-27", | |
}); | |
const deletePage = async () => { | |
const customers = await s.customers.list(); | |
for (let customer of customers.data) { | |
const before = new Date().getTime(); | |
await s.customers.del(customer.id); | |
const after = new Date().getTime(); | |
console.log('Deleted', customer.id, 'in', after - before, 'ms'); | |
} | |
if (customers.has_more) { | |
console.log('Going to next page...'); | |
await deletePage(); | |
} | |
} | |
deletePage().then(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: