Have the private option in the new repo form alert the user about needing to purchase a plan and let them do so
This commit is contained in:
parent
bb2446c45c
commit
1ee21318d4
4 changed files with 133 additions and 36 deletions
|
@ -54,7 +54,7 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
|
|||
return keyService;
|
||||
}]);
|
||||
|
||||
$provide.factory('PlanService', [function() {
|
||||
$provide.factory('PlanService', ['Restangular', 'KeyService', function(Restangular, KeyService) {
|
||||
var plans = [
|
||||
{
|
||||
title: 'Open Source',
|
||||
|
@ -96,11 +96,54 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
|
|||
|
||||
planService.planList = function() {
|
||||
return plans;
|
||||
}
|
||||
};
|
||||
|
||||
planService.getPlan = function(planId) {
|
||||
return planDict[planId];
|
||||
}
|
||||
};
|
||||
|
||||
planService.getMinimumPlan = function(privateCount) {
|
||||
for (var i = 0; i < plans.length; i++) {
|
||||
var plan = plans[i];
|
||||
if (plan.privateRepos >= privateCount) {
|
||||
return plan;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
planService.showSubscribeDialog = function($scope, planId, started, success, failed) {
|
||||
var submitToken = function(token) {
|
||||
$scope.$apply(function() {
|
||||
started();
|
||||
});
|
||||
|
||||
mixpanel.track('plan_subscribe');
|
||||
|
||||
var subscriptionDetails = {
|
||||
token: token.id,
|
||||
plan: planId,
|
||||
};
|
||||
|
||||
var createSubscriptionRequest = Restangular.one('user/plan');
|
||||
$scope.$apply(function() {
|
||||
createSubscriptionRequest.customPUT(subscriptionDetails).then(success, failed);
|
||||
});
|
||||
};
|
||||
|
||||
var planDetails = planService.getPlan(planId)
|
||||
StripeCheckout.open({
|
||||
key: KeyService.stripePublishableKey,
|
||||
address: false, // TODO change to true
|
||||
amount: planDetails.price,
|
||||
currency: 'usd',
|
||||
name: 'Quay ' + planDetails.title + ' Subscription',
|
||||
description: 'Up to ' + planDetails.privateRepos + ' private repositories',
|
||||
panelLabel: 'Subscribe',
|
||||
token: submitToken
|
||||
});
|
||||
};
|
||||
|
||||
return planService;
|
||||
}]);
|
||||
|
|
Reference in a new issue