mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-28 12:45:45 +01:00
change payment for premium
This commit is contained in:
parent
ccb7ede4fa
commit
a1529bc4e9
@ -16,11 +16,11 @@
|
|||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
$scope.card = null;
|
$scope.card = null;
|
||||||
if (existingPaymentMethod) {
|
if (existingPaymentMethod) {
|
||||||
$analytics.eventTrack('Changed Payment Method');
|
$analytics.eventTrack('Changed Organization Payment Method');
|
||||||
toastr.success('You have changed your payment method.');
|
toastr.success('You have changed your payment method.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$analytics.eventTrack('Added Payment Method');
|
$analytics.eventTrack('Added Organization Payment Method');
|
||||||
toastr.success('You have added a payment method.');
|
toastr.success('You have added a payment method.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
$scope.changePayment = function () {
|
$scope.changePayment = function () {
|
||||||
var modal = $uibModal.open({
|
var modal = $uibModal.open({
|
||||||
animation: true,
|
animation: true,
|
||||||
templateUrl: 'app/organization/views/organizationBillingChangePayment.html',
|
templateUrl: 'app/settings/views/settingsBillingChangePayment.html',
|
||||||
controller: 'organizationBillingChangePaymentController',
|
controller: 'organizationBillingChangePaymentController',
|
||||||
resolve: {
|
resolve: {
|
||||||
existingPaymentMethod: function () {
|
existingPaymentMethod: function () {
|
||||||
|
@ -127,6 +127,7 @@
|
|||||||
postDelete: { url: _apiUri + '/accounts/delete', method: 'POST', params: {} },
|
postDelete: { url: _apiUri + '/accounts/delete', method: 'POST', params: {} },
|
||||||
postPremium: { url: _apiUri + '/accounts/premium', method: 'POST', params: {} },
|
postPremium: { url: _apiUri + '/accounts/premium', method: 'POST', params: {} },
|
||||||
putStorage: { url: _apiUri + '/accounts/storage', 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: {} },
|
putCancelPremium: { url: _apiUri + '/accounts/cancel-premium', method: 'POST', params: {} },
|
||||||
putReinstatePremium: { url: _apiUri + '/accounts/reinstate-premium', method: 'POST', params: {} },
|
putReinstatePremium: { url: _apiUri + '/accounts/reinstate-premium', method: 'POST', params: {} },
|
||||||
getBilling: { url: _apiUri + '/accounts/billing', method: 'GET', params: {} }
|
getBilling: { url: _apiUri + '/accounts/billing', method: 'GET', params: {} }
|
||||||
|
34
src/app/settings/settingsBillingChangePaymentController.js
Normal file
34
src/app/settings/settingsBillingChangePaymentController.js
Normal 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');
|
||||||
|
};
|
||||||
|
});
|
@ -14,7 +14,7 @@
|
|||||||
$scope.changePayment = function () {
|
$scope.changePayment = function () {
|
||||||
var modal = $uibModal.open({
|
var modal = $uibModal.open({
|
||||||
animation: true,
|
animation: true,
|
||||||
templateUrl: 'app/organization/views/settingsBillingChangePayment.html',
|
templateUrl: 'app/settings/views/settingsBillingChangePayment.html',
|
||||||
controller: 'settingsBillingChangePaymentController',
|
controller: 'settingsBillingChangePaymentController',
|
||||||
resolve: {
|
resolve: {
|
||||||
existingPaymentMethod: function () {
|
existingPaymentMethod: function () {
|
||||||
|
@ -216,6 +216,7 @@
|
|||||||
<script src="app/settings/settingsCreateOrganizationController.js"></script>
|
<script src="app/settings/settingsCreateOrganizationController.js"></script>
|
||||||
<script src="app/settings/settingsBillingController.js"></script>
|
<script src="app/settings/settingsBillingController.js"></script>
|
||||||
<script src="app/settings/settingsBillingAdjustStorageController.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/settingsUpdateKeyController.js"></script>
|
||||||
<script src="app/settings/settingsPremiumController.js"></script>
|
<script src="app/settings/settingsPremiumController.js"></script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user