diff --git a/src/js/controllers/amazonCards.js b/src/js/controllers/amazonCards.js index 329c620fc..c0e42b791 100644 --- a/src/js/controllers/amazonCards.js +++ b/src/js/controllers/amazonCards.js @@ -29,15 +29,18 @@ angular.module('copayApp.controllers').controller('amazonCardsController', var index = 0; var gcds = $scope.giftCards; lodash.forEach(gcds, function(dataFromStorage) { - if (dataFromStorage.status == 'PENDING') { - $log.debug("creating gift card"); + if (dataFromStorage.status == 'PENDING' || dataFromStorage.status == 'invalid') { + $log.debug("Creating / Updating gift card"); $scope.updatingPending[dataFromStorage.invoiceId] = true; + amazonService.createGiftCard(dataFromStorage, function(err, giftCard) { + $scope.updatingPending[dataFromStorage.invoiceId] = false; if (err) { popupService.showAlert('Error creating gift card', err); return; } + if (giftCard.status != 'PENDING') { var newData = {}; diff --git a/src/js/services/amazonService.js b/src/js/services/amazonService.js index cfd990f1e..c0dee597e 100644 --- a/src/js/services/amazonService.js +++ b/src/js/services/amazonService.js @@ -72,8 +72,10 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo if (opts && opts.remove) { delete(inv[gc.invoiceId]); } + inv = JSON.stringify(inv); + storageService.setAmazonGiftCards(network, inv, function(err) { homeIntegrationsService.register(homeItem); diff --git a/www/views/amazonCards.html b/www/views/amazonCards.html index a50aa1454..03a989e06 100644 --- a/www/views/amazonCards.html +++ b/www/views/amazonCards.html @@ -14,16 +14,16 @@ {{id}} -

- {{item.amount | currency : '$ ' : 2}} {{item.currency}} - - +

+ {{item.amount | currency : '$ ' : 2}} {{item.currency}}

Error Expired + Still waiting confirmation
(Use higher fees setting to faster delivery)
Pending to confirmation Canceled - {{item.date | amTimeAgo}} + {{item.date | amTimeAgo}}

diff --git a/www/views/modals/amazon-card-details.html b/www/views/modals/amazon-card-details.html index 86e58b2dd..0bd850367 100644 --- a/www/views/modals/amazon-card-details.html +++ b/www/views/modals/amazon-card-details.html @@ -11,13 +11,21 @@
Amazon.com Gift Card +
+ Gift Card Amount: + + {{card.amount | currency : '$ ' : 2}} + +
+ + +
+ Created + {{card.date | amTimeAgo}} +
+ +
-
- Gift Card Amount: - - {{card.amount | currency : '$ ' : 2}} - -
Claim code: {{card.claimCode}}
@@ -42,6 +50,10 @@ PENDING + + STILL PENDING + + FAILURE