mirror of https://github.com/BTCPrivate/copay.git
Adds exchange rates during the top-up of the BitPay card
This commit is contained in:
parent
099f771faf
commit
938862bfe8
|
@ -229,6 +229,20 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
return result.replace('x', '*');
|
||||
};
|
||||
|
||||
$scope.getRates = function() {
|
||||
bitpayCardService.getRates($scope.alternativeIsoCode, function(err, res) {
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
return;
|
||||
}
|
||||
if ($scope.unitName == 'bits') {
|
||||
$scope.exchangeRate = '1,000,000 bits ~ ' + res.rate + ' ' + $scope.alternativeIsoCode;
|
||||
} else {
|
||||
$scope.exchangeRate = '1 BTC ~ ' + res.rate + ' ' + $scope.alternativeIsoCode;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.finish = function() {
|
||||
var _amount = evaluate(format($scope.amount));
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService, glideraService, bwcError) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService, glideraService, bwcError, bitpayCardService) {
|
||||
var cachedTxp = {};
|
||||
var toAmount;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
@ -824,4 +824,21 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getRates = function() {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var unitName = config.unitName;
|
||||
var alternativeIsoCode = config.alternativeIsoCode;
|
||||
bitpayCardService.getRates(alternativeIsoCode, function(err, res) {
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
return;
|
||||
}
|
||||
if (unitName == 'bits') {
|
||||
$scope.exchangeRate = '1,000,000 bits ~ ' + res.rate + ' ' + alternativeIsoCode;
|
||||
} else {
|
||||
$scope.exchangeRate = '1 BTC ~ ' + res.rate + ' ' + alternativeIsoCode;
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -305,6 +305,15 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
});
|
||||
};
|
||||
|
||||
root.getRates = function(currency, cb) {
|
||||
$http(_get('/rates/' + currency)).then(function(data) {
|
||||
$log.info('BitPay Get Rates: SUCCESS');
|
||||
return cb(data.data.error, data.data.data);
|
||||
}, function(data) {
|
||||
return cb(_setError('BitPay Error: Get Rates', data));
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
<div class="title">
|
||||
<span translate>Amount</span>
|
||||
<div class="size-12" ng-show="isGiftCard">Purchase Amount is limited to USD 1000 per day</div>
|
||||
<div class="size-12" ng-if="cardId" ng-init="getRates()">{{exchangeRate}}</div>
|
||||
<div ng-show="isGlidera">
|
||||
<div class="limits" ng-show="limits && isGlidera == 'buy'">
|
||||
<span>Daily buy limit</span>:
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount">{{displayAmount || '...'}} <span class="unit">{{displayUnit}}</span></div>
|
||||
<div class="right size-12" ng-if="cardId" ng-init="getRates()">{{exchangeRate}}</div>
|
||||
<div class="alternative">{{alternativeAmountStr || '...'}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue