Merge pull request #5897 from cmgustavo/bug/top-up-limits

Top up a debit card is limited to 10000 usd
This commit is contained in:
Matias Alejo Garcia 2017-04-18 18:35:41 +02:00 committed by GitHub
commit c7ab58b502

View file

@ -50,6 +50,22 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
}
};
var checkDailyLimit = function() {
if (currency == 'USD' && amount > 10000) {
showErrorAndBack('Top up is limited to USD 10,000 per day');
return;
}
bitpayCardService.getRates('USD', function(err, data) {
if (err) $log.error(err);
$scope.rate = data.rate;
if (currency == 'BTC' && (amount * data.rate) > 10000) {
showErrorAndBack('Top up is limited to USD 10,000 per day');
return;
}
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
cardId = data.stateParams.id;
sendMax = data.stateParams.useSendMax;
@ -81,11 +97,6 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
}
$scope.onWalletSelect($scope.wallets[0]); // Default first wallet
bitpayCardService.getRates('USD', function(err, data) {
if (err) $log.error(err);
$scope.rate = data.rate;
});
bitpayCardService.get({ cardId: cardId, noRefresh: true }, function(err, card) {
if (err) {
showErrorAndBack(err);
@ -207,11 +218,14 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
amount = parsedAmount.amount;
currency = parsedAmount.currency;
checkDailyLimit();
$scope.amountUnitStr = parsedAmount.amountUnitStr;
$timeout(function() {
$scope.$digest();
}, 100);
});
} else {
checkDailyLimit();
}
};