mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Fixed Portal showing paid Tiers when Stripe not connected
closes https://github.com/TryGhost/Team/issues/2197 Portal was relying on monthlyPrice or yearlyPrice being undefined as a proxy to determine whether or not to show paid plans, this fixes it to check for whether or not stripe is enabled. I did consider using the portal_plans array to filter out unselected Tiers, but wasn't sure of the repercussions, though it does seem like the correct fix long term.
This commit is contained in:
parent
ba41f308c7
commit
743228ff1c
2 changed files with 19 additions and 1 deletions
|
@ -300,6 +300,11 @@ export function getAvailableProducts({site}) {
|
|||
}
|
||||
|
||||
return products.filter(product => !!product).filter((product) => {
|
||||
if (site.is_stripe_configured) {
|
||||
return true;
|
||||
}
|
||||
return product.type !== 'paid';
|
||||
}).filter((product) => {
|
||||
return !!(product.monthlyPrice && product.yearlyPrice);
|
||||
}).filter((product) => {
|
||||
return !!(Object.keys(product.monthlyPrice).length > 0 && Object.keys(product.yearlyPrice).length > 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {getCurrencySymbol, getFreeProduct, getMemberName, getMemberSubscription, getPriceFromSubscription, getPriceIdFromPageQuery, getSupportAddress, getUrlHistory, hasMultipleProducts, isActiveOffer, isInviteOnlySite, isPaidMember, isSameCurrency, transformApiTiersData} from './helpers';
|
||||
import {getAvailableProducts, getCurrencySymbol, getFreeProduct, getMemberName, getMemberSubscription, getPriceFromSubscription, getPriceIdFromPageQuery, getSupportAddress, getUrlHistory, hasMultipleProducts, isActiveOffer, isInviteOnlySite, isPaidMember, isSameCurrency, transformApiTiersData} from './helpers';
|
||||
import * as Fixtures from './fixtures-generator';
|
||||
import {site as FixturesSite, member as FixtureMember, offer as FixtureOffer, transformTierFixture as TransformFixtureTiers} from '../utils/test-fixtures';
|
||||
import {isComplimentaryMember} from '../utils/helpers';
|
||||
|
@ -294,4 +294,17 @@ describe('Helpers - ', () => {
|
|||
expect(urlHistory).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAvailableProducts', () => {
|
||||
it('Does not include paid Tiers when stripe is not configured', () => {
|
||||
const actual = getAvailableProducts({
|
||||
site: {
|
||||
...FixturesSite.multipleTiers.basic,
|
||||
is_stripe_configured: false
|
||||
}
|
||||
});
|
||||
|
||||
expect(actual.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue