glidera new send and buy flow
This commit is contained in:
parent
6f508184ef
commit
e44a305269
8 changed files with 184 additions and 75 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, $ionicPopover, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService) {
|
||||
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, $ionicPopover, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService) {
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
var unitDecimals;
|
||||
|
|
@ -15,22 +15,31 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isGiftCard = data.stateParams.isGiftCard;
|
||||
$scope.isGlidera = data.stateParams.isGlidera;
|
||||
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
|
||||
$scope.cardId = data.stateParams.cardId;
|
||||
$scope.showMenu = $ionicHistory.backView().stateName == 'tabs.send';
|
||||
$scope.isWallet = data.stateParams.isWallet;
|
||||
$scope.cardId = data.stateParams.cardId;
|
||||
$scope.toAddress = data.stateParams.toAddress;
|
||||
$scope.toName = data.stateParams.toName;
|
||||
$scope.toEmail = data.stateParams.toEmail;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera;
|
||||
$scope.toColor = data.stateParams.toColor;
|
||||
|
||||
$scope.customAmount = data.stateParams.customAmount;
|
||||
|
||||
if (!$scope.cardId && !$scope.isGiftCard && !data.stateParams.toAddress) {
|
||||
if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !data.stateParams.toAddress) {
|
||||
$log.error('Bad params at amount')
|
||||
throw ('bad params');
|
||||
}
|
||||
|
||||
glideraService.getLimits($scope.glideraAccessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
|
||||
var reNr = /^[1234567890\.]$/;
|
||||
var reOp = /^[\*\+\-\/]$/;
|
||||
|
||||
|
|
@ -325,6 +334,12 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
}, true);
|
||||
});
|
||||
});
|
||||
} else if ($scope.isGlidera) {
|
||||
$state.transitionTo('tabs.buyandsell.glidera.confirm', {
|
||||
toAmount: (amount * unitToSatoshi).toFixed(0),
|
||||
glideraBuy: true,
|
||||
glideraAccessToken: $scope.glideraAccessToken
|
||||
});
|
||||
} else {
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
if ($scope.customAmount) {
|
||||
|
|
|
|||
|
|
@ -9,65 +9,65 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
this.success = null;
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, w) {
|
||||
if (lodash.isEmpty(w)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
wallet = w;
|
||||
$log.debug('Wallet changed: ' + w.name);
|
||||
});
|
||||
|
||||
$scope.update = function(opts) {
|
||||
if (!$scope.token || !$scope.permissions) return;
|
||||
$log.debug('Updating Glidera Account...');
|
||||
var accessToken = $scope.token;
|
||||
var permissions = $scope.permissions;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
glideraService.getStatus(accessToken, function(err, data) {
|
||||
$scope.status = data;
|
||||
});
|
||||
|
||||
glideraService.getLimits(accessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
});
|
||||
|
||||
if (permissions.transaction_history) {
|
||||
glideraService.getTransactions(accessToken, function(err, data) {
|
||||
$scope.txs = data;
|
||||
});
|
||||
}
|
||||
|
||||
if (permissions.view_email_address && opts.fullUpdate) {
|
||||
glideraService.getEmail(accessToken, function(err, data) {
|
||||
$scope.email = data.email;
|
||||
});
|
||||
}
|
||||
if (permissions.personal_info && opts.fullUpdate) {
|
||||
glideraService.getPersonalInfo(accessToken, function(err, data) {
|
||||
$scope.personalInfo = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.getBuyPrice = function(token, price) {
|
||||
var self = this;
|
||||
if (!price || (price && !price.qty && !price.fiat)) {
|
||||
this.buyPrice = null;
|
||||
return;
|
||||
}
|
||||
this.gettingBuyPrice = true;
|
||||
glideraService.buyPrice(token, price, function(err, buyPrice) {
|
||||
self.gettingBuyPrice = false;
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
||||
return;
|
||||
}
|
||||
self.buyPrice = buyPrice;
|
||||
});
|
||||
};
|
||||
// $scope.$on('Wallet/Changed', function(event, w) {
|
||||
// if (lodash.isEmpty(w)) {
|
||||
// $log.debug('No wallet provided');
|
||||
// return;
|
||||
// }
|
||||
// wallet = w;
|
||||
// $log.debug('Wallet changed: ' + w.name);
|
||||
// });
|
||||
//
|
||||
// $scope.update = function(opts) {
|
||||
// if (!$scope.token || !$scope.permissions) return;
|
||||
// $log.debug('Updating Glidera Account...');
|
||||
// var accessToken = $scope.token;
|
||||
// var permissions = $scope.permissions;
|
||||
//
|
||||
// opts = opts || {};
|
||||
//
|
||||
// glideraService.getStatus(accessToken, function(err, data) {
|
||||
// $scope.status = data;
|
||||
// });
|
||||
//
|
||||
// glideraService.getLimits(accessToken, function(err, limits) {
|
||||
// $scope.limits = limits;
|
||||
// });
|
||||
//
|
||||
// if (permissions.transaction_history) {
|
||||
// glideraService.getTransactions(accessToken, function(err, data) {
|
||||
// $scope.txs = data;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// if (permissions.view_email_address && opts.fullUpdate) {
|
||||
// glideraService.getEmail(accessToken, function(err, data) {
|
||||
// $scope.email = data.email;
|
||||
// });
|
||||
// }
|
||||
// if (permissions.personal_info && opts.fullUpdate) {
|
||||
// glideraService.getPersonalInfo(accessToken, function(err, data) {
|
||||
// $scope.personalInfo = data;
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// this.getBuyPrice = function(token, price) {
|
||||
// var self = this;
|
||||
// if (!price || (price && !price.qty && !price.fiat)) {
|
||||
// this.buyPrice = null;
|
||||
// return;
|
||||
// }
|
||||
// this.gettingBuyPrice = true;
|
||||
// glideraService.buyPrice(token, price, function(err, buyPrice) {
|
||||
// self.gettingBuyPrice = false;
|
||||
// if (err) {
|
||||
// popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
||||
// return;
|
||||
// }
|
||||
// self.buyPrice = buyPrice;
|
||||
// });
|
||||
// };
|
||||
|
||||
this.get2faCode = function(token) {
|
||||
var self = this;
|
||||
|
|
@ -116,7 +116,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
}, 100);
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data){
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
$scope.token = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
|
|
@ -134,7 +134,9 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
}
|
||||
$scope.token = glidera.token;
|
||||
$scope.permissions = glidera.permissions;
|
||||
$scope.update({fullUpdate: true});
|
||||
$scope.update({
|
||||
fullUpdate: true
|
||||
});
|
||||
});
|
||||
|
||||
$scope.wallets = profileService.getWallets({
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -899,13 +899,40 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.buyandsell.glidera.sell', {
|
||||
url: '/sell',
|
||||
url: '/sell/:glideraSell/:glideraAccessToken',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'sellGlideraController',
|
||||
controllerAs: 'sell',
|
||||
templateUrl: 'views/sellGlidera.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
isGlidera: true
|
||||
}
|
||||
})
|
||||
.state('tabs.buyandsell.glidera.amount', {
|
||||
url: '/amount/:glideraBuy/:glideraAccessToken',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amountController',
|
||||
templateUrl: 'views/amount.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
isGlidera: true
|
||||
}
|
||||
})
|
||||
.state('tabs.buyandsell.glidera.confirm', {
|
||||
url: '/confirm/:toAmount/:glideraBuy/:glideraAccessToken',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'confirmController',
|
||||
templateUrl: 'views/confirm.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
isGlidera: true
|
||||
}
|
||||
})
|
||||
.state('tabs.preferences.glidera', {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
* Development: 'testnet'
|
||||
* Production: 'livenet'
|
||||
*/
|
||||
credentials.NETWORK = 'livenet';
|
||||
credentials.NETWORK = 'testnet';
|
||||
|
||||
if (credentials.NETWORK == 'testnet') {
|
||||
credentials.HOST = glidera.sandbox.host;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
position: absolute;
|
||||
top: 10px;
|
||||
}
|
||||
.amount-pane-send {
|
||||
.amount-pane-recipient {
|
||||
position: absolute;
|
||||
top: 95px;
|
||||
bottom: 0;
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.amount-pane-receive {
|
||||
.amount-pane-no-recipient {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
|
|
@ -84,6 +84,10 @@
|
|||
padding-top: 10px;
|
||||
color: $dark-gray;
|
||||
font-weight: bold;
|
||||
.limits {
|
||||
margin-top: 20px;
|
||||
color: $light-gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
.amount {
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
<ion-content scroll="false">
|
||||
|
||||
<div ng-if="!customAmount">
|
||||
<div ng-if="!customAmount && !isGlidera">
|
||||
<div class="item item-no-bottom-border recipient-label" translate>Recipient</div>
|
||||
|
||||
<div class="item item-text-wrap item-icon-left bitcoin-address" ng-class="{'item-big-icon-left':cardId}">
|
||||
<i class="icon big-icon-svg" ng-if="isWallet">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': toColor}" class="bg"/>
|
||||
</i>
|
||||
<span ng-if="!isWallet && !isGiftCard">
|
||||
<span ng-if="!isWallet && !isGiftCard && !isGlidera">
|
||||
<gravatar ng-if="!cardId" class="send-gravatar" name="{{toName}}" height="30" width="30" email="{{toEmail}}"></gravatar>
|
||||
<i ng-if="cardId" class="icon big-icon-svg">
|
||||
<div class="bg icon-bitpay-card"></div>
|
||||
|
|
@ -36,12 +36,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-class="{'amount-pane-send': !customAmount, 'amount-pane-receive': customAmount}">
|
||||
<div ng-class="{'amount-pane-recipient': !customAmount && !isGlidera, 'amount-pane-no-recipient': customAmount || isGlidera}">
|
||||
|
||||
<div class="amount-bar oh">
|
||||
<div class="title">
|
||||
<span translate>Amount</span>
|
||||
<span ng-show="isGiftCard" class="size-12">(Purchase Amount is limited to USD 500 per day)</span>
|
||||
<span ng-show="isGiftCard">(Purchase Amount is limited to USD 500 per day)</span>
|
||||
<div ng-show="isGlidera" class="limits">
|
||||
<span>Daily buy limit</span>:
|
||||
{{limits.dailyBuy|currency:'':2}} {{limits.currency}}
|
||||
(remaining {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}})
|
||||
<br>
|
||||
<span>Monthly buy limit</span>:
|
||||
{{limits.monthlyBuy|currency:'':2}} {{limits.currency}}
|
||||
(remaining {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -62,6 +71,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="keypad">
|
||||
<div class="row">
|
||||
<div class="col col-25 col-offset-75 operator-send"
|
||||
|
|
|
|||
|
|
@ -75,18 +75,32 @@
|
|||
ng-show="status && status.userCanTransact">
|
||||
<a ng-show="status.userCanBuy"
|
||||
class="item item-icon-right"
|
||||
href ui-sref="tabs.buyandsell.glidera.buy">
|
||||
href ui-sref="tabs.buyandsell.glidera.amount({glideraBuy: true, glideraAccessToken: token})">
|
||||
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="45" class="item-img-buy">
|
||||
Buy Bitcoin
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<a class="item item-icon-right"
|
||||
ng-show="status.userCanSell"
|
||||
href ui-sref="tabs.buyandsell.glidera.sell">
|
||||
href ui-sref="tabs.buyandsell.glidera.amount({glideraSell: true, glideraAccessToken: token})">
|
||||
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="45" class="item-img-sell">
|
||||
Sell Bitcoin
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<a ng-show="status.userCanBuy"
|
||||
class="item item-icon-right"
|
||||
href ui-sref="tabs.buyandsell.glidera.buy">
|
||||
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="45" class="item-img-buy">
|
||||
Buy Bitcoin OLD
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<a class="item item-icon-right"
|
||||
ng-show="status.userCanSell"
|
||||
href ui-sref="tabs.buyandsell.glidera.sell">
|
||||
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="45" class="item-img-sell">
|
||||
Sell Bitcoin OLD
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="list card" ng-show="permissions && permissions.transaction_history && txs.length > 0">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue