Handle errors. Cancel gift card
This commit is contained in:
parent
6b2fbeae01
commit
b0d24c6814
6 changed files with 238 additions and 63 deletions
|
|
@ -15,7 +15,6 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
return;
|
||||
}
|
||||
self.giftCards = gcds;
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -26,8 +25,55 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.card = card;
|
||||
|
||||
$scope.cancelGiftCard = function() {
|
||||
$scope.refresh = true;
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
gcId: $scope.card.gcId,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.cancelGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err || data.status != 'SUCCESS') {
|
||||
$scope.error = err || data.status;
|
||||
return;
|
||||
}
|
||||
$scope.refreshGiftCard();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
amazonService.saveGiftCard($scope.card, {remove: true}, function(err) {
|
||||
$modalInstance.close(true);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.refreshGiftCard = function() {
|
||||
$scope.refresh = true;
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
amount: $scope.card.cardInfo.value.amount,
|
||||
currencyCode: $scope.card.cardInfo.value.currencyCode,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.createGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.card = data;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = lodash.debounce(function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
$modalInstance.close($scope.refresh);
|
||||
}, 0, 1000);
|
||||
|
||||
};
|
||||
|
|
@ -39,7 +85,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
});
|
||||
|
||||
var disableCloseModal = $rootScope.$on('closeModal', function() {
|
||||
modalInstance.dismiss('cancel');
|
||||
modalInstance.close($scope.refresh);
|
||||
});
|
||||
|
||||
modalInstance.result.finally(function() {
|
||||
|
|
@ -48,6 +94,10 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
var m = angular.element(document.getElementsByClassName('reveal-modal'));
|
||||
m.addClass(animationService.modalAnimated.slideOutRight);
|
||||
});
|
||||
|
||||
modalInstance.result.then(function(refresh) {
|
||||
if (refresh) self.init();
|
||||
}, function() {});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,11 +45,12 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
});
|
||||
} catch (e) {
|
||||
$log.debug(e);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
self.errorInfo = null;
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.type = 'SELL';
|
||||
$scope.wallets = wallets;
|
||||
|
|
@ -104,6 +105,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
|
||||
this.createTx = function() {
|
||||
self.error = null;
|
||||
self.errorInfo = null;
|
||||
|
||||
var currency_code = configService.getSync().amazon.testnet ? window.amazon_sandbox_currency_code : window.amazon_currency_code;
|
||||
var dataSrc = {
|
||||
|
|
@ -178,6 +180,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
self.loading = null;
|
||||
if (err) {
|
||||
self.error = err;
|
||||
self.errorInfo = gift;
|
||||
return;
|
||||
}
|
||||
self.giftCard = giftCard;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue