1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

change payment for premium

This commit is contained in:
Kyle Spearrin 2017-07-11 11:17:43 -04:00
parent ccb7ede4fa
commit a1529bc4e9
7 changed files with 40 additions and 4 deletions

View File

@ -16,11 +16,11 @@
}).then(function (response) {
$scope.card = null;
if (existingPaymentMethod) {
$analytics.eventTrack('Changed Payment Method');
$analytics.eventTrack('Changed Organization Payment Method');
toastr.success('You have changed your payment method.');
}
else {
$analytics.eventTrack('Added Payment Method');
$analytics.eventTrack('Added Organization Payment Method');
toastr.success('You have added a payment method.');
}

View File

@ -15,7 +15,7 @@
$scope.changePayment = function () {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/organization/views/organizationBillingChangePayment.html',
templateUrl: 'app/settings/views/settingsBillingChangePayment.html',
controller: 'organizationBillingChangePaymentController',
resolve: {
existingPaymentMethod: function () {

View File

@ -127,6 +127,7 @@
postDelete: { url: _apiUri + '/accounts/delete', method: 'POST', params: {} },
postPremium: { url: _apiUri + '/accounts/premium', method: 'POST', params: {} },
putStorage: { url: _apiUri + '/accounts/storage', method: 'POST', params: {} },
putPayment: { url: _apiUri + '/accounts/payment', method: 'POST', params: {} },
putCancelPremium: { url: _apiUri + '/accounts/cancel-premium', method: 'POST', params: {} },
putReinstatePremium: { url: _apiUri + '/accounts/reinstate-premium', method: 'POST', params: {} },
getBilling: { url: _apiUri + '/accounts/billing', method: 'GET', params: {} }

View File

@ -0,0 +1,34 @@
angular
.module('bit.organization')
.controller('settingsBillingChangePaymentController', function ($scope, $state, $uibModalInstance, apiService, stripe,
$analytics, toastr, existingPaymentMethod) {
$analytics.eventTrack('settingsBillingChangePaymentController', { category: 'Modal' });
$scope.existingPaymentMethod = existingPaymentMethod;
$scope.submit = function () {
$scope.submitPromise = stripe.card.createToken($scope.card).then(function (response) {
var request = {
paymentToken: response.id
};
return apiService.accounts.putPayment(null, request).$promise;
}).then(function (response) {
$scope.card = null;
if (existingPaymentMethod) {
$analytics.eventTrack('Changed Payment Method');
toastr.success('You have changed your payment method.');
}
else {
$analytics.eventTrack('Added Payment Method');
toastr.success('You have added a payment method.');
}
$uibModalInstance.close();
});
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -14,7 +14,7 @@
$scope.changePayment = function () {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/organization/views/settingsBillingChangePayment.html',
templateUrl: 'app/settings/views/settingsBillingChangePayment.html',
controller: 'settingsBillingChangePaymentController',
resolve: {
existingPaymentMethod: function () {

View File

@ -216,6 +216,7 @@
<script src="app/settings/settingsCreateOrganizationController.js"></script>
<script src="app/settings/settingsBillingController.js"></script>
<script src="app/settings/settingsBillingAdjustStorageController.js"></script>
<script src="app/settings/settingsBillingChangePaymentController.js"></script>
<script src="app/settings/settingsUpdateKeyController.js"></script>
<script src="app/settings/settingsPremiumController.js"></script>