mirror of https://github.com/BTCPrivate/copay.git
handle the "invalid" status
This commit is contained in:
parent
5f197b5f4e
commit
dd1209a92c
|
@ -9,6 +9,7 @@ angular.module('copayApp.controllers').controller('amazonCardsController',
|
|||
|
||||
var updateGiftCards = function(cb) {
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
console.log('[amazonCards.js.11:gcds:]',gcds); //TODO
|
||||
if (err) {
|
||||
popupService.showAlert('Could not get gift cards', err);
|
||||
if (cb) return cb();
|
||||
|
@ -28,16 +29,24 @@ angular.module('copayApp.controllers').controller('amazonCardsController',
|
|||
updateGiftCards(function() {
|
||||
var index = 0;
|
||||
var gcds = $scope.giftCards;
|
||||
console.log('[amazonCards.js.31:gcds:]',gcds); //TODO
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
if (dataFromStorage.status == 'PENDING') {
|
||||
$log.debug("creating gift card");
|
||||
console.log('[amazonCards.js.33:dataFromStorage:]',dataFromStorage); //TODO
|
||||
if (dataFromStorage.status == 'PENDING' || dataFromStorage.status == 'invalid') {
|
||||
$log.debug("Creating / Updating gift card");
|
||||
$scope.updatingPending[dataFromStorage.invoiceId] = true;
|
||||
|
||||
console.log('[amazonCards.js.38]'); //TODO
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
|
||||
console.log('[amazonCards.js.41]'); //TODO
|
||||
$scope.updatingPending[dataFromStorage.invoiceId] = false;
|
||||
if (err) {
|
||||
popupService.showAlert('Error creating gift card', err);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[amazonCards.js.48]', giftCard); //TODO
|
||||
if (giftCard.status != 'PENDING') {
|
||||
var newData = {};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -125,8 +127,10 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
"invoiceId": data.invoiceId,
|
||||
"accessKey": data.accessKey
|
||||
};
|
||||
console.log('[amazonService.js.129:dataSrc:]',dataSrc); //TODO
|
||||
|
||||
$http(_postBitPay('/amazon-gift/redeem', dataSrc)).then(function(data) {
|
||||
console.log('[amazonService.js.130:data:]',data); //TODO
|
||||
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);
|
||||
|
|
|
@ -14,16 +14,16 @@
|
|||
<img src="img/a-smile_color_btn.png" alt="{{id}}" width="40">
|
||||
<ion-spinner class="spinner-dark recent right m10 size-16" icon="crescent" ng-show="updatingPending[item.invoiceId]">
|
||||
</ion-spinner>
|
||||
<h2>
|
||||
<span ng-if="item.claimCode">{{item.amount | currency : '$ ' : 2}} {{item.currency}}</span>
|
||||
<span ng-if="!item.claimCode">-</span>
|
||||
<h2 ng-if="item.amount">
|
||||
{{item.amount | currency : '$ ' : 2}} {{item.currency}}
|
||||
</h2>
|
||||
<p>
|
||||
<span class="assertive" ng-if="item.status == 'FAILURE' || item.status == 'RESEND'">Error</span>
|
||||
<span class="assertive" ng-if="item.status == 'expired'">Expired</span>
|
||||
<span class="assertive" ng-if="item.status == 'invalid'">Still waiting confirmation<br> (Use higher fees setting to faster delivery)</span>
|
||||
<span class="text-gray" ng-if="item.status == 'PENDING'">Pending to confirmation</span>
|
||||
<span class="assertive" ng-if="item.status == 'SUCCESS' && item.cardStatus == 'Canceled'">Canceled</span>
|
||||
<span class="text-gray" ng-if="item.status == 'SUCCESS' && item.cardStatus == 'Fulfilled'">{{item.date | amTimeAgo}}</span>
|
||||
<span class="text-gray">{{item.date | amTimeAgo}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,13 +11,21 @@
|
|||
<div class="header-modal text-center">
|
||||
<img src="img/a_generic.jpg" alt="Amazon.com Gift Card" width="230" ng-click="refreshGiftCard()">
|
||||
|
||||
<div class="m10t">
|
||||
Gift Card Amount:
|
||||
<span class="text-bold">
|
||||
{{card.amount | currency : '$ ' : 2}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="m10t">
|
||||
Created
|
||||
{{card.date | amTimeAgo}}
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-show="card.claimCode">
|
||||
<div class="m10t">
|
||||
Gift Card Amount:
|
||||
<span class="text-bold">
|
||||
{{card.amount | currency : '$ ' : 2}}
|
||||
</span>
|
||||
</div>
|
||||
<div ng-show="card.cardStatus !== 'Canceled'">
|
||||
Claim code: <span class="text-bold" copy-to-clipboard="card.claimCode">{{card.claimCode}}</span>
|
||||
</div>
|
||||
|
@ -42,6 +50,10 @@
|
|||
<span class="text-bold" ng-show="card.status == 'PENDING'">
|
||||
PENDING
|
||||
</span>
|
||||
<span class="text-bold" ng-show="card.status=='invalid'">
|
||||
STILL PENDING
|
||||
</span>
|
||||
|
||||
<span class="text-bold" ng-show="card.status == 'FAILURE' || card.status == 'RESEND'">
|
||||
FAILURE
|
||||
</span>
|
||||
|
|
Loading…
Reference in New Issue