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

🐛 Fixed complimentary plan currency change when yearly currency was changed

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
This commit is contained in:
Nazar Gargol 2020-03-13 11:54:03 +08:00
parent da3f92fac4
commit ecf718b028

View file

@ -63,7 +63,7 @@ export default Component.extend({
return (proc.adapter === 'stripe'); return (proc.adapter === 'stripe');
}); });
let monthlyPlan = stripeProcessor.config.plans.find(plan => plan.interval === 'month'); 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 // NOTE: need to be careful about division by zero if we introduce zero decimal currencies
// ref.: https://stripe.com/docs/currencies#zero-decimal // ref.: https://stripe.com/docs/currencies#zero-decimal
@ -136,7 +136,7 @@ export default Component.extend({
} }
if (key === 'month' || key === 'year') { if (key === 'month' || key === 'year') {
stripeConfig.plans = stripeConfig.plans.map((plan) => { 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; plan.amount = parseInt(event.target.value) ? (event.target.value * 100) : 0;
} }
return plan; return plan;