Checkpointing stripe work.

This commit is contained in:
yackob03 2013-10-02 00:48:03 -04:00
parent 211fd6bcd7
commit 7bd18c1bab
11 changed files with 172 additions and 6 deletions

View file

@ -175,7 +175,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
$scope.listImages = function() {
if ($scope.imageHistory) { return; }
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/tag/' + $scope.currentTag.name + '/images');
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/tag/' + $scope.currentTag.name + '/images');
imageFetch.get().then(function(resp) {
$scope.imageHistory = resp.images;
});
@ -365,4 +365,74 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
$rootScope.title = 'Unknown Repository';
$scope.loading = false;
});
}
function UserAdminCtrl($scope, Restangular) {
$scope.plans = [
{
title: 'Micro',
price: 700,
privateRepos: 5,
stripeId: 'micro',
},
{
title: 'Small',
price: 1200,
privateRepos: 10,
stripeId: 'small',
},
{
title: 'Medium',
price: 2200,
privateRepos: 20,
stripeId: 'medium',
},
];
var planDict = {};
var i;
for(i = 0; i < $scope.plans.length; i++) {
planDict[$scope.plans[i].stripeId] = $scope.plans[i];
}
var getSubscription = Restangular.one('user/plan');
getSubscription.get().then(function(sub) {
// User has a subscription
$scope.subscription = sub;
});
$scope.subscribe = function(planId) {
var submitToken = function(token) {
$scope.$apply(function() {
var subscriptionDetails = {
token: token.id,
plan: planId,
};
console.log(subscriptionDetails);
var createSubscriptionRequest = Restangular.one('user/plan');
createSubscriptionRequest.customPUT(subscriptionDetails).then(function() {
// Success
console.log('successfully created subscription');
}, function() {
// Failure
console.log('failed to created subscription');
});
});
};
console.log('Got request for plan: ' + planId);
var planDetails = planDict[planId]
StripeCheckout.open({
key: 'pk_test_uEDHANKm9CHCvVa2DLcipGRh',
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
});
};
}