UI styling. Improve error handle
This commit is contained in:
parent
d0ac2e4fa4
commit
0b3cb389ae
6 changed files with 132 additions and 80 deletions
|
|
@ -142,13 +142,21 @@ angular.module('copayApp.controllers').controller('buyMercadoLibreController', f
|
|||
var checkTransaction = lodash.throttle(function(count, dataSrc) {
|
||||
mercadoLibreService.createGiftCard(dataSrc, function(err, giftCard) {
|
||||
$log.debug("creating gift card " + count);
|
||||
if (err || !giftCard.pin) {
|
||||
if (err) {
|
||||
$scope.sendStatus = '';
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
giftCard = {};
|
||||
giftCard.status = 'FAILURE';
|
||||
}
|
||||
|
||||
if (giftCard && giftCard.cardStatus && (giftCard.cardStatus != 'active' && giftCard.cardStatus != 'inactive' && giftCard.cardStatus != 'expired')) {
|
||||
$scope.sendStatus = '';
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
giftCard = {};
|
||||
giftCard.status = 'FAILURE';
|
||||
}
|
||||
|
||||
|
||||
if (giftCard.status == 'PENDING' && count < 3) {
|
||||
$log.debug("Waiting for payment confirmation");
|
||||
checkTransaction(count + 1, dataSrc);
|
||||
|
|
|
|||
|
|
@ -24,18 +24,15 @@ angular.module('copayApp.controllers').controller('mercadoLibreCardsController',
|
|||
};
|
||||
|
||||
$scope.updatePendingGiftCards = lodash.debounce(function() {
|
||||
$scope.updatingPending = {};
|
||||
updateGiftCards(function() {
|
||||
var index = 0;
|
||||
var gcds = $scope.giftCards;
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
if (dataFromStorage.status == 'PENDING' || dataFromStorage.status == 'invalid') {
|
||||
if (dataFromStorage.status == 'PENDING') {
|
||||
$log.debug("Creating / Updating gift card");
|
||||
$scope.updatingPending[dataFromStorage.invoiceId] = true;
|
||||
|
||||
mercadoLibreService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
|
||||
$scope.updatingPending[dataFromStorage.invoiceId] = false;
|
||||
if (err) {
|
||||
popupService.showAlert('Error creating gift card', err);
|
||||
return;
|
||||
|
|
@ -44,6 +41,12 @@ angular.module('copayApp.controllers').controller('mercadoLibreCardsController',
|
|||
if (giftCard.status != 'PENDING') {
|
||||
var newData = {};
|
||||
|
||||
if (!giftCard.status) dataFromStorage.status = null; // Fix error from server
|
||||
|
||||
var cardStatus = giftCard.cardStatus;
|
||||
if (cardStatus && (cardStatus != 'active' && cardStatus != 'inactive' && cardStatus != 'expired'))
|
||||
giftCard.status = 'FAILURE';
|
||||
|
||||
lodash.merge(newData, dataFromStorage, giftCard);
|
||||
|
||||
mercadoLibreService.savePendingGiftCard(newData, null, function(err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue