From 1932d56890066ecda2e64b5041e0985a4567e7e7 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Mon, 25 Jan 2021 15:33:49 +0000 Subject: [PATCH] Updated linkSubscription to ensure flag is synced --- ghost/members-api/lib/repositories/member/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ghost/members-api/lib/repositories/member/index.js b/ghost/members-api/lib/repositories/member/index.js index 4d16592601..a16195bde6 100644 --- a/ghost/members-api/lib/repositories/member/index.js +++ b/ghost/members-api/lib/repositories/member/index.js @@ -197,6 +197,20 @@ module.exports = class MemberRepository { ...options, subscription_id: subscription.id }); + + if (this.isActiveSubscriptionStatus(subscription.status)) { + await this._Member.edit({status: 'paid'}, {...options, id: data.id}); + } else { + const subscriptions = await member.related('stripeSubscriptions').fetch(options); + let status = 'free'; + for (const subscription of subscriptions.models) { + if (this.isActiveSubscriptionStatus(subscription.get('status'))) { + status = 'paid'; + break; + } + } + await this._Member.edit({status: status}, {...options, id: data.id}); + } } async updateSubscription(data, options) {