mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #6167 from ajp8164/feat/wc-card-compatibility
Currency and field compatibility with wavecrest card.
This commit is contained in:
commit
8b28e708bc
|
@ -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: ''
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div class="amount-bg"></div>
|
||||
<div class="amount">
|
||||
<div ng-if="bitpayCard.balance" ng-click="bitpayCard.update()">
|
||||
<div class="amount__balance">${{bitpayCard.balance}}</div>
|
||||
<div class="amount__balance">{{bitpayCard.currencySymbol}}{{bitpayCard.balance}}</div>
|
||||
|
||||
<div class="size-12 m5r" ng-if="bitpayCard.updatedOn">
|
||||
{{bitpayCard.updatedOn * 1000 | amTimeAgo}}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div class="bg icon-bitpay-card"></div>
|
||||
</i>
|
||||
<span>BitPay Visa® Card ({{card.lastFourDigits}})</span>
|
||||
<p>{{card.balance ? '$' + card.balance : 'Add funds to get started'|translate}} {{card.updatedOn ? (' · ' + (card.updatedOn * 1000 | amTimeAgo)) : ''}}</p>
|
||||
<p>{{card.balance ? card.currencySymbol + card.balance : 'Add funds to get started'|translate}} {{card.updatedOn ? (' · ' + (card.updatedOn * 1000 | amTimeAgo)) : ''}}</p>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
'balanced': tx.price.toString().indexOf('-') == -1 && !tx.pending,
|
||||
'text-gray': tx.price.toString().indexOf('-') == -1 && tx.pending}">
|
||||
<span ng-show="tx.price.toString().indexOf('-') == -1">+ </span>
|
||||
{{tx.price | currency:'$':2 }}
|
||||
{{tx.price | currency:bitpayCard.currencySymbol:2 }}
|
||||
</div>
|
||||
<time class="size-12 text-gray" ng-if="!tx.pending">{{tx.runningBalance | currency:'$':2}}</time>
|
||||
<time class="size-12 text-gray" ng-if="!tx.pending">{{tx.runningBalance | currency:bitpayCard.currencySymbol:2}}</time>
|
||||
<span class="size-12 text-gray text-italic" ng-if="tx.pending" class="tu" translate>Pending</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue