Files
overleaf-cep/services/web/app/src/Features/Subscription/SubscriptionHelper.js
Tim Alby 28cb844d5a rename price attributes to price_in_cents or price_in_unit
GitOrigin-RevId: 8045472c96862078583fcb522099ad78926281dc
2022-01-21 09:03:23 +00:00

22 lines
588 B
JavaScript

/**
* If the user changes to a less expensive plan, we shouldn't apply the change immediately.
* This is to avoid unintended/artifical credits on users Recurly accounts.
*/
function shouldPlanChangeAtTermEnd(oldPlan, newPlan) {
return getPlanPriceInCents(oldPlan) > getPlanPriceInCents(newPlan)
}
/**
* Group plans have their price in dollars, but individual plans store the price in cents
*/
function getPlanPriceInCents(plan) {
if (plan.price_in_unit) {
return plan.price_in_unit * 100
}
return plan.price_in_cents
}
module.exports = {
shouldPlanChangeAtTermEnd,
}