mirror of https://github.com/BTCPrivate/copay.git
Fix amount process
This commit is contained in:
parent
964318d57f
commit
3b0dceccf5
|
@ -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;
|
||||
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
<div class="amount-bar oh">
|
||||
<div class="title">
|
||||
<span translate>Amount</span>
|
||||
<span ng-show="!isCoinbase" translate>Amount</span>
|
||||
<div class="size-12" ng-show="isGiftCard">Purchase Amount is limited to USD 1000 per day</div>
|
||||
<div class="size-12" ng-if="cardId" ng-init="getRates()">{{exchangeRate}}</div>
|
||||
<div ng-show="isGlidera">
|
||||
|
@ -68,22 +68,23 @@
|
|||
</div>
|
||||
|
||||
<div ng-show="isCoinbase">
|
||||
<div class="limits" ng-show="coinbaseBuyPrice && isCoinbase == 'buy'">
|
||||
1 BTC ~ {{coinbaseBuyPrice.amount}} {{coinbaseBuyPrice.currency}}
|
||||
</div>
|
||||
<div class="limits" ng-show="coinbaseSellPrice && isCoinbase == 'sell'">
|
||||
1 BTC ~ {{coinbaseSellPrice.amount}} {{coinbaseSellPrice.currency}}
|
||||
</div>
|
||||
<div class="list select">
|
||||
<label class="item item-input item-select">
|
||||
<div class="input-label">
|
||||
Payment Method
|
||||
<span ng-show="isCoinbase == 'buy'">Payment Method</span>
|
||||
<span ng-show="isCoinbase == 'sell'">Deposit into</span>
|
||||
</div>
|
||||
<select ng-model="coinbaseSelectedPaymentMethod.id"
|
||||
ng-options="item.id as item.name for item in coinbasePaymentMethods">
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="limits" ng-show="coinbaseBuyPrice && isCoinbase == 'buy'">
|
||||
1 BTC ~ {{coinbaseBuyPrice.amount}} {{coinbaseBuyPrice.currency}}
|
||||
</div>
|
||||
<div class="limits" ng-show="coinbaseSellPrice && isCoinbase == 'sell'">
|
||||
1 BTC ~ {{coinbaseSellPrice.amount}} {{coinbaseSellPrice.currency}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<div class="item head">
|
||||
<div class="sending-label">
|
||||
<img src="img/icon-tx-sent-outline.svg">
|
||||
<span translate ng-if="!useSendMax && !isGlidera">Sending</span>
|
||||
<span translate ng-if="!useSendMax && !(isGlidera || isCoinbase)">Sending</span>
|
||||
<span translate ng-if="useSendMax">Sending maximum amount</span>
|
||||
<span ng-if="isGlidera == 'buy'">Buying</span>
|
||||
<span ng-if="isGlidera == 'sell'">Selling</span>
|
||||
<span ng-if="(isGlidera || isCoinbase) == 'buy'">Buying</span>
|
||||
<span ng-if="(isGlidera || isCoinbase) == 'sell'">Selling</span>
|
||||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount">{{displayAmount || '...'}} <span class="unit">{{displayUnit}}</span></div>
|
||||
|
@ -30,16 +30,17 @@
|
|||
<span class="item-note" ng-if="paymentExpired.value" ng-style="{'color': 'red'}" translate>Expired</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span class="label" ng-if="!isGlidera" translate>To</span>
|
||||
<span class="label" ng-if="isGlidera == 'buy'">From</span>
|
||||
<span class="label" ng-if="isGlidera == 'sell'">To</span>
|
||||
<span class="label" ng-if="!(isGlidera || isCoinbase)" translate>To</span>
|
||||
<span class="label" ng-if="(isGlidera || isCoinbase) == 'buy'">From</span>
|
||||
<span class="label" ng-if="(isGlidera || isCoinbase) == 'sell'">To</span>
|
||||
<span class="payment-proposal-to">
|
||||
<img ng-if="!cardId && !isGiftCard && !isGlidera" src="img/icon-bitcoin-small.svg">
|
||||
<img ng-if="!cardId && !isGiftCard && !isGlidera && !isCoinbase" src="img/icon-bitcoin-small.svg">
|
||||
<img ng-if="cardId" src="img/icon-card.svg" width="34">
|
||||
<i ng-if="isGiftCard" class="icon big-icon-svg">
|
||||
<div class="bg icon-amazon"></div>
|
||||
</i>
|
||||
<img ng-if="isGlidera" src="img/glidera-logo.png" width="90"/>
|
||||
<img ng-if="isCoinbase" src="img/coinbase-logo.png" width="90"/>
|
||||
|
||||
<div copy-to-clipboard="toAddress" ng-if="!paypro" class="ellipsis">
|
||||
<contact ng-if="!toName" address="{{toAddress}}"></contact>
|
||||
|
@ -57,9 +58,9 @@
|
|||
</span>
|
||||
</div>
|
||||
<a class="item item-icon-right" ng-hide="!useSendMax && (insufficientFunds || noMatchingWallet)" ng-click="showWalletSelector()">
|
||||
<span class="label" ng-if="!isGlidera" translate>From</span>
|
||||
<span class="label" ng-if="isGlidera == 'buy'">To</span>
|
||||
<span class="label" ng-if="isGlidera == 'sell'">From</span>
|
||||
<span class="label" ng-if="!(isGlidera || isCoinbase)" translate>From</span>
|
||||
<span class="label" ng-if="(isGlidera || isCoinbase) == 'buy'">To</span>
|
||||
<span class="label" ng-if="(isGlidera || isCoinbase) == 'sell'">From</span>
|
||||
<div class="wallet" ng-if="wallet">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}" class="bg"/>
|
||||
|
@ -74,14 +75,14 @@
|
|||
</div>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet && !isGlidera" ng-click="showDescriptionPopup()">
|
||||
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet && !(isGlidera || isCoinbase)" ng-click="showDescriptionPopup()">
|
||||
<span class="label" translate>Add Memo</span>
|
||||
<span class="item-note m10l">
|
||||
{{description}}
|
||||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet && !isGlidera">
|
||||
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet && !(isGlidera || isCoinbase)">
|
||||
<span class="label">{{'Fee' | translate}}: {{feeLevel | translate}}</span>
|
||||
<span class="item-note">
|
||||
{{fee || '...'}}
|
||||
|
@ -153,6 +154,10 @@
|
|||
<span ng-show="isGlidera == 'buy'">A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business day</span>
|
||||
<span ng-show="isGlidera == 'sell'">A transfer has been initiated to your bank account. Should arrive in 4-6 business days</span>
|
||||
</div>
|
||||
<div ng-show="isCoinbase" class="glidera-success">
|
||||
<span ng-show="isCoinbase == 'buy'">Bitcoin purchase completed. Coinbase has queued the transfer to your selected Copay wallet</span>
|
||||
<span ng-show="isCoinbase == 'sell'">Sale initiated</span>
|
||||
</div>
|
||||
</slide-to-accept-success>
|
||||
|
||||
<wallet-selector
|
||||
|
|
Loading…
Reference in New Issue