生意失败了,我该怎么办?仪表板不允许我用一个简单的命令一次一次地取消所有订阅和计划。
发布于 2022-05-03 03:11:16
当您需要取消所有客户的订阅时,我不得不创建我称之为“世界末日”的脚本,或者至少要取消相当数量的客户订阅。
步骤:
fml.js
const stripe = require('stripe')('your api key goes here');
const subscriptions = [
// paste all subscriptions ids here or parse the array from the first column of the CSV file
];
async function cancelSubscription(s) {
try {
const deleted = await stripe.subscriptions.del(s);
console.log(deleted.id);
} catch (e) {
console.log(e)
}
}
function delay(t, val) {
return new Promise(function(resolve) {
setTimeout(function() {
resolve(val);
}, t);
});
}
(async () => {
for (const sub of subscriptions) {
await cancelSubscription(sub)
await delay(1000) // this delay prevents going over the API limit, you can decrease it
// but you'll miss the opportunity to say goodbye to the ids rolling through your screen
}
})()祝你一切顺利,愿你永远不用使用这段代码。
https://stackoverflow.com/questions/72094460
复制相似问题