mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-09 09:51:02 +01:00
error handling for no payment method
This commit is contained in:
parent
96b8467859
commit
f944910975
@ -31,7 +31,12 @@ angular
|
|||||||
}, function failure(reason) {
|
}, function failure(reason) {
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
form.$loading = false;
|
form.$loading = false;
|
||||||
|
if (typeof reason === 'string') {
|
||||||
|
validationService.addError(form, null, reason, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
validationService.addErrors(form, reason);
|
validationService.addErrors(form, reason);
|
||||||
|
}
|
||||||
scope.$broadcast('show-errors-check-validity');
|
scope.$broadcast('show-errors-check-validity');
|
||||||
$('html, body').animate({ scrollTop: 0 }, 200);
|
$('html, body').animate({ scrollTop: 0 }, 200);
|
||||||
});
|
});
|
||||||
|
@ -56,12 +56,18 @@
|
|||||||
|
|
||||||
$scope.submit = function (model) {
|
$scope.submit = function (model) {
|
||||||
$scope.submitPromise = getPaymentToken(model).then(function (token) {
|
$scope.submitPromise = getPaymentToken(model).then(function (token) {
|
||||||
|
if (!token) {
|
||||||
|
throw 'No payment token.';
|
||||||
|
}
|
||||||
|
|
||||||
var request = {
|
var request = {
|
||||||
paymentToken: token,
|
paymentToken: token,
|
||||||
additionalStorageGb: model.additionalStorageGb
|
additionalStorageGb: model.additionalStorageGb
|
||||||
};
|
};
|
||||||
|
|
||||||
return apiService.accounts.postPremium(request).$promise;
|
return apiService.accounts.postPremium(request).$promise;
|
||||||
|
}, function (err) {
|
||||||
|
throw err;
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
return authService.updateProfilePremium(true);
|
return authService.updateProfilePremium(true);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
@ -78,6 +84,8 @@
|
|||||||
if ($scope.paymentMethod === 'paypal') {
|
if ($scope.paymentMethod === 'paypal') {
|
||||||
return btInstance.requestPaymentMethod().then(function (payload) {
|
return btInstance.requestPaymentMethod().then(function (payload) {
|
||||||
return payload.nonce;
|
return payload.nonce;
|
||||||
|
}).catch(function (err) {
|
||||||
|
throw err.message;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user