From ecf718b02874805ecb9e0a9e1b186e72a44c93bd Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Fri, 13 Mar 2020 11:54:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20complimentary=20plan=20c?= =?UTF-8?q?urrency=20change=20when=20yearly=20currency=20was=20changed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Ghost/issues/11649 - The bug was changing all complimentary plan prices to the value of yearly. - This is another point to putting in place validation of plan setting object on the server side so we don't accidentally allow values like this to slip through --- ghost/admin/app/components/gh-members-lab-setting.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/gh-members-lab-setting.js b/ghost/admin/app/components/gh-members-lab-setting.js index b7da4dff2c..85552d97bf 100644 --- a/ghost/admin/app/components/gh-members-lab-setting.js +++ b/ghost/admin/app/components/gh-members-lab-setting.js @@ -63,7 +63,7 @@ export default Component.extend({ return (proc.adapter === 'stripe'); }); let monthlyPlan = stripeProcessor.config.plans.find(plan => plan.interval === 'month'); - let yearlyPlan = stripeProcessor.config.plans.find(plan => plan.interval === 'year'); + let yearlyPlan = stripeProcessor.config.plans.find(plan => plan.interval === 'year' && plan.name !== 'Complimentary'); // NOTE: need to be careful about division by zero if we introduce zero decimal currencies // ref.: https://stripe.com/docs/currencies#zero-decimal @@ -136,7 +136,7 @@ export default Component.extend({ } if (key === 'month' || key === 'year') { stripeConfig.plans = stripeConfig.plans.map((plan) => { - if (key === plan.interval) { + if (key === plan.interval && plan.name !== 'Complimentary') { plan.amount = parseInt(event.target.value) ? (event.target.value * 100) : 0; } return plan;