mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Added cancelAllSubscriptions method
no-issue This gets all subscriptions, filters out ones which have already been cancelled and cancels the rest
This commit is contained in:
parent
18aeed905a
commit
6fe46a79f3
1 changed files with 14 additions and 0 deletions
|
@ -108,6 +108,20 @@ module.exports = class StripePaymentProcessor {
|
|||
};
|
||||
}
|
||||
|
||||
async cancelAllSubscriptions(member) {
|
||||
const subscriptions = await this.getSubscriptions(member);
|
||||
|
||||
const activeSubscriptions = subscriptions.filter((subscription) => {
|
||||
return subscription.status !== 'cancelled';
|
||||
});
|
||||
|
||||
await Promise.all(activeSubscriptions.map((subscription) => {
|
||||
return del(this._stripe, 'subscriptions', subscription.subscription);
|
||||
}));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async getSubscriptions(member) {
|
||||
const metadata = await this.storage.get(member);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue