0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Fixed incomplete subscription flow (#341)

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

Because we were only attempting to add the product to the members if the
subscription was new AND active - we would not add it for incomplete
subscriptions transitioning to active.

Instead we always attempt to add the product to a member for an active
subscription - it doesn't matter if it's a new one. We later have logic
to filter out duplicate products if the member already has access to the
product.
This commit is contained in:
Fabien 'egg' O'Carroll 2021-10-18 14:25:28 +02:00 committed by GitHub
parent 47ad10629e
commit 9e3136cdbc

View file

@ -625,15 +625,13 @@ module.exports = class MemberRepository {
} else {
status = 'paid';
}
if (!model) {
// This is a new subscription! Add the product
if (ghostProduct) {
memberProducts.push(ghostProduct.toJSON());
}
} else {
// This is an active subscription! Add the product
if (ghostProduct) {
memberProducts.push(ghostProduct.toJSON());
}
if (model) {
if (model.get('stripe_price_id') !== subscriptionData.stripe_price_id) {
// The subscription has changed plan - we may need to update the products
memberProducts.push(ghostProduct.toJSON());
const subscriptions = await member.related('stripeSubscriptions').fetch(options);
const changedProduct = await this._productRepository.get({