Added guards for stripe_plans setting being null

no-issue

There is concern that the settings cache can return `null` for values
which it cannot parse correctly, this just ensures that we always have
an array where we expect one
This commit is contained in:
Fabien O'Carroll 2020-07-07 13:10:10 +02:00
parent 8675a7d317
commit 694d92d270

View File

@ -62,7 +62,7 @@ class MembersConfigProvider {
};
try {
const plans = this._settingsCache.get('stripe_plans');
const plans = this._settingsCache.get('stripe_plans') || [];
const priceData = plans.reduce((prices, plan) => {
const numberAmount = 0 + plan.amount;
@ -177,7 +177,7 @@ class MembersConfigProvider {
product: {
name: this._settingsCache.get('stripe_product_name')
},
plans: [COMPLIMENTARY_PLAN].concat(this._settingsCache.get('stripe_plans')),
plans: [COMPLIMENTARY_PLAN].concat(this._settingsCache.get('stripe_plans') || []),
appInfo: {
name: 'Ghost',
partner_id: 'pp_partner_DKmRVtTs4j9pwZ',