Use the stripe publishable key for prod in prod. Track when a user signs up for a plan.

This commit is contained in:
yackob03 2013-10-08 13:57:48 -04:00
parent 5a5ddf2c0e
commit 12e91022cc
2 changed files with 20 additions and 2 deletions

View file

@ -36,6 +36,18 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
return userService;
}]);
$provide.factory('KeyService', ['$location', function($location) {
var keyService = {}
if ($location.host() === 'quay.io') {
keyService['stripePublishableKey'] = 'pk_live_P5wLU0vGdHnZGyKnXlFG4oiu';
} else {
keyService['stripePublishableKey'] = 'pk_test_uEDHANKm9CHCvVa2DLcipGRh';
}
return keyService;
}]);
$provide.factory('PlanService', [function() {
var plans = [
{

View file

@ -449,7 +449,7 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
});
}
function UserAdminCtrl($scope, Restangular, PlanService, $routeParams) {
function UserAdminCtrl($scope, Restangular, PlanService, KeyService, $routeParams) {
$scope.plans = PlanService.planList();
var subscribedToPlan = function(sub) {
@ -463,6 +463,10 @@ function UserAdminCtrl($scope, Restangular, PlanService, $routeParams) {
$scope.planLoading = false;
$scope.planChanging = false;
mixpanel.people.set({
'plan': sub.plan
});
}
$scope.planLoading = true;
@ -476,6 +480,8 @@ function UserAdminCtrl($scope, Restangular, PlanService, $routeParams) {
$scope.subscribe = function(planId) {
var submitToken = function(token) {
$scope.$apply(function() {
mixpanel.track('plan_subscribe');
$scope.planChanging = true;
$scope.errorMessage = undefined;
@ -494,7 +500,7 @@ function UserAdminCtrl($scope, Restangular, PlanService, $routeParams) {
var planDetails = PlanService.getPlan(planId)
StripeCheckout.open({
key: 'pk_test_uEDHANKm9CHCvVa2DLcipGRh',
key: KeyService.stripePublishableKey,
address: false, // TODO change to true
amount: planDetails.price,
currency: 'usd',