2021-04-27 10:17:39 -04:00
|
|
|
/**
|
|
|
|
* 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) {
|
2021-09-14 08:18:37 -04:00
|
|
|
return getPlanPrice(oldPlan) > getPlanPrice(newPlan)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Group plans have their price in dollars, but individual plans store the price in cents
|
|
|
|
*/
|
|
|
|
function getPlanPrice(plan) {
|
|
|
|
if (plan.groupPlan) {
|
|
|
|
return plan.price * 100
|
|
|
|
}
|
|
|
|
return plan.price
|
2021-04-27 10:17:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
shouldPlanChangeAtTermEnd,
|
|
|
|
}
|