Merge pull request #6167 from ajp8164/feat/wc-card-compatibility
Currency and field compatibility with wavecrest card.
This commit is contained in:
commit
8b28e708bc
5 changed files with 33 additions and 6 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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: ''
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue