fix amazon"s next steps

This commit is contained in:
Matias Alejo Garcia 2017-01-31 08:21:18 -03:00
commit 54c8c64351
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
3 changed files with 33 additions and 31 deletions

View file

@ -3,19 +3,31 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
var root = {}; var root = {};
var credentials = {}; var credentials = {};
var setCredentials = function() { /*
/* * Development: 'testnet'
* Development: 'testnet' * Production: 'livenet'
* Production: 'livenet' */
*/ //credentials.NETWORK = 'livenet';
//credentials.NETWORK = 'livenet'; credentials.NETWORK = 'testnet';
credentials.NETWORK = 'testnet';
if (credentials.NETWORK == 'testnet') { if (credentials.NETWORK == 'testnet') {
credentials.BITPAY_API_URL = "https://test.bitpay.com"; credentials.BITPAY_API_URL = "https://test.bitpay.com";
} else { } else {
credentials.BITPAY_API_URL = "https://bitpay.com"; credentials.BITPAY_API_URL = "https://bitpay.com";
}; };
var homeItem = {
name: 'amazon',
title: 'Amazon Gift Cards',
icon: 'icon-amazon',
sref: 'tabs.giftcards.amazon',
};
var nextStepItem = {
name: 'amazon',
title: 'Buy a gift card',
icon: 'icon-amazon',
sref: 'tabs.giftcards.amazon',
}; };
var _getBitPay = function(endpoint) { var _getBitPay = function(endpoint) {
@ -63,6 +75,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
inv = JSON.stringify(inv); inv = JSON.stringify(inv);
storageService.setAmazonGiftCards(network, inv, function(err) { storageService.setAmazonGiftCards(network, inv, function(err) {
homeIntegrationsService.register(homeItem);
nextStepsService.unregister(nextStepItem.name);
return cb(err); return cb(err);
}); });
}); });
@ -139,28 +154,16 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
}); });
}; };
var register = function () { var register = function() {
storageService.getAmazonGiftCards(root.getNetwork(), function(err, giftCards) { storageService.getAmazonGiftCards(root.getNetwork(), function(err, giftCards) {
if (giftCards) { if (giftCards) {
homeIntegrationsService.register({ homeIntegrationsService.register(homeItem);
name: 'amazon',
title: 'Amazon Gift Cards',
icon: 'icon-amazon',
sref: 'tabs.giftcards.amazon',
});
} else { } else {
nextStepsService.register({ nextStepsService.register(nextStepItem);
name: 'amazon',
title: 'Buy a gift card',
icon: 'icon-amazon',
sref: 'tabs.giftcards.amazon',
});
} }
}); });
}; };
setCredentials();
register(); register();
return root; return root;
}); });

View file

@ -603,7 +603,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
}; };
root.updatePendingTransactions = lodash.throttle(function() { root.updatePendingTransactions = lodash.throttle(function() {
$log.debug('Updating pending transactions...'); $log.debug('Updating coinbase pending transactions...');
var pendingTransactions = { var pendingTransactions = {
data: {} data: {}
}; };

View file

@ -14,7 +14,7 @@
}; };
root.unregister = function(serviceName) { root.unregister = function(serviceName) {
console.log('[nextStepsService.js.16:serviceName:] UNR',serviceName); //TODO $log.info('Removing NextSteps entry:' + serviceName);
var newS = lodash.filter(services, function(x) { var newS = lodash.filter(services, function(x) {
return x.name!=serviceName; return x.name!=serviceName;
}); });
@ -25,7 +25,6 @@ console.log('[nextStepsService.js.16:serviceName:] UNR',serviceName); //TODO
while(newS.length) while(newS.length)
services.push(newS.pop()); services.push(newS.pop());
console.log('[nextStepsService.js.26:services:]',services); //TODO
}; };
root.get = function() { root.get = function() {