There was a temporary/recoverable system failure that can be resolved by retrying the request
@@ -116,8 +116,7 @@
This action will remove the gift card
@@ -130,8 +129,7 @@
This action will cancel the gift card
diff --git a/src/js/controllers/buyAmazon.js b/src/js/controllers/buyAmazon.js
index 842efee66..c3c5b028b 100644
--- a/src/js/controllers/buyAmazon.js
+++ b/src/js/controllers/buyAmazon.js
@@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('buyAmazonController',
- function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwsError, configService, walletService, fingerprintService, amazonService) {
+ function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwsError, configService, walletService, fingerprintService, amazonService, ongoingProcess) {
var self = this;
var client;
@@ -60,7 +60,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
};
this.setAmount = function(plus) {
- if (self.loading) return;
if (plus && $scope.fiat < maximumAmount ) {
stepAmount = stepAmount + 1;
$scope.fiat = stepAmount * multiplierAmount;
@@ -86,12 +85,12 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
var walletSettings = configWallet.settings;
- self.loading = 'Creating invoice...';
+ ongoingProcess.set('Creating invoice...', true);
$timeout(function() {
amazonService.createBitPayInvoice(dataSrc, function(err, data) {
+ ongoingProcess.set('Creating invoice...', false);
if (err) {
- self.loading = null;
self.error = bwsError.msg(err);
$scope.$apply();
return;
@@ -119,23 +118,22 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
feeLevel: walletSettings.feeLevel || 'normal'
};
- self.loading = 'Creating transaction...';
+ ongoingProcess.set('Creating transaction...', true);
walletService.createTx(client, txp, function(err, createdTxp) {
- self.loading = null;
+ ongoingProcess.set('Creating transaction...', false);
if (err) {
- self.loading = null;
- $log.debug(err);
self.error = bwsError.msg(err);
$scope.$apply();
return;
}
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
if (accept) {
- self.loading = 'Sending bitcoin...';
+ ongoingProcess.set('Sending bitcoin...', true);
self.confirmTx(createdTxp, function(err, tx) {
+ ongoingProcess.set('Sending bitcoin...', false);
if (err) {
- self.loading = null;
- self.error = err;
+ self.error = bwsError.msg(err);
+ $scope.$apply();
return;
}
var gift = {
@@ -144,12 +142,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
bitpayInvoiceId: data.data.id,
bitpayInvoiceUrl: data.data.url
};
- self.loading = 'Creating gift card...';
+ ongoingProcess.set('Creating gift card...', true);
amazonService.createGiftCard(gift, function(err, giftCard) {
- self.loading = null;
+ ongoingProcess.set('Creating gift card...', false);
if (err) {
- self.error = err;
+ self.error = bwsError.msg(err);
self.errorInfo = gift;
+ $scope.$apply();
return;
}
amazonService.setAmountByDay(dataSrc.price);
diff --git a/src/js/controllers/modals/amazonCardDetails.js b/src/js/controllers/modals/amazonCardDetails.js
index 5426bcd06..beb8cbaf7 100644
--- a/src/js/controllers/modals/amazonCardDetails.js
+++ b/src/js/controllers/modals/amazonCardDetails.js
@@ -1,6 +1,6 @@
'use strict';
-angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $timeout, amazonService) {
+angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $timeout, amazonService, ongoingProcess) {
$scope.cancelGiftCard = function() {
var dataSrc = {
@@ -10,9 +10,9 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
date: $scope.card.date
};
- $scope.loading = true;
+ ongoingProcess.set('Canceling gift card...', true);
amazonService.cancelGiftCard(dataSrc, function(err, data) {
- $scope.loading = null;
+ ongoingProcess.set('Canceling gift card...', false);
if (err || data.status != 'SUCCESS') {
$scope.error = err || data.status;
return;
@@ -36,9 +36,9 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
date: $scope.card.date
};
- $scope.loading = true;
+ ongoingProcess.set('Updating gift card...', true);
amazonService.createGiftCard(dataSrc, function(err, data) {
- $scope.loading = null;
+ ongoingProcess.set('Updating gift card...', false);
if (err) {
$scope.error = err;
return;