glidera new send and buy flow

This commit is contained in:
Gabriel Bazán 2016-12-02 09:48:56 -03:00
commit e44a305269
8 changed files with 184 additions and 75 deletions

View file

@ -21,6 +21,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
giftCardInvoiceTime = data.stateParams.giftCardInvoiceTime;
giftCardUUID = data.stateParams.giftCardUUID;
// Glidera parameters
toAmount = data.stateParams.toAmount;
cachedSendMax = {};
$scope.useSendMax = data.stateParams.useSendMax == 'true' ? true : false;
@ -131,6 +133,23 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.displayAmount = $scope.displayUnit = $scope.fee = $scope.alternativeAmountStr = $scope.insufficientFunds = $scope.noMatchingWallet = null;
};
$scope.getBuyPrice = function(token, price) {
if (!price || (price && !price.qty && !price.fiat)) {
$scope.buyPrice = null;
return;
}
$scope.gettingBuyPrice = true;
glideraService.buyPrice(token, price, function(err, buyPrice) {
$scope.gettingBuyPrice = false;
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
return;
}
$scope.buyPrice = buyPrice;
});
};
$scope.getSendMaxInfo = function() {
resetValues();
@ -537,6 +556,24 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}
};
$scope.get2faCode = function(token, cb) {
ongoingProcess.set('Sending 2FA code...', true);
$timeout(function() {
glideraService.get2faCode(token, function(err, sent) {
ongoingProcess.set('Sending 2FA code...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
return;
}
var title = gettextCatalog.getString("Please, enter the code below");
var message = gettextCatalog.getString("A SMS containing a confirmation code was sent to your phone.");
popupService.showPrompt(title, message, null, function(code) {
return cb(code);
});
});
}, 100);
};
function publishAndSign(wallet, txp, onSendStatusChange) {
walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err);