diff --git a/static/js/services/plan-service.js b/static/js/services/plan-service.js index b940d2d3f..b7a2e39e6 100644 --- a/static/js/services/plan-service.js +++ b/static/js/services/plan-service.js @@ -206,11 +206,25 @@ function(KeyService, UserService, CookieService, ApiService, Features, Config) { callbacks['started'](); } + planService.getSubscription(orgname, function(sub) { + planService.getPlanIncludingDeprecated(sub.plan, function(subscribedPlan) { + planService.changePlanInternal($scope, orgname, planId, callbacks, opt_async, + subscribedPlan.price > 0); + }); + }, function() { + planService.changePlanInternal($scope, orgname, planId, callbacks, opt_async, false); + }); + }; + + planService.changePlanInternal = function($scope, orgname, planId, callbacks, opt_async, + opt_reuseCard) { + if (!Features.BILLING) { return; } + planService.getPlan(planId, function(plan) { if (orgname && !planService.isOrgCompatible(plan)) { return; } planService.getCardInfo(orgname, function(cardInfo) { - if (plan.price > 0 && (previousSubscribeFailure || !cardInfo.last4)) { + if (plan.price > 0 && (previousSubscribeFailure || !cardInfo.last4 || !opt_reuseCard)) { var title = cardInfo.last4 ? 'Subscribe' : 'Start Trial ({{amount}} plan)'; planService.showSubscribeDialog($scope, orgname, planId, callbacks, title, /* async */true); return;