diff --git a/src/js/controllers/buyMercadoLibre.js b/src/js/controllers/buyMercadoLibre.js
index 321d77d8a..79e2c1edf 100644
--- a/src/js/controllers/buyMercadoLibre.js
+++ b/src/js/controllers/buyMercadoLibre.js
@@ -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);
diff --git a/src/js/controllers/mercadoLibreCards.js b/src/js/controllers/mercadoLibreCards.js
index 438631c06..6d67a888a 100644
--- a/src/js/controllers/mercadoLibreCards.js
+++ b/src/js/controllers/mercadoLibreCards.js
@@ -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) {
diff --git a/src/js/services/mercadoLibreService.js b/src/js/services/mercadoLibreService.js
index 86bf74362..eb07ac685 100644
--- a/src/js/services/mercadoLibreService.js
+++ b/src/js/services/mercadoLibreService.js
@@ -140,7 +140,7 @@ angular.module('copayApp.services').factory('mercadoLibreService', function($htt
$log.info('Mercado Libre Gift Card Create/Update: ' + status);
return cb(null, data.data);
}, function(data) {
- $log.error('Mercado Libre Gift Card Create/Update: ' + data.data.message);
+ $log.error('Mercado Libre Gift Card Create/Update: ', JSON.stringify(data.data));
return cb(data.data);
});
};
diff --git a/src/sass/views/integrations/mercadolibre.scss b/src/sass/views/integrations/mercadolibre.scss
index 63b0032f5..54b0a7cfb 100644
--- a/src/sass/views/integrations/mercadolibre.scss
+++ b/src/sass/views/integrations/mercadolibre.scss
@@ -144,3 +144,50 @@
}
}
}
+
+#meli-card {
+ .card-head {
+ margin: 20px 0;
+ text-align: center;
+ .date {
+ font-size: 12px;
+ margin: 10px 0;
+ }
+ .amount {
+ font-size: 16px;
+ font-weight: bold;
+ }
+ }
+ .card-status {
+ text-align: center;
+ margin-bottom: 25px;
+ .card-status-desc {
+ margin-top: 5px;
+ font-size: 12px;
+ color: $v-text-secondary-color;
+ }
+ .redeem-pin {
+ font-weight: bold;
+ font-size: 22px;
+ }
+ .button-redeem {
+ margin-top: 10px;
+ background: transparent;
+ border: none;
+ font-size: 12px;
+ color: $v-text-accent-color;
+ }
+ }
+ .card-remove {
+ text-align: center;
+ margin-top: 30px;
+ .button-remove {
+ margin-top: 10px;
+ background: transparent;
+ border: none;
+ font-size: 12px;
+ color: red;
+ }
+ }
+
+}
diff --git a/www/views/mercadoLibreCards.html b/www/views/mercadoLibreCards.html
index 8488e318c..2888651fb 100644
--- a/www/views/mercadoLibreCards.html
+++ b/www/views/mercadoLibreCards.html
@@ -12,19 +12,20 @@
class="item item-avatar"
ng-hide="hideCards">
-
- 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/mercadolibre-card-details.html b/www/views/modals/mercadolibre-card-details.html index 12aa92870..f4366ad79 100644 --- a/www/views/modals/mercadolibre-card-details.html +++ b/www/views/modals/mercadolibre-card-details.html @@ -1,82 +1,75 @@ -