Support the additional stripe callbacks
This commit is contained in:
parent
68e1658849
commit
0f473a3a82
3 changed files with 49 additions and 41 deletions
|
@ -1038,17 +1038,14 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
};
|
||||
|
||||
$scope.upgradePlan = function() {
|
||||
PlanService.changePlan($scope, null, $scope.planRequired.stripeId, null, function() {
|
||||
// Subscribing.
|
||||
$scope.planChanging = true;
|
||||
}, function(plan) {
|
||||
// Subscribed.
|
||||
subscribedToPlan(plan);
|
||||
}, function() {
|
||||
// Failure.
|
||||
$('#couldnotsubscribeModal').modal();
|
||||
$scope.planChanging = false;
|
||||
});
|
||||
var callbacks = {
|
||||
'opened': function() { $scope.planChanging = true; },
|
||||
'closed': function() { $scope.planChanging = false; },
|
||||
'success': subscribedToPlan,
|
||||
'failure': function() { $('#couldnotsubscribeModal').modal(); $scope.planChanging = false; }
|
||||
};
|
||||
|
||||
PlanService.changePlan($scope, null, $scope.planRequired.stripeId, null, callbacks);
|
||||
};
|
||||
|
||||
// Watch the namespace on the repo. If it changes, we update the plan and the public/private
|
||||
|
@ -1364,24 +1361,25 @@ function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, Plan
|
|||
// Reset the organizations list.
|
||||
UserService.load();
|
||||
|
||||
var showOrg = function() {
|
||||
$location.path('/organization/' + org.name + '/');
|
||||
};
|
||||
|
||||
// If the selected plan is free, simply move to the org page.
|
||||
if ($scope.currentPlan.price == 0) {
|
||||
$location.path('/organization/' + org.name + '/');
|
||||
showOrg();
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, show the subscribe for the plan.
|
||||
PlanService.changePlan($scope, org.name, $scope.currentPlan.stripeId, false, function() {
|
||||
// Started.
|
||||
$scope.creating = true;
|
||||
}, function(sub) {
|
||||
// Success.
|
||||
$location.path('/organization/' + org.name + '/');
|
||||
}, function() {
|
||||
// Failure.
|
||||
$location.path('/organization/' + org.name + '/');
|
||||
});
|
||||
var callbacks = {
|
||||
'opened': function() { $scope.creating = true; },
|
||||
'closed': showOrg,
|
||||
'success': showOrg,
|
||||
'failure': showOrg
|
||||
};
|
||||
|
||||
PlanService.changePlan($scope, org.name, $scope.currentPlan.stripeId, false, callbacks);
|
||||
}, function(result) {
|
||||
$scope.creating = false;
|
||||
$scope.createError = result.data.message || result.data;
|
||||
|
|
Reference in a new issue