mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Refactored getActiveSubscriptions to getSubscriptions
no-issue
This commit is contained in:
parent
ea5503f58d
commit
18aeed905a
1 changed files with 10 additions and 9 deletions
|
@ -108,7 +108,7 @@ module.exports = class StripePaymentProcessor {
|
|||
};
|
||||
}
|
||||
|
||||
async getActiveSubscriptions(member) {
|
||||
async getSubscriptions(member) {
|
||||
const metadata = await this.storage.get(member);
|
||||
|
||||
const customers = await Promise.all(metadata.map(async (data) => {
|
||||
|
@ -134,17 +134,10 @@ module.exports = class StripePaymentProcessor {
|
|||
if (!subscription.plan) {
|
||||
return subscriptions;
|
||||
}
|
||||
// Ignore cancelled subscriptions
|
||||
if (subscription.status === 'cancelled') {
|
||||
return subscriptions;
|
||||
}
|
||||
// Ignore unpaid subscriptions
|
||||
if (subscription.status === 'unpaid') {
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
return subscriptions.concat([{
|
||||
customer: customer.id,
|
||||
status: subscription.status,
|
||||
subscription: subscription.id,
|
||||
plan: subscription.plan.id,
|
||||
name: subscription.plan.nickname,
|
||||
|
@ -155,6 +148,14 @@ module.exports = class StripePaymentProcessor {
|
|||
}, []);
|
||||
}
|
||||
|
||||
async getActiveSubscriptions(member) {
|
||||
const subscriptions = await this.getSubscriptions(member);
|
||||
|
||||
return subscriptions.filter((subscription) => {
|
||||
return subscription.status !== 'cancelled' && subscription.status !== 'unpaid';
|
||||
});
|
||||
}
|
||||
|
||||
async addCustomerToMember(member, customer) {
|
||||
const metadata = await this.storage.get(member);
|
||||
// Do not add the customer if they are already linked
|
||||
|
|
Loading…
Add table
Reference in a new issue