diff --git a/src/js/controllers/bitpayCard.js b/src/js/controllers/bitpayCard.js index 4c154bd9b..8f2f36e11 100644 --- a/src/js/controllers/bitpayCard.js +++ b/src/js/controllers/bitpayCard.js @@ -143,7 +143,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi var _getIconName = function(tx) { var icon = tx.mcc || tx.category || null; - if (!icon) return 'default'; + if (!icon || bitpayCardService.iconMap[icon] == undefined) return 'default'; return bitpayCardService.iconMap[icon]; }; @@ -201,6 +201,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi if (cards && cards[0]) { self.lastFourDigits = cards[0].lastFourDigits; self.balance = cards[0].balance; + self.currencySymbol = cards[0].currencySymbol; self.updatedOn = cards[0].updatedOn; } self.update(); diff --git a/src/js/services/bitpayCardService.js b/src/js/services/bitpayCardService.js index 2c22ffe53..01e92de04 100644 --- a/src/js/services/bitpayCardService.js +++ b/src/js/services/bitpayCardService.js @@ -14,7 +14,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log, for (var i = 0; i < invoices.length; i++) { var matched = false; for (var j = 0; j < history.length; j++) { - if (history[j].description[0].indexOf(invoices[i].id) > -1) { + if (history[j].description[0] && history[j].description[0].indexOf(invoices[i].id) > -1) { matched = true; } } @@ -64,6 +64,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log, n.id = x.id; n.lastFourDigits = x.lastFourDigits; n.token = x.token; + n.currency = x.currency; cards.push(n); }); @@ -76,6 +77,17 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log, }); }; + root.setCurrencySymbol = function(card) { + // Sets a currency symbol. + // Uses the currency code if no symbol is mapped (should never happen). + // Backaward compatibility for FirstView cards (all USD). + // This avoids users having to re-pair their account. + if (!card.currency) { + card.currency = 'USD'; + } + card.currencySymbol = root.currencySymbols[card.currency] || card.currency + ' '; + }; + // opts: range root.getHistory = function(cardId, opts, cb) { var invoices, transactions; @@ -240,6 +252,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log, // Async, no problem lodash.each(cards, function(x) { + root.setCurrencySymbol(x); root.addLastKnownBalance(x, function() {}); // async refresh @@ -259,6 +272,12 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log, * CONSTANTS */ + root.currencySymbols = { + 'EUR': '€', + 'GBP': '£', + 'USD': '$' + }; + root.bpTranCodes = { '00611': { merchant: { @@ -317,6 +336,13 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log, }, category: 'bp002', description: '' + }, + '9991': { // General assignment of a fee for WC card + merchant: { + name: 'Transaction Fee', + }, + category: 'bp002', + description: '' } }; diff --git a/www/views/bitpayCard.html b/www/views/bitpayCard.html index f3c2ead30..c13d1ee96 100644 --- a/www/views/bitpayCard.html +++ b/www/views/bitpayCard.html @@ -15,7 +15,7 @@
-
${{bitpayCard.balance}}
+
{{bitpayCard.currencySymbol}}{{bitpayCard.balance}}
{{bitpayCard.updatedOn * 1000 | amTimeAgo}} diff --git a/www/views/includes/bitpayCardsCard.html b/www/views/includes/bitpayCardsCard.html index b3b909c6e..dbbde5da8 100644 --- a/www/views/includes/bitpayCardsCard.html +++ b/www/views/includes/bitpayCardsCard.html @@ -12,7 +12,7 @@
BitPay Visa® Card ({{card.lastFourDigits}}) -

{{card.balance ? '$' + card.balance : 'Add funds to get started'|translate}} {{card.updatedOn ? (' · ' + (card.updatedOn * 1000 | amTimeAgo)) : ''}}

+

{{card.balance ? card.currencySymbol + card.balance : 'Add funds to get started'|translate}} {{card.updatedOn ? (' · ' + (card.updatedOn * 1000 | amTimeAgo)) : ''}}

diff --git a/www/views/includes/cardActivity.html b/www/views/includes/cardActivity.html index 678b267c5..612d50a64 100644 --- a/www/views/includes/cardActivity.html +++ b/www/views/includes/cardActivity.html @@ -35,9 +35,9 @@ 'balanced': tx.price.toString().indexOf('-') == -1 && !tx.pending, 'text-gray': tx.price.toString().indexOf('-') == -1 && tx.pending}"> + - {{tx.price | currency:'$':2 }} + {{tx.price | currency:bitpayCard.currencySymbol:2 }}
- + Pending