diff --git a/src/js/controllers/bitpayCard.js b/src/js/controllers/bitpayCard.js index 24863eebc..c17cdf4a1 100644 --- a/src/js/controllers/bitpayCard.js +++ b/src/js/controllers/bitpayCard.js @@ -184,7 +184,6 @@ 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({ @@ -204,6 +203,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi self.balance = cards[0].balance; self.currencySymbol = cards[0].currencySymbol; self.updatedOn = cards[0].updatedOn; + self.currency = cards[0].currency; } self.update(); }); diff --git a/src/js/controllers/topup.js b/src/js/controllers/topup.js index 6ed932eca..ce9ff7964 100644 --- a/src/js/controllers/topup.js +++ b/src/js/controllers/topup.js @@ -91,28 +91,17 @@ angular.module('copayApp.controllers').controller('topUpController', function($s } $scope.onWalletSelect($scope.wallets[0]); // Default first wallet - var currencyCode = bitpayCardService.getAvailableCurrency(); - var code; - switch(currencyCode) { - case 'EUR': - $scope.currencySymbol = '€'; - break; - case 'GBP': - $scope.currencySymbol = '£'; - break; - default : $scope.currencySymbol = '$'; - }; - bitpayCardService.getRates(currencyCode, function(err, data) { - if (err) $log.error(err); - $scope.rate = data.rate; - }); - bitpayCardService.get({ cardId: cardId, noRefresh: true }, function(err, card) { if (err) { showErrorAndBack(null, err); return; } $scope.cardInfo = card[0]; + bitpayCardService.setCurrencySymbol($scope.cardInfo); + bitpayCardService.getRates($scope.cardInfo.currency, function(err, data) { + if (err) $log.error(err); + $scope.rate = data.rate; + }); }); }); diff --git a/src/js/services/bitpayCardService.js b/src/js/services/bitpayCardService.js index b4a747255..7c38abafd 100644 --- a/src/js/services/bitpayCardService.js +++ b/src/js/services/bitpayCardService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('bitpayCardService', function($log, $rootScope, $filter, lodash, storageService, bitauthService, platformInfo, moment, appIdentityService, bitpayService, nextStepsService, configService, txFormatService, appConfigService) { +angular.module('copayApp.services').factory('bitpayCardService', function($log, $rootScope, $filter, lodash, storageService, bitauthService, platformInfo, moment, appIdentityService, bitpayService, nextStepsService, txFormatService, appConfigService) { var root = {}; var _setError = function(msg, e) { @@ -41,16 +41,6 @@ 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' diff --git a/www/views/bitpayCard.html b/www/views/bitpayCard.html index c1e6ad9c6..5f0a43e71 100644 --- a/www/views/bitpayCard.html +++ b/www/views/bitpayCard.html @@ -23,7 +23,7 @@ + ui-sref="tabs.bitpayCard.amount({nextStep: 'tabs.bitpayCard.topup', currency: bitpayCard.currency})" no-low-fee> {{'Add Funds'|translate}} diff --git a/www/views/topup.html b/www/views/topup.html index 2542c645f..61e8c800c 100644 --- a/www/views/topup.html +++ b/www/views/topup.html @@ -20,7 +20,7 @@
{{amountUnitStr}}
@ - {{rate | currency:currencySymbol:2}} per BTC + {{rate | currency:cardInfo.currencySymbol:2}} per BTC ...