mirror of https://github.com/BTCPrivate/copay.git
Currency and field compatibility with wavecrest card.
This commit is contained in:
parent
382c81f67a
commit
33f3669746
|
@ -143,7 +143,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
||||||
|
|
||||||
var _getIconName = function(tx) {
|
var _getIconName = function(tx) {
|
||||||
var icon = tx.mcc || tx.category || null;
|
var icon = tx.mcc || tx.category || null;
|
||||||
if (!icon) return 'default';
|
if (!icon || bitpayCardService.iconMap[icon] == undefined) return 'default';
|
||||||
return bitpayCardService.iconMap[icon];
|
return bitpayCardService.iconMap[icon];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,6 +201,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
||||||
if (cards && cards[0]) {
|
if (cards && cards[0]) {
|
||||||
self.lastFourDigits = cards[0].lastFourDigits;
|
self.lastFourDigits = cards[0].lastFourDigits;
|
||||||
self.balance = cards[0].balance;
|
self.balance = cards[0].balance;
|
||||||
|
self.currencySymbol = cards[0].currencySymbol;
|
||||||
self.updatedOn = cards[0].updatedOn;
|
self.updatedOn = cards[0].updatedOn;
|
||||||
}
|
}
|
||||||
self.update();
|
self.update();
|
||||||
|
|
|
@ -14,7 +14,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
||||||
for (var i = 0; i < invoices.length; i++) {
|
for (var i = 0; i < invoices.length; i++) {
|
||||||
var matched = false;
|
var matched = false;
|
||||||
for (var j = 0; j < history.length; j++) {
|
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;
|
matched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
||||||
n.id = x.id;
|
n.id = x.id;
|
||||||
n.lastFourDigits = x.lastFourDigits;
|
n.lastFourDigits = x.lastFourDigits;
|
||||||
n.token = x.token;
|
n.token = x.token;
|
||||||
|
n.currency = x.currency;
|
||||||
cards.push(n);
|
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
|
// opts: range
|
||||||
root.getHistory = function(cardId, opts, cb) {
|
root.getHistory = function(cardId, opts, cb) {
|
||||||
var invoices, transactions;
|
var invoices, transactions;
|
||||||
|
@ -240,6 +252,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
||||||
// Async, no problem
|
// Async, no problem
|
||||||
lodash.each(cards, function(x) {
|
lodash.each(cards, function(x) {
|
||||||
|
|
||||||
|
root.setCurrencySymbol(x);
|
||||||
root.addLastKnownBalance(x, function() {});
|
root.addLastKnownBalance(x, function() {});
|
||||||
|
|
||||||
// async refresh
|
// async refresh
|
||||||
|
@ -259,6 +272,12 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
||||||
* CONSTANTS
|
* CONSTANTS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
root.currencySymbols = {
|
||||||
|
'EUR': '€',
|
||||||
|
'GBP': '£',
|
||||||
|
'USD': '$'
|
||||||
|
};
|
||||||
|
|
||||||
root.bpTranCodes = {
|
root.bpTranCodes = {
|
||||||
'00611': {
|
'00611': {
|
||||||
merchant: {
|
merchant: {
|
||||||
|
@ -317,6 +336,13 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
||||||
},
|
},
|
||||||
category: 'bp002',
|
category: 'bp002',
|
||||||
description: ''
|
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-bg"></div>
|
||||||
<div class="amount">
|
<div class="amount">
|
||||||
<div ng-if="bitpayCard.balance" ng-click="bitpayCard.update()">
|
<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">
|
<div class="size-12 m5r" ng-if="bitpayCard.updatedOn">
|
||||||
{{bitpayCard.updatedOn * 1000 | amTimeAgo}}
|
{{bitpayCard.updatedOn * 1000 | amTimeAgo}}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="bg icon-bitpay-card"></div>
|
<div class="bg icon-bitpay-card"></div>
|
||||||
</i>
|
</i>
|
||||||
<span>BitPay Visa® Card ({{card.lastFourDigits}})</span>
|
<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>
|
<i class="icon bp-arrow-right"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -35,9 +35,9 @@
|
||||||
'balanced': tx.price.toString().indexOf('-') == -1 && !tx.pending,
|
'balanced': tx.price.toString().indexOf('-') == -1 && !tx.pending,
|
||||||
'text-gray': 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>
|
<span ng-show="tx.price.toString().indexOf('-') == -1">+ </span>
|
||||||
{{tx.price | currency:'$':2 }}
|
{{tx.price | currency:bitpayCard.currencySymbol:2 }}
|
||||||
</div>
|
</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>
|
<span class="size-12 text-gray text-italic" ng-if="tx.pending" class="tu" translate>Pending</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue