Adds support for EUR and GBP currencies

This commit is contained in:
Gustavo Maximiliano Cortez 2017-06-01 17:16:42 -03:00
parent 8b28e708bc
commit e0eb06156e
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
5 changed files with 30 additions and 5 deletions

View File

@ -184,6 +184,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.cardId = data.stateParams.id;
$scope.currency = bitpayCardService.getAvailableCurrency();
if (!$scope.cardId) {
$ionicHistory.nextViewOptions({

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError, txFormatService, sendMaxService) {
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, $sce, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError, txFormatService, sendMaxService) {
var amount;
var currency;
@ -91,7 +91,19 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
}
$scope.onWalletSelect($scope.wallets[0]); // Default first wallet
bitpayCardService.getRates('USD', function(err, data) {
var currencyCode = bitpayCardService.getAvailableCurrency();
var code;
switch(currencyCode) {
case 'EUR':
code = '€';
break;
case 'GBP':
code = '£';
break;
default : code = '$';
};
$scope.htmlCurrencyCode = $sce.trustAsHtml(code);
bitpayCardService.getRates(currencyCode, function(err, data) {
if (err) $log.error(err);
$scope.rate = data.rate;
});

View File

@ -7,7 +7,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
$log.error(msg);
var error = (e && e.data && e.data.error) ? e.data.error : msg;
return error;
};
};
var _processTransactions = function(invoices, history) {
invoices = invoices ||  [];
@ -41,6 +41,16 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
return history;
};
root.getAvailableCurrency = function() {
var config = configService.getSync().wallet.settings;
// ONLY "USD", "EUR" and "GBP"
switch (config.alternativeIsoCode) {
case 'EUR': return 'EUR';
case 'GBP': return 'GBP';
default: return 'USD'
};
};
root.sync = function(apiContext, cb) {
var json = {
method: 'getDebitCards'

View File

@ -23,7 +23,7 @@
<a class="button button-primary button-small m5t size-14"
style="padding: 0.5em 1em;"
ui-sref="tabs.bitpayCard.amount({nextStep: 'tabs.bitpayCard.topup'})" no-low-fee>
ui-sref="tabs.bitpayCard.amount({nextStep: 'tabs.bitpayCard.topup', currency: currency})" no-low-fee>
<i class="icon ion-plus m10r" style="vertical-align: baseline;"></i>
{{'Add Funds'|translate}}
</a>

View File

@ -19,7 +19,9 @@
<div class="amount-label">
<div class="amount-final">{{amountUnitStr}}</div>
<div class="alternative">
<span ng-if="rate">@ {{rate | currency:'$':2}} per BTC</span>
<span ng-if="rate">@
<span ng-bind-html="htmlCurrencyCode"></span>
{{rate | currency:' ':2}} per BTC</span>
<span ng-if="!rate">...</span>
</div>
</div>