SubscriptionHelper.js 546 B

123456789101112131415161718192021
  1. /**
  2. * If the user changes to a less expensive plan, we shouldn't apply the change immediately.
  3. * This is to avoid unintended/artifical credits on users Recurly accounts.
  4. */
  5. function shouldPlanChangeAtTermEnd(oldPlan, newPlan) {
  6. return getPlanPrice(oldPlan) > getPlanPrice(newPlan)
  7. }
  8. /**
  9. * Group plans have their price in dollars, but individual plans store the price in cents
  10. */
  11. function getPlanPrice(plan) {
  12. if (plan.groupPlan) {
  13. return plan.price * 100
  14. }
  15. return plan.price
  16. }
  17. module.exports = {
  18. shouldPlanChangeAtTermEnd,
  19. }