diff --git a/gulpfile.js b/gulpfile.js index 1aee077b4d..d26ac30b9c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,7 +18,10 @@ var gulp = require('gulp'), project = require('./package.json'), jshint = require('gulp-jshint'), _ = require('lodash'), - webpack = require('webpack-stream'); + webpack = require('webpack-stream'), + browserify = require('browserify'), + derequire = require('gulp-derequire'), + source = require('vinyl-source-stream'); var paths = {}; paths.dist = './dist/'; @@ -43,7 +46,7 @@ gulp.task('lint', function () { gulp.task('build', function (cb) { return runSequence( 'clean', - ['lib', 'webpack', 'less', 'settings', 'lint'], + ['browserify', 'lib', 'webpack', 'less', 'settings', 'lint'], cb); }); @@ -232,6 +235,35 @@ gulp.task('watch', function () { gulp.watch('./settings*.json', ['settings']); }); +gulp.task('browserify', ['browserify:stripe', 'browserify:cc']); + +gulp.task('browserify:stripe', function () { + return browserify(paths.npmDir + 'angular-stripe/src/index.js', + { + entry: '.', + standalone: 'angularStripe', + global: true + }) + .transform('exposify', { expose: { angular: 'angular' } }) + .bundle() + .pipe(source('angular-stripe.js')) + .pipe(derequire()) + .pipe(gulp.dest(paths.libDir + 'angular-stripe')); +}); + +gulp.task('browserify:cc', function () { + return browserify(paths.npmDir + 'angular-credit-cards/src/index.js', + { + entry: '.', + standalone: 'angularCreditCards' + }) + .transform('exposify', { expose: { angular: 'angular' } }) + .bundle() + .pipe(source('angular-credit-cards.js')) + .pipe(derequire()) + .pipe(gulp.dest(paths.libDir + 'angular-credit-cards')); +}); + gulp.task('dist:clean', function (cb) { return rimraf(paths.dist, cb); }); @@ -332,7 +364,7 @@ gulp.task('dist:preprocess', function () { .src([ paths.dist + '/**/*.html' ], { base: '.' }) - .pipe(preprocess({ context: { cacheTag: randomString }})) + .pipe(preprocess({ context: { cacheTag: randomString } })) .pipe(gulp.dest('.')); }); diff --git a/package.json b/package.json index e64fa6e1db..76a15c9748 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,11 @@ "angulartics": "1.4.0", "angulartics-google-analytics": "0.4.0", "node-forge": "0.7.0", - "webpack-stream": "3.2.0" + "webpack-stream": "3.2.0", + "angular-stripe": "4.2.12", + "angular-credit-cards": "3.1.6", + "browserify": "14.1.0", + "vinyl-source-stream": "1.1.0", + "gulp-derequire": "2.1.0" } } diff --git a/src/app/app.js b/src/app/app.js index 859a82c85c..75e54d47f9 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -8,6 +8,8 @@ 'toastr', 'angulartics', 'angulartics.google.analytics', + 'angular-stripe', + 'credit-cards', 'bit.directives', 'bit.filters', diff --git a/src/app/config.js b/src/app/config.js index aa1511e2d8..fc34d35251 100644 --- a/src/app/config.js +++ b/src/app/config.js @@ -2,7 +2,7 @@ angular .module('bit') .config(function ($stateProvider, $urlRouterProvider, $httpProvider, jwtInterceptorProvider, jwtOptionsProvider, - $uibTooltipProvider, toastrConfig, $locationProvider, $qProvider) { + $uibTooltipProvider, toastrConfig, $locationProvider, $qProvider, stripeProvider) { $qProvider.errorOnUnhandledRejections(false); $locationProvider.hashPrefix(''); jwtOptionsProvider.config({ @@ -10,7 +10,8 @@ angular whiteListedDomains: ['api.bitwarden.com', 'localhost'] }); var refreshPromise; - jwtInterceptorProvider.tokenGetter = /*@ngInject*/ function (options, appSettings, tokenService, apiService, jwtHelper, $q) { + jwtInterceptorProvider.tokenGetter = /*@ngInject*/ function (options, appSettings, tokenService, apiService, + jwtHelper, $q) { if (options.url.indexOf(appSettings.apiUri) !== 0) { return; } @@ -48,6 +49,8 @@ angular return refreshPromise; }; + stripeProvider.setPublishableKey('pk_test_KPoCfZXu7mznb9uSCPZ2JpTD'); + angular.extend(toastrConfig, { closeButton: true, progressBar: true, diff --git a/src/app/settings/settingsCreateOrganizationController.js b/src/app/settings/settingsCreateOrganizationController.js index 7fb6b48d9a..5b7e7a6552 100644 --- a/src/app/settings/settingsCreateOrganizationController.js +++ b/src/app/settings/settingsCreateOrganizationController.js @@ -1,32 +1,37 @@ angular .module('bit.settings') - .controller('settingsCreateOrganizationController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, - toastr, $analytics, authService) { + .controller('settingsCreateOrganizationController', function($scope, $state, apiService, $uibModalInstance, cryptoService, + toastr, $analytics, authService, stripe) { $analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' }); $scope.model = { - plan: 'Free' + plan: 'Personal' }; - $scope.submit = function (model) { - var request = { - name: model.name, - planType: model.plan, - key: cryptoService.makeShareKey() - }; + $scope.submit = function(model) { + $scope.submitPromise = stripe.card.createToken(model.card).then(function(response) { + var request = { + name: model.name, + planType: model.plan, + key: cryptoService.makeShareKey(), + cardToken: response.id + }; + + return apiService.organizations.post(request).$promise; + }).then(function(result) { + $scope.model.card = null; - $scope.submitPromise = apiService.organizations.post(request, function (result) { $uibModalInstance.dismiss('cancel'); $analytics.eventTrack('Created Organization'); authService.addProfileOrganization(result); - $state.go('backend.org.dashboard', { orgId: result.Id }).then(function () { + $state.go('backend.org.dashboard', { orgId: result.Id }).then(function() { toastr.success('Your new organization is ready to go!', 'Organization Created'); }); - }).$promise; + }); }; - $scope.close = function () { + $scope.close = function() { $uibModalInstance.dismiss('cancel'); }; }); diff --git a/src/app/settings/views/settingsCreateOrganization.html b/src/app/settings/views/settingsCreateOrganization.html index fd8afd5da6..f677c92593 100644 --- a/src/app/settings/views/settingsCreateOrganization.html +++ b/src/app/settings/views/settingsCreateOrganization.html @@ -18,15 +18,8 @@
-

Share with 1 other user.

-
-
-

Share with up to 5 users.

@@ -38,6 +31,334 @@

Share with as many users as you need.

+
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+