From acb4d3d354501467cc268a840ed706edb4f85023 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 18 Apr 2017 10:38:44 -0300 Subject: [PATCH] Top up a debit card is limited to 10000 usd --- src/js/controllers/topup.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/js/controllers/topup.js b/src/js/controllers/topup.js index 1a2d2ac03..43b1b4f43 100644 --- a/src/js/controllers/topup.js +++ b/src/js/controllers/topup.js @@ -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(); } };