save giftcards data when reedem failed

This commit is contained in:
Gabriel Bazán 2016-08-04 13:21:14 -03:00 committed by Gustavo Maximiliano Cortez
commit 7334d06c89
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
3 changed files with 9 additions and 4 deletions

View file

@ -45,9 +45,12 @@
<div ng-show="!card.claimCode">
<div class="m10t">
Status:
<span class="text-bold">
<span class="text-bold" ng-show="card.status == 'PENDING'">
PENDING
</span>
<span class="text-bold" ng-show="card.status == 'FAILURE'">
FAILURE
</span>
</div>
</div>
<div class="size-12 m10t text-center">
@ -71,7 +74,7 @@
</button>
</div>
<div class="text-warning m10" ng-show="card.status == 'FAILURE'">
There was a failure to the create gift card that could not be recoverable. Please, contact BitPay to refund your bitcoin
There was a failure to the create gift card. Please, contact BitPay to refund your bitcoin
</div>
</div>

View file

@ -194,14 +194,16 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
$log.debug("creating gift card " + count);
if (err) {
giftCard = {};
giftCard.status = 'FAILURE';
ongoingProcess.set('Processing Transaction...', false);
self.error = bwcError.msg(err);
self.errorInfo = dataSrc;
$timeout(function() {
$scope.$digest();
});
return;
}
if (giftCard.status == 'PENDING' && count < 3) {
$log.debug("pending gift card not available yet");
self.debounceCreate(count + 1, dataSrc, dataSrc);

View file

@ -101,7 +101,7 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
};
$http(_postBitPay('/amazon-gift/redeem', dataSrc)).then(function(data) {
var status = data.data.status == ('new' || 'paid') ? 'PENDING' : data.data.status;
var status = data.data.status == 'new' ? 'PENDING' : (data.data.status == 'paid') ? 'PENDING' : data.data.status;
data.data.status = status;
$log.info('Amazon.com Gift Card Create/Update: ' + status);
return cb(null, data.data);