Fix amount process
This commit is contained in:
parent
964318d57f
commit
3b0dceccf5
5 changed files with 132 additions and 29 deletions
|
|
@ -66,11 +66,20 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.coinbasePaymentMethods = [];
|
||||
coinbaseService.getPaymentMethods(data.accessToken, function(err, p) {
|
||||
lodash.each(p.data, function(pm) {
|
||||
if (pm.allow_buy) {
|
||||
$scope.coinbasePaymentMethods.push(pm);
|
||||
}
|
||||
if (pm.allow_buy && pm.primary_buy) {
|
||||
$scope.coinbaseSelectedPaymentMethod = pm;
|
||||
if ($scope.isCoinbase == 'sell') {
|
||||
if (pm.allow_sell) {
|
||||
$scope.coinbasePaymentMethods.push(pm);
|
||||
}
|
||||
if (pm.allow_sell && pm.primary_sell) {
|
||||
$scope.coinbaseSelectedPaymentMethod = pm;
|
||||
}
|
||||
} else {
|
||||
if (pm.allow_buy) {
|
||||
$scope.coinbasePaymentMethods.push(pm);
|
||||
}
|
||||
if (pm.allow_buy && pm.primary_buy) {
|
||||
$scope.coinbaseSelectedPaymentMethod = pm;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -386,7 +395,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
return;
|
||||
}
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
$state.transitionTo('tabs.buyandsell.glidera.confirm', {
|
||||
$state.transitionTo('tabs.buyandsell.coinbase.confirm', {
|
||||
toAmount: (amount * unitToSatoshi).toFixed(0),
|
||||
isCoinbase: $scope.isCoinbase,
|
||||
coinbasePaymentMethodId: $scope.coinbaseSelectedPaymentMethod.id
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService, glideraService, bwcError, bitpayCardService) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService, glideraService, bwcError, coinbaseService, bitpayCardService) {
|
||||
var cachedTxp = {};
|
||||
var toAmount;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
|
@ -25,6 +25,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.isGlidera = data.stateParams.isGlidera;
|
||||
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
|
||||
|
||||
// Coinbase parameters
|
||||
$scope.isCoinbase = data.stateParams.isCoinbase;
|
||||
$scope.coinbasePaymentMethodId = data.stateParams.coinbasePaymentMethodId;
|
||||
|
||||
toAmount = data.stateParams.toAmount;
|
||||
cachedSendMax = {};
|
||||
$scope.useSendMax = data.stateParams.useSendMax == 'true' ? true : false;
|
||||
|
|
@ -50,6 +54,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
|
||||
$scope.feeLevel = feeService.feeOpts[feeLevel];
|
||||
if ($scope.isGlidera) $scope.network = glideraService.getEnvironment();
|
||||
else if ($scope.isCoinbase) $scope.network = coinbaseService.getEnvironment();
|
||||
else $scope.network = (new bitcore.Address($scope.toAddress)).network.name;
|
||||
resetValues();
|
||||
setwallets();
|
||||
|
|
@ -283,7 +288,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
|
||||
$scope.showWalletSelector = function() {
|
||||
$scope.walletSelectorTitle = $scope.isGlidera == 'buy' ? 'Receive in' : $scope.isGlidera == 'sell' ? 'Sell From' : gettextCatalog.getString('Send from');
|
||||
$scope.walletSelectorTitle = ($scope.isGlidera || $scope.isCoinbase) == 'buy' ? 'Receive in' : ($scope.isGlidera || $scope.isCoinbase) == 'sell' ? 'Sell From' : gettextCatalog.getString('Send from');
|
||||
if (!$scope.useSendMax && ($scope.insufficientFunds || $scope.noMatchingWallet)) return;
|
||||
$scope.showWallets = true;
|
||||
};
|
||||
|
|
@ -362,7 +367,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.wallet = wallet;
|
||||
$scope.fee = $scope.txp = null;
|
||||
|
||||
if ($scope.isGlidera) return;
|
||||
if ($scope.isGlidera || $scope.isCoinbase) return;
|
||||
if (stop) {
|
||||
$timeout.cancel(stop);
|
||||
stop = null;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,34 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
var isCordova = platformInfo.isCordova;
|
||||
var isNW = platformInfo.isNW;
|
||||
|
||||
// FAKE DATA
|
||||
var isFake = true;
|
||||
|
||||
root.priceSensitivity = [
|
||||
{
|
||||
value: 0.5,
|
||||
name: '0.5%'
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
name: '1%'
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
name: '2%'
|
||||
},
|
||||
{
|
||||
value: 5,
|
||||
name: '5%'
|
||||
},
|
||||
{
|
||||
value: 10,
|
||||
name: '10%'
|
||||
}
|
||||
];
|
||||
|
||||
root.selectedPriceSensitivity = root.priceSensitivity[1];
|
||||
|
||||
root.setCredentials = function() {
|
||||
|
||||
if (!$window.externalServices || !$window.externalServices.coinbase) {
|
||||
|
|
@ -304,6 +332,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.getPaymentMethods = function(token, cb) {
|
||||
if (isFake) return cb(null, payment_methods);
|
||||
$http(_get('/payment-methods', token)).then(function(data) {
|
||||
$log.info('Coinbase Get Payment Methods: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
|
|
@ -603,6 +632,60 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
});
|
||||
};
|
||||
|
||||
var payment_methods = {
|
||||
"pagination": {
|
||||
"ending_before": null,
|
||||
"starting_after": null,
|
||||
"limit": 25,
|
||||
"order": "desc",
|
||||
"previous_uri": null,
|
||||
"next_uri": null
|
||||
},
|
||||
"data": [
|
||||
{
|
||||
"id": "127b4d76-a1a0-5de7-8185-3657d7b526ec",
|
||||
"type": "fiat_account",
|
||||
"name": "USD Wallet",
|
||||
"currency": "USD",
|
||||
"primary_buy": false,
|
||||
"primary_sell": false,
|
||||
"allow_buy": true,
|
||||
"allow_sell": true,
|
||||
"allow_deposit": true,
|
||||
"allow_withdraw": true,
|
||||
"instant_buy": true,
|
||||
"instant_sell": true,
|
||||
"created_at": "2015-02-24T14:30:30-08:00",
|
||||
"updated_at": "2015-02-24T14:30:30-08:00",
|
||||
"resource": "payment_method",
|
||||
"resource_path": "/v2/payment-methods/127b4d76-a1a0-5de7-8185-3657d7b526ec",
|
||||
"fiat_account": {
|
||||
"id": "a077fff9-312b-559b-af98-146c33e27388",
|
||||
"resource": "account",
|
||||
"resource_path": "/v2/accounts/a077fff9-312b-559b-af98-146c33e27388"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "83562370-3e5c-51db-87da-752af5ab9559",
|
||||
"type": "ach_bank_account",
|
||||
"name": "International Bank *****1111",
|
||||
"currency": "USD",
|
||||
"primary_buy": true,
|
||||
"primary_sell": true,
|
||||
"allow_buy": true,
|
||||
"allow_sell": true,
|
||||
"allow_deposit": true,
|
||||
"allow_withdraw": true,
|
||||
"instant_buy": false,
|
||||
"instant_sell": false,
|
||||
"created_at": "2015-01-31T20:49:02Z",
|
||||
"updated_at": "2015-02-11T16:53:57-08:00",
|
||||
"resource": "payment_method",
|
||||
"resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return root;
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue