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, {
|
$state.transitionTo($scope.nextStep, {
|
||||||
id: _cardId,
|
id: _cardId,
|
||||||
amount: _amount,
|
amount: _amount,
|
||||||
currency: $scope.showAlternativeAmount ? $scope.alternativeIsoCode : ''
|
currency: $scope.showAlternativeAmount ? $scope.alternativeIsoCode : $scope.unitName
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||||
|
|
|
@ -112,8 +112,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
$scope.network = amazonService.getNetwork();
|
$scope.network = amazonService.getNetwork();
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
onlyComplete: true,
|
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
|
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
@ -34,8 +34,8 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||||
var parsedAmount = coinbaseService.parseAmount(
|
var parsedAmount = txFormatService.parseAmount(
|
||||||
data.stateParams.amount,
|
data.stateParams.amount,
|
||||||
data.stateParams.currency);
|
data.stateParams.currency);
|
||||||
|
|
||||||
|
@ -48,6 +48,11 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
||||||
onlyComplete: true,
|
onlyComplete: true,
|
||||||
network: $scope.network
|
network: $scope.network
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (lodash.isEmpty($scope.wallets)) {
|
||||||
|
showErrorAndBack('No wallets available');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||||
|
|
||||||
ongoingProcess.set('connectingCoinbase', true);
|
ongoingProcess.set('connectingCoinbase', true);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
@ -36,8 +36,8 @@ angular.module('copayApp.controllers').controller('buyGlideraController', functi
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||||
var parsedAmount = glideraService.parseAmount(
|
var parsedAmount = txFormatService.parseAmount(
|
||||||
data.stateParams.amount,
|
data.stateParams.amount,
|
||||||
data.stateParams.currency);
|
data.stateParams.currency);
|
||||||
|
|
||||||
|
@ -50,6 +50,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController', functi
|
||||||
onlyComplete: true,
|
onlyComplete: true,
|
||||||
network: $scope.network
|
network: $scope.network
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (lodash.isEmpty($scope.wallets)) {
|
||||||
|
showErrorAndBack('No wallets available');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||||
|
|
||||||
ongoingProcess.set('connectingGlidera', true);
|
ongoingProcess.set('connectingGlidera', true);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
@ -117,8 +117,8 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', func
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||||
var parsedAmount = coinbaseService.parseAmount(
|
var parsedAmount = txFormatService.parseAmount(
|
||||||
data.stateParams.amount,
|
data.stateParams.amount,
|
||||||
data.stateParams.currency);
|
data.stateParams.currency);
|
||||||
|
|
||||||
|
@ -133,8 +133,15 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', func
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
m: 1, // Only 1-signature wallet
|
m: 1, // Only 1-signature wallet
|
||||||
onlyComplete: true,
|
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
|
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||||
|
|
||||||
ongoingProcess.set('connectingCoinbase', true);
|
ongoingProcess.set('connectingCoinbase', true);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
@ -36,8 +36,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController', funct
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
$scope.isFiat = data.stateParams.currency != 'bits' && data.stateParams.currency != 'BTC' ? true : false;
|
||||||
var parsedAmount = glideraService.parseAmount(
|
var parsedAmount = txFormatService.parseAmount(
|
||||||
data.stateParams.amount,
|
data.stateParams.amount,
|
||||||
data.stateParams.currency);
|
data.stateParams.currency);
|
||||||
|
|
||||||
|
@ -49,8 +49,15 @@ angular.module('copayApp.controllers').controller('sellGlideraController', funct
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
m: 1, // Only 1-signature wallet
|
m: 1, // Only 1-signature wallet
|
||||||
onlyComplete: true,
|
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
|
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||||
|
|
||||||
ongoingProcess.set('connectingGlidera', true);
|
ongoingProcess.set('connectingGlidera', true);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
@ -50,21 +50,21 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
|
||||||
cardId = data.stateParams.id;
|
cardId = data.stateParams.id;
|
||||||
|
|
||||||
if (!cardId) {
|
if (!cardId) {
|
||||||
showErrorAndBack('No card selected');
|
showErrorAndBack('No card selected');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parsedAmount = bitpayCardService.parseAmount(
|
var parsedAmount = txFormatService.parseAmount(
|
||||||
data.stateParams.amount,
|
data.stateParams.amount,
|
||||||
data.stateParams.currency);
|
data.stateParams.currency);
|
||||||
|
|
||||||
amount = parsedAmount.amount;
|
amount = parsedAmount.amount;
|
||||||
currency = parsedAmount.currency;
|
currency = parsedAmount.currency;
|
||||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||||
|
$scope.alternativeIsoCode = parsedAmount.alternativeIsoCode;
|
||||||
|
|
||||||
$scope.network = bitpayService.getEnvironment().network;
|
$scope.network = bitpayService.getEnvironment().network;
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
|
@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
|
||||||
}
|
}
|
||||||
$scope.onWalletSelect($scope.wallets[0]); // Default first wallet
|
$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);
|
if (err) $log.error(err);
|
||||||
$scope.rate = data.rate;
|
$scope.rate = data.rate;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1060,8 +1060,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
id: null,
|
id: null,
|
||||||
currency: 'USD',
|
currency: 'USD'
|
||||||
forceCurrency: true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('tabs.bitpayCard.amount', {
|
.state('tabs.bitpayCard.amount', {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 root = {};
|
||||||
|
|
||||||
var _setError = function(msg, e) {
|
var _setError = function(msg, e) {
|
||||||
|
@ -39,33 +39,6 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
|
||||||
return history;
|
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) {
|
root.sync = function(apiContext, cb) {
|
||||||
var json = {
|
var json = {
|
||||||
method: 'getDebitCards'
|
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() {
|
root.getSignupUrl = function() {
|
||||||
return credentials.HOST + '/signup';
|
return credentials.HOST + '/signup';
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,30 +53,6 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
||||||
return 'USD';
|
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() {
|
root.getSignupUrl = function() {
|
||||||
return credentials.HOST + '/register';
|
return credentials.HOST + '/register';
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,5 +155,34 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
||||||
return txps;
|
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;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="amount-label">
|
<div class="amount-label">
|
||||||
<div class="amount-final">{{amountUnitStr}}</div>
|
<div class="amount-final">{{amountUnitStr}}</div>
|
||||||
<div class="alternative" ng-show="isFiat && rate">
|
<div class="alternative">
|
||||||
@ {{rate | currency:'$':2}} per BTC
|
<span ng-if="rate">@ {{rate | currency:'$':2}} per BTC</span>
|
||||||
|
<span ng-if="!rate">...</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue