1
0
mirror of https://github.com/bitwarden/web synced 2025-12-11 05:43:16 +00: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

@@ -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');
};
});