Fixed comped members having a status of 'paid'

refs https://github.com/TryGhost/Team/issues/995

Since we reintroduced the comped status, we did not update the
subscription handling to correctly set members to a status of comped
when they were on a 'Complimentary' plan.
This commit is contained in:
Fabien O'Carroll 2021-08-17 12:09:27 +02:00
parent dbae9f3233
commit b6e4eae272

View File

@ -57,6 +57,10 @@ module.exports = class MemberRepository {
return ['active', 'trialing', 'unpaid', 'past_due'].includes(status);
}
isComplimentarySubscription(subscription) {
return subscription.plan.nickname && subscription.plan.nickname.toLowerCase() === 'complimentary';
}
async get(data, options) {
if (data.customer_id) {
const customer = await this._StripeCustomer.findOne({
@ -600,7 +604,11 @@ module.exports = class MemberRepository {
const oldMemberProducts = member.related('products').toJSON();
let status = memberProducts.length === 0 ? 'free' : 'comped';
if (this.isActiveSubscriptionStatus(subscription.status)) {
if (this.isComplimentarySubscription(subscription)) {
status = 'comped';
} else {
status = 'paid';
}
if (!model) {
// This is a new subscription! Add the product
if (ghostProduct) {