mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
🐛 Fixed sending non-integer prices to Tiers API
refs https://github.com/TryGhost/Team/issues/1319 Due to how JS implements numbers, it's possible that when we multiple a number with 2 decimal places by 100 that we do not end up with an integer e.g. 9.95 * 100 = 994.999... This is not a valid price for the API and so we must round it to the nearest integer. Rounding is safe here, because the errors involved in floating point operations are very small.
This commit is contained in:
parent
a2b631f8b6
commit
047f28177f
@ -259,8 +259,8 @@ export default class MembersAccessController extends Controller {
|
||||
@action
|
||||
updatePortalPreview({forceRefresh} = {forceRefresh: false}) {
|
||||
// TODO: can these be worked out from settings in membersUtils?
|
||||
const monthlyPrice = this.stripeMonthlyAmount * 100;
|
||||
const yearlyPrice = this.stripeYearlyAmount * 100;
|
||||
const monthlyPrice = Math.round(this.stripeMonthlyAmount * 100);
|
||||
const yearlyPrice = Math.round(this.stripeYearlyAmount * 100);
|
||||
let portalPlans = this.settings.get('portalPlans') || [];
|
||||
|
||||
let isMonthlyChecked = portalPlans.includes('monthly');
|
||||
|
Loading…
Reference in New Issue
Block a user