mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-25 02:31:59 -05:00
Added helper for determining active subscriptions
This commit is contained in:
parent
02990ce7e5
commit
f9dbeafbbb
1 changed files with 5 additions and 1 deletions
|
@ -25,6 +25,10 @@ module.exports = class MemberRepository {
|
||||||
this._logging = logger;
|
this._logging = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isActiveSubscriptionStatus(status) {
|
||||||
|
return ['active', 'trialing', 'unpaid', 'past_due'].includes(status);
|
||||||
|
}
|
||||||
|
|
||||||
async get(data, options) {
|
async get(data, options) {
|
||||||
if (data.customer_id) {
|
if (data.customer_id) {
|
||||||
const customer = await this._StripeCustomer.findOne({
|
const customer = await this._StripeCustomer.findOne({
|
||||||
|
@ -242,7 +246,7 @@ module.exports = class MemberRepository {
|
||||||
const subscriptions = await member.related('stripeSubscriptions').fetch(options);
|
const subscriptions = await member.related('stripeSubscriptions').fetch(options);
|
||||||
|
|
||||||
const activeSubscriptions = subscriptions.models.filter((subscription) => {
|
const activeSubscriptions = subscriptions.models.filter((subscription) => {
|
||||||
return ['active', 'trialing', 'unpaid', 'past_due'].includes(subscription.get('status'));
|
return this.isActiveSubscriptionStatus(subscription.get('status'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// NOTE: Because we allow for multiple Complimentary plans, need to take into account currently availalbe
|
// NOTE: Because we allow for multiple Complimentary plans, need to take into account currently availalbe
|
||||||
|
|
Loading…
Add table
Reference in a new issue