mirror of https://github.com/BTCPrivate/copay.git
Enable input in bits/BTC to reload the debit card
This commit is contained in:
parent
c31fb5f5c4
commit
bc2d530e90
|
@ -224,7 +224,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$state.transitionTo($scope.nextStep, {
|
||||
id: _cardId,
|
||||
amount: _amount,
|
||||
currency: $scope.showAlternativeAmount ? $scope.alternativeIsoCode : ''
|
||||
currency: $scope.showAlternativeAmount ? $scope.alternativeIsoCode : $scope.unitName
|
||||
});
|
||||
} else {
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
|
|
|
@ -112,8 +112,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
|||
$scope.network = amazonService.getNetwork();
|
||||
$scope.wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
network: $scope.network,
|
||||
hasFunds: true
|
||||
});
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack('No wallets with funds');
|
||||
return;
|
||||
}
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService) {
|
||||
angular.module('copayApp.controllers').controller('buyCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, txFormatService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
@ -34,8 +34,8 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
var parsedAmount = coinbaseService.parseAmount(
|
||||
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
|
@ -48,6 +48,11 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
|||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack('No wallets available');
|
||||
return;
|
||||
}
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
|
||||
ongoingProcess.set('connectingCoinbase', true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, platformInfo, txFormatService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
@ -36,8 +36,8 @@ angular.module('copayApp.controllers').controller('buyGlideraController', functi
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
var parsedAmount = glideraService.parseAmount(
|
||||
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
|
@ -50,6 +50,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController', functi
|
|||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack('No wallets available');
|
||||
return;
|
||||
}
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, appConfigService, configService) {
|
||||
angular.module('copayApp.controllers').controller('sellCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, appConfigService, configService, txFormatService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
@ -117,8 +117,8 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', func
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
var parsedAmount = coinbaseService.parseAmount(
|
||||
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
|
@ -133,8 +133,15 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', func
|
|||
$scope.wallets = profileService.getWallets({
|
||||
m: 1, // Only 1-signature wallet
|
||||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
network: $scope.network,
|
||||
hasFunds: true,
|
||||
minAmount: parsedAmount.amountSat
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack('Insufficient funds');
|
||||
return;
|
||||
}
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
|
||||
ongoingProcess.set('connectingCoinbase', true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, configService, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, txFormatService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
@ -36,8 +36,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController', funct
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
var parsedAmount = glideraService.parseAmount(
|
||||
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
|
@ -49,8 +49,15 @@ angular.module('copayApp.controllers').controller('sellGlideraController', funct
|
|||
$scope.wallets = profileService.getWallets({
|
||||
m: 1, // Only 1-signature wallet
|
||||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
network: $scope.network,
|
||||
hasFunds: true,
|
||||
minAmount: parsedAmount.amountSat
|
||||
});
|
||||
|
||||
if (lodash.isEmpty($scope.wallets)) {
|
||||
showErrorAndBack('Insufficient funds');
|
||||
return;
|
||||
}
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError) {
|
||||
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError, txFormatService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
@ -50,21 +50,21 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
cardId = data.stateParams.id;
|
||||
|
||||
if (!cardId) {
|
||||
showErrorAndBack('No card selected');
|
||||
return;
|
||||
}
|
||||
|
||||
var parsedAmount = bitpayCardService.parseAmount(
|
||||
|
||||
var parsedAmount = txFormatService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
amount = parsedAmount.amount;
|
||||
currency = parsedAmount.currency;
|
||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||
$scope.alternativeIsoCode = parsedAmount.alternativeIsoCode;
|
||||
|
||||
$scope.network = bitpayService.getEnvironment().network;
|
||||
$scope.wallets = profileService.getWallets({
|
||||
|
@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
|||
}
|
||||
$scope.onWalletSelect($scope.wallets[0]); // Default first wallet
|
||||
|
||||
bitpayCardService.getRates(currency, function(err, data) {
|
||||
bitpayCardService.getRates($scope.alternativeIsoCode, function(err, data) {
|
||||
if (err) $log.error(err);
|
||||
$scope.rate = data.rate;
|
||||
});
|
||||
|
|
|
@ -1060,8 +1060,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
params: {
|
||||
id: null,
|
||||
currency: 'USD',
|
||||
forceCurrency: true
|
||||
currency: 'USD'
|
||||
}
|
||||
})
|
||||
.state('tabs.bitpayCard.amount', {
|
||||
|
|
|
@ -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, rateService) {
|
||||
angular.module('copayApp.services').factory('bitpayCardService', function($log, $rootScope, $filter, lodash, storageService, bitauthService, platformInfo, moment, appIdentityService, bitpayService, nextStepsService, configService, txFormatService, appConfigService) {
|
||||
var root = {};
|
||||
|
||||
var _setError = function(msg, e) {
|
||||
|
@ -39,33 +39,6 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
|||
return history;
|
||||
};
|
||||
|
||||
root.parseAmount = function(amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var amountUnitStr;
|
||||
var amountSat;
|
||||
|
||||
// IF 'USD'
|
||||
if (currency) {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
amountSat = rateService.fromFiat(amount, currency).toFixed(0);
|
||||
} else {
|
||||
amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = txFormatService.formatAmountStr(amountSat);
|
||||
// convert unit to BTC
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = 'BTC';
|
||||
}
|
||||
|
||||
return {
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
amountSat: amountSat,
|
||||
amountUnitStr: amountUnitStr
|
||||
};
|
||||
};
|
||||
|
||||
root.sync = function(apiContext, cb) {
|
||||
var json = {
|
||||
method: 'getDebitCards'
|
||||
|
|
|
@ -107,30 +107,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
};
|
||||
|
||||
root.parseAmount = function(amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var amountUnitStr;
|
||||
|
||||
// IF 'USD'
|
||||
if (currency) {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
} else {
|
||||
var amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = txFormatService.formatAmountStr(amountSat);
|
||||
// convert unit to BTC
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = 'BTC';
|
||||
}
|
||||
|
||||
return {
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
amountUnitStr: amountUnitStr
|
||||
};
|
||||
};
|
||||
|
||||
root.getSignupUrl = function() {
|
||||
return credentials.HOST + '/signup';
|
||||
}
|
||||
|
|
|
@ -53,30 +53,6 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
return 'USD';
|
||||
};
|
||||
|
||||
root.parseAmount = function(amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var amountUnitStr;
|
||||
|
||||
// IF 'USD'
|
||||
if (currency) {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
} else {
|
||||
var amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = txFormatService.formatAmountStr(amountSat);
|
||||
// convert unit to BTC
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = 'BTC';
|
||||
}
|
||||
|
||||
return {
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
amountUnitStr: amountUnitStr
|
||||
};
|
||||
};
|
||||
|
||||
root.getSignupUrl = function() {
|
||||
return credentials.HOST + '/register';
|
||||
}
|
||||
|
|
|
@ -155,5 +155,34 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
return txps;
|
||||
};
|
||||
|
||||
root.parseAmount = function(amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var amountUnitStr;
|
||||
var amountSat;
|
||||
var alternativeIsoCode = config.alternativeIsoCode;
|
||||
|
||||
// If fiat currency
|
||||
if (currency != 'bits' && currency != 'BTC') {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
amountSat = rateService.fromFiat(amount, currency).toFixed(0);
|
||||
} else {
|
||||
amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = root.formatAmountStr(amountSat);
|
||||
// convert unit to BTC
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = 'BTC';
|
||||
}
|
||||
|
||||
return {
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
alternativeIsoCode: alternativeIsoCode,
|
||||
amountSat: amountSat,
|
||||
amountUnitStr: amountUnitStr
|
||||
};
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount-final">{{amountUnitStr}}</div>
|
||||
<div class="alternative" ng-show="isFiat && rate">
|
||||
@ {{rate | currency:'$':2}} per BTC
|
||||
<div class="alternative">
|
||||
<span ng-if="rate">@ {{rate | currency:'$':2}} per BTC</span>
|
||||
<span ng-if="!rate">...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue