diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 7247d3cb7..ad9f81f54 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -72,6 +72,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ } $scope.coinbasePaymentMethods = []; + $scope.coinbaseSelectedPaymentMethodId = { value : null }; coinbaseService.getPaymentMethods(data.accessToken, function(err, p) { lodash.each(p.data, function(pm) { if ($scope.isCoinbase == 'sell') { @@ -79,14 +80,14 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.coinbasePaymentMethods.push(pm); } if (pm.allow_sell && pm.primary_sell) { - $scope.coinbaseSelectedPaymentMethod = pm; + $scope.coinbaseSelectedPaymentMethodId.value = pm.id; } } else { if (pm.allow_buy) { $scope.coinbasePaymentMethods.push(pm); } if (pm.allow_buy && pm.primary_buy) { - $scope.coinbaseSelectedPaymentMethod = pm; + $scope.coinbaseSelectedPaymentMethodId.value = pm.id; } } }); @@ -398,7 +399,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ glideraAccessToken: $scope.glideraAccessToken }); } else if ($scope.isCoinbase) { - if (lodash.isEmpty($scope.coinbaseSelectedPaymentMethod)) { + if (lodash.isEmpty($scope.coinbaseSelectedPaymentMethodId.value)) { popupService.showAlert(gettextCatalog.getString('Error'), 'No Payment Method Selected'); return; } @@ -407,12 +408,17 @@ angular.module('copayApp.controllers').controller('amountController', function($ return; } var amountUSD = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount)); + if (amountUSD < 1) { + popupService.showAlert(gettextCatalog.getString('Error'), 'Amount must be at least 1.00 USD'); + return; + } + var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount; $state.transitionTo('tabs.buyandsell.coinbase.confirm', { toAmount: (amount * unitToSatoshi).toFixed(0), toAddress: $scope.toAddress, isCoinbase: $scope.isCoinbase, - coinbasePaymentMethodId: $scope.coinbaseSelectedPaymentMethod.id, + coinbasePaymentMethodId: $scope.coinbaseSelectedPaymentMethodId.value, coinbaseAmount: amountUSD, coinbaseAmountCurrency: 'USD' }); diff --git a/src/js/controllers/coinbase.js b/src/js/controllers/coinbase.js index c23bd3faf..e1bc21e17 100644 --- a/src/js/controllers/coinbase.js +++ b/src/js/controllers/coinbase.js @@ -26,10 +26,8 @@ angular.module('copayApp.controllers').controller('coinbaseController', function $scope.updateTransactions = function() { $log.debug('Getting transactions...'); - coinbaseService.getPendingTransactions($scope.accessToken, $scope.accountId, function(err, txs) { - $scope.pendingTransactions = txs; - }); - + $scope.pendingTransactions = { data: {} }; + coinbaseService.getPendingTransactions($scope.pendingTransactions); }; this.openAuthenticateWindow = function() { diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index a8a9e5a77..66416f1a7 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -159,7 +159,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( if ($scope.paypro) _paymentTimeControl($scope.paypro.expires); displayValues(); - if ($scope.wallets.length > 1) $scope.showWalletSelector(); + if ($scope.wallets.length > 1 && $scope.isCoinbase != 'buy') $scope.showWalletSelector(); else setWallet($scope.wallets[0]); $timeout(function() { $scope.$apply(); @@ -175,6 +175,8 @@ angular.module('copayApp.controllers').controller('confirmController', function( $scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.cardAmountUSD) + ' USD'; } else if ($scope.giftCardAmountUSD) { $scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.giftCardAmountUSD) + ' USD'; + } else if ($scope.coinbaseAmount) { + $scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.coinbaseAmount) + ' ' + $scope.coinbaseAmountCurrency; } else { txFormatService.formatAlternativeStr(toAmount, function(v) { $scope.alternativeAmountStr = v; @@ -197,6 +199,10 @@ angular.module('copayApp.controllers').controller('confirmController', function( coinbaseService.sellPrice(data.accessToken, $scope.coinbaseAmountCurrency, function(err, sell) { $scope.coinbaseSellPrice = sell.data; }); + coinbaseService.getPaymentMethod(data.accessToken, $scope.coinbasePaymentMethodId, function(err, data) { + if (err) $log.error(err); + $scope.coinbasePaymentMethodInfo = data.data; + }); }); } }; @@ -567,30 +573,45 @@ angular.module('copayApp.controllers').controller('confirmController', function( var accountId = res.accountId; coinbaseService.buyCommit(token, accountId, $scope.coinbaseBuyRequest.id, function(err, b) { if (err) { - $log.error(err); + ongoingProcess.set('buyingBitcoin', false, onSendStatusChange); + popupService.showAlert(gettextCatalog.getString('Error'), 'Could not complete purchase'); return; } var tx = b.data.transaction; - if (!tx) return; + if (!tx) { + ongoingProcess.set('buyingBitcoin', false, onSendStatusChange); + popupService.showAlert(gettextCatalog.getString('Error'), 'Transaction not found'); + return; + } - coinbaseService.getTransaction(token, accountId, tx.id, function(err, updatedTx) { - if (err) $log.debug(err); - walletService.getAddress($scope.wallet, false, function(err, walletAddr) { + $timeout(function() { + coinbaseService.getTransaction(token, accountId, tx.id, function(err, updatedTx) { if (err) { + ongoingProcess.set('buyingBitcoin', false, onSendStatusChange); + popupService.showAlert(gettextCatalog.getString('Error'), 'Transaction error'); return; } - updatedTx.data['toAddr'] = walletAddr; - coinbaseService.savePendingTransaction(updatedTx.data, {}, function(err) { - if (err) $log.debug(err); - if (updatedTx.data.status == 'completed') { - coinbaseSendToCopay(token, accountId, updatedTx.data, onSendStatusChange); - } else { + walletService.getAddress($scope.wallet, false, function(err, walletAddr) { + if (err) { + ongoingProcess.set('buyingBitcoin', false, onSendStatusChange); + popupService.showAlert(gettextCatalog.getString('Error'), err); + return; + } + updatedTx.data['toAddr'] = walletAddr; + updatedTx.data['status'] = 'pending'; // Forcing "pending" status to process later + + $log.debug('Saving transaction to process later...'); + coinbaseService.savePendingTransaction(updatedTx.data, {}, function(err) { + if (err) $log.debug(err); ongoingProcess.set('buyingBitcoin', false, onSendStatusChange); $scope.coinbaseBuySuccess = updatedTx.data; - } + $timeout(function() { + $scope.$apply(); + }); + }); }); }); - }); + }, 8000); }); }); } @@ -610,7 +631,6 @@ angular.module('copayApp.controllers').controller('confirmController', function( popupService.showConfirm(null, message, okText, cancelText, function(ok) { if (!ok) { - $scope.sendStatus = ''; $timeout(function() { $scope.$apply(); }); @@ -618,56 +638,13 @@ angular.module('copayApp.controllers').controller('confirmController', function( } // SIMULATE publishAndSign //$log.warn('Simulating publishAndSign...'); - publishAndSign(wallet, txp, onSendStatusChange); - - $timeout(function() { - - coinbaseService.init(function(err, res) { - if (err) { - $log.error(err); - return; - } - var token = res.accessToken; - var accountId = res.accountId; - - coinbaseService.getAddressTransactions(token, accountId, $scope.toAddress, function(err, ctxs) { - if (err) { - ongoingProcess.clear(); - $log.debug(err); - return; - } - var coinbaseTransactions = ctxs.data; - var txFound = false; - var ctx; - for(var i = 0; i < coinbaseTransactions.length; i++) { - ctx = coinbaseTransactions[i]; - if (ctx.type == 'send' && ctx.from) { - txFound = true; - if (ctx.status == 'completed') { - coinbaseSellRequest(token, accountId, ctx, onSendStatusChange); - } else { - $log.debug('Saving transaction to process later'); - ctx['price_sensitivity'] = $scope.selectedPriceSensitivity.data; - ctx['sell_price_amount'] = $scope.coinbaseSellPrice ? $scope.coinbaseSellPrice.amount : ''; - ctx['sell_price_currency'] = $scope.coinbaseSellPrice ? $scope.coinbaseSellPrice.currency : 'USD'; - ctx['description'] = $window.appConfig.nameCase + ' Wallet: ' + $scope.wallet.name; - $scope.coinbaseSendInfo = ctx; - coinbaseService.savePendingTransaction(ctx, null, function(err) { - ongoingProcess.set('sellingBitcoin', false, onSendStatusChange); - if (err) $log.debug(err); - }); - } - } - } - if (!txFound) { - // Transaction sent, but can not verify it on Coinbase.com - // TODO: improve error message - ongoingProcess.clear(); - return setSendError('Transaction not found. Please, verify if transaction exists on Coinbase.com'); - } - }); - }); - }, 5000); + $log.debug('Plublish and Sign...'); + publishAndSign(wallet, txp, function() {}, function(err) { + if (err) return setSendError(err); + $log.debug('Finished publish and sign. Trying to sell...'); + var count = 0; + checkTransaction(count, txp, onSendStatusChange); + }); }); }); } @@ -725,9 +702,9 @@ angular.module('copayApp.controllers').controller('confirmController', function( ( processName === 'broadcastingTx' || ((processName === 'signingTx') && $scope.wallet.m > 1) || - (processName == 'sendingTx' && !$scope.wallet.canSign() && !$scope.wallet.isPrivKeyExternal()) || + (processName == 'sendingTx' && !$scope.wallet.canSign() && !$scope.wallet.isPrivKeyExternal()) || (processName == 'buyingBitcoin') || - (processName == 'sellingBitcoin' && ($scope.coinbaseSellRequest || $scope.coinbaseSendInfo)) + (processName == 'sellingBitcoin') ) && !isOn) { $scope.sendStatus = 'success'; $timeout(function() { @@ -960,18 +937,26 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); }; - function publishAndSign(wallet, txp, onSendStatusChange) { + function publishAndSign(wallet, txp, onSendStatusChange, cb) { if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { $log.info('No signing proposal: No private key'); - return walletService.onlyPublish(wallet, txp, function(err) { - if (err) setSendError(err); + walletService.onlyPublish(wallet, txp, function(err) { + if (err) { + if (cb) return cb(err); + else return setSendError(err); + } + if (cb) return cb(); + else return; }, onSendStatusChange); } walletService.publishAndSign(wallet, txp, function(err, txp) { - if (err) return setSendError(err); + if (err) { + if (cb) return cb(err); + else return setSendError(err); + } var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName; var fromAmazon = previousView.match(/tabs.giftcards.amazon/) ? true : false; @@ -990,8 +975,72 @@ angular.module('copayApp.controllers').controller('confirmController', function( ongoingProcess.set('creatingGiftCard', true); debounceCreate(count, dataSrc, onSendStatusChange); } + if (cb) return cb(); }, onSendStatusChange); - } + }; + + var checkTransaction = lodash.throttle(function(count, txp, onSendStatusChange) { + $log.warn('Check if transaction has been received by Coinbase. Try ' + count + '/5'); + coinbaseService.init(function(err, res) { + if (err) { + ongoingProcess.set('sellingBitcoin', false, onSendStatusChange); + $log.error(err); + checkTransaction(count, txp, onSendStatusChange); + return; + } + var token = res.accessToken; + var accountId = res.accountId; + + coinbaseService.getTransactions(token, accountId, function(err, ctxs) { + if (err) { + ongoingProcess.set('sellingBitcoin', false, onSendStatusChange); + $log.debug(err); + checkTransaction(count, txp, onSendStatusChange); + return; + } + + // TX amount in BTC + var satToBtc = 1 / 100000000; + var amountBTC = (txp.amount * satToBtc).toFixed(8); + + var coinbaseTransactions = ctxs.data; + var txFound = false; + var ctx; + for(var i = 0; i < coinbaseTransactions.length; i++) { + ctx = coinbaseTransactions[i]; + if (ctx.type == 'send' && ctx.from && ctx.amount.amount == amountBTC ) { + $log.warn('Transaction found!', ctx); + txFound = true; + $log.debug('Saving transaction to process later...'); + ctx['payment_method'] = $scope.coinbasePaymentMethodId; + ctx['status'] = 'pending'; // Forcing "pending" status to process later + ctx['price_sensitivity'] = $scope.selectedPriceSensitivity.data; + ctx['sell_price_amount'] = $scope.coinbaseSellPrice ? $scope.coinbaseSellPrice.amount : ''; + ctx['sell_price_currency'] = $scope.coinbaseSellPrice ? $scope.coinbaseSellPrice.currency : 'USD'; + ctx['description'] = $window.appConfig.nameCase + ' Wallet: ' + $scope.wallet.name; + coinbaseService.savePendingTransaction(ctx, null, function(err) { + ongoingProcess.set('sellingBitcoin', false, onSendStatusChange); + if (err) $log.debug(err); + $scope.coinbaseSendInfo = ctx; + $timeout(function() { + $scope.$apply(); + }); + }); + return; + } + } + if (!txFound) { + // Transaction sent, but could not be verified by Coinbase.com + $log.warn('Transaction not found in Coinbase.'); + if (count < 5) { + checkTransaction(count + 1, txp, onSendStatusChange); + } + } + }); + }); + }, 8000, { + 'leading': true + }); var debounceCreate = lodash.throttle(function(count, dataSrc) { debounceCreateGiftCard(count, dataSrc); @@ -1067,12 +1116,25 @@ angular.module('copayApp.controllers').controller('confirmController', function( }; coinbaseService.init(function(err, res) { if (err) { + $scope.showWallets = null; $log.error(err); + popupService.showAlert(gettextCatalog.getString('Error'), 'Could not connect to Coinbase', function() { + $ionicHistory.goBack(); + }); return; } + coinbaseService.getPaymentMethod(res.accessToken, paymentMethodId, function(err, data) { + if (err) $log.error(err); + $scope.coinbasePaymentMethodInfo = data.data; + }); + coinbaseService.buyRequest(res.accessToken, res.accountId, dataSrc, function(err, data) { if (err) { + $scope.showWallets = null; $log.error(err); + popupService.showAlert(gettextCatalog.getString('Error'), 'Could not create a buy request', function() { + $ionicHistory.goBack(); + }); return; } $scope.coinbaseBuyRequest = data.data; @@ -1080,48 +1142,4 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); }; - var coinbaseSellRequest = function(accessToken, accountId, ctx, onSendStatusChange) { - var dataSrc = ctx.amount; - dataSrc['payment_method'] = $scope.coinbasePaymentMethodId || null; - dataSrc['commit'] = true; - - coinbaseService.sellRequest(accessToken, accountId, dataSrc, function(err, data) { - if (err) { - ongoingProcess.clear(); - $log.error(err); - return; - } - $scope.coinbaseSellRequest = data.data; - coinbaseService.savePendingTransaction($scope.coinbaseSellRequest, null, function(err) { - ongoingProcess.set('sellingBitcoin', false, onSendStatusChange); - if (err) $log.debug(err); - }); - }); - }; - - var coinbaseSendToCopay = function(token, accountId, tx, onSendStatusChange) { - var data = { - to: tx.toAddr, - amount: tx.amount.amount, - currency: tx.amount.currency, - description: 'Copay Wallet: ' + $scope.wallet.name - }; - coinbaseService.sendTo(token, accountId, data, function(err, res) { - if (err) { - return; - } - $scope.coinbaseReceiveInfo = res.data; - if (!res.data.id) return; - coinbaseService.getTransaction(token, accountId, res.data.id, function(err, sendTx) { - coinbaseService.savePendingTransaction(tx, { - remove: true - }, function(err) { - coinbaseService.savePendingTransaction(sendTx.data, {}, function(err) { - ongoingProcess.set('buyingBitcoin', false, onSendStatusChange); - // TODO - }); - }); - }); - }); - }; }); diff --git a/src/js/services/coinbaseService.js b/src/js/services/coinbaseService.js index 248dc0e52..f0267eb1d 100644 --- a/src/js/services/coinbaseService.js +++ b/src/js/services/coinbaseService.js @@ -476,74 +476,90 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $ }); }; - root.getPendingTransactions = function(accessToken, accountId, cb) { - var coinbasePendingTransactions; - storageService.getCoinbaseTxs(credentials.NETWORK, function(err, txs) { - txs = txs ? JSON.parse(txs) : {}; - coinbasePendingTransactions = lodash.isEmpty(txs) ? null : txs; - lodash.forEach(coinbasePendingTransactions, function(dataFromStorage, txId) { - if ((dataFromStorage.type == 'sell' && dataFromStorage.status == 'completed') || - (dataFromStorage.type == 'buy' && dataFromStorage.status == 'completed') || - dataFromStorage.status == 'error' || - (dataFromStorage.type == 'send' && dataFromStorage.status == 'completed')) - return cb(null, coinbasePendingTransactions); - root.getTransaction(accessToken, accountId, txId, function(err, tx) { - if (err || lodash.isEmpty(tx)) { - _savePendingTransaction(dataFromStorage, { - status: 'error', - error: err - }, function(err) { - if (err) $log.debug(err); - }); - return cb(err); - } - _updateCoinbasePendingTransactions(dataFromStorage, tx.data); - coinbasePendingTransactions[txId] = dataFromStorage; - if (tx.data.type == 'send' && tx.data.status == 'completed' && tx.data.from) { - root.sellPrice(accessToken, dataFromStorage.sell_price_currency, function(err, s) { - if (err) { - _savePendingTransaction(dataFromStorage, { - status: 'error', - error: err - }, function(err) { - if (err) $log.debug(err); - }); - return cb(err); - } - var newSellPrice = s.data.amount; - var variance = Math.abs((newSellPrice - dataFromStorage.sell_price_amount) / dataFromStorage.sell_price_amount * 100); - if (variance < dataFromStorage.price_sensitivity.value) { - _sellPending(tx.data, accessToken, accountId); - } else { - var error = { - errors: [{ - message: 'Price falls over the selected percentage' - }] - }; - _savePendingTransaction(dataFromStorage, { - status: 'error', - error: error - }, function(err) { - if (err) $log.debug(err); - }); - } - }); - } else if (tx.data.type == 'buy' && tx.data.status == 'completed' && tx.data.buy) { - _sendToCopay(dataFromStorage, accessToken, accountId); - } else { - _savePendingTransaction(dataFromStorage, {}, function(err) { - if (err) $log.debug(err); - }); - } - return cb(null, coinbasePendingTransactions); + root.getPendingTransactions = function(coinbasePendingTransactions) { + root.init(function(err, data) { + var accessToken = data.accessToken; + var accountId = data.accountId; + storageService.getCoinbaseTxs(credentials.NETWORK, function(err, txs) { + txs = txs ? JSON.parse(txs) : {}; + console.log('[coinbaseService.js:484] getCoinbaseTxs',err, txs); //TODO + coinbasePendingTransactions.data = lodash.isEmpty(txs) ? null : txs; + + lodash.forEach(coinbasePendingTransactions.data, function(dataFromStorage, txId) { + if ((dataFromStorage.type == 'sell' && dataFromStorage.status == 'completed') || + (dataFromStorage.type == 'buy' && dataFromStorage.status == 'completed') || + dataFromStorage.status == 'error' || + (dataFromStorage.type == 'send' && dataFromStorage.status == 'completed')) + return; + root.getTransaction(accessToken, accountId, txId, function(err, tx) { + console.log('[coinbaseService.js:494] getTransaction to UPDATE from Coinbase',err, tx); //TODO + if (err || lodash.isEmpty(tx) || (tx.data && tx.data.error)) { + _savePendingTransaction(dataFromStorage, { + status: 'error', + error: (tx.data && tx.data.error) ? tx.data.error : err + }, function(err) { + if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); + }); + return; + } + _updateCoinbasePendingTransactions(dataFromStorage, tx.data); + coinbasePendingTransactions.data[txId] = dataFromStorage; + if (tx.data.type == 'send' && tx.data.status == 'completed' && tx.data.from) { + root.sellPrice(accessToken, dataFromStorage.sell_price_currency, function(err, s) { + if (err) { + _savePendingTransaction(dataFromStorage, { + status: 'error', + error: err + }, function(err) { + if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); + }); + return; + } + var newSellPrice = s.data.amount; + var variance = Math.abs((newSellPrice - dataFromStorage.sell_price_amount) / dataFromStorage.sell_price_amount * 100); + if (variance < dataFromStorage.price_sensitivity.value) { + _sellPending(dataFromStorage, accessToken, accountId, coinbasePendingTransactions); + } else { + var error = { + errors: [{ + message: 'Price falls over the selected percentage' + }] + }; + _savePendingTransaction(dataFromStorage, { + status: 'error', + error: error + }, function(err) { + if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); + }); + } + }); + } else if (tx.data.type == 'buy' && tx.data.status == 'completed' && tx.data.buy) { + _sendToWallet(dataFromStorage, accessToken, accountId, coinbasePendingTransactions); + } else { + _savePendingTransaction(dataFromStorage, {}, function(err) { + if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); + }); + } + }); }); }); }); }; - var _sellPending = function(tx, accessToken, accountId) { - if (!tx) return; + var _updateTxs = function(coinbasePendingTransactions) { + storageService.getCoinbaseTxs(credentials.NETWORK, function(err, txs) { + txs = txs ? JSON.parse(txs) : {}; + coinbasePendingTransactions.data = lodash.isEmpty(txs) ? null : txs; + }); + }; + + var _sellPending = function(tx, accessToken, accountId, coinbasePendingTransactions) { var data = tx.amount; + data['payment_method'] = tx.payment_method || null; data['commit'] = true; root.sellRequest(accessToken, accountId, data, function(err, res) { if (err) { @@ -552,14 +568,16 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $ error: err }, function(err) { if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); }); } else { - if (!res.data.transaction) { + if (res.data && !res.data.transaction) { _savePendingTransaction(tx, { status: 'error', error: err }, function(err) { if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); }); return; } @@ -569,6 +587,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $ root.getTransaction(accessToken, accountId, res.data.transaction.id, function(err, updatedTx) { _savePendingTransaction(updatedTx.data, {}, function(err) { if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); }); }); }); @@ -576,38 +595,43 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $ }); }; - var _sendToCopay = function(tx, accessToken, accountId) { + var _sendToWallet = function(tx, accessToken, accountId, coinbasePendingTransactions) { if (!tx) return; var data = { to: tx.toAddr, amount: tx.amount.amount, currency: tx.amount.currency, - description: 'To Copay Wallet' + description: 'To Wallet' }; root.sendTo(accessToken, accountId, data, function(err, res) { +console.log('[coinbaseService.js:591] SEND TO COPAY',err, res); //TODO if (err) { _savePendingTransaction(tx, { status: 'error', error: err }, function(err) { if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); }); } else { - if (!res.data.id) { + if (res.data && !res.data.id) { _savePendingTransaction(tx, { status: 'error', error: err }, function(err) { if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); }); return; } root.getTransaction(accessToken, accountId, res.data.id, function(err, sendTx) { +console.log('[coinbaseService.js:633] GET UPDATED TX', err, sendTx); //TODO _savePendingTransaction(tx, { remove: true }, function(err) { _savePendingTransaction(sendTx.data, {}, function(err) { - // TODO + if (err) $log.debug(err); + _updateTxs(coinbasePendingTransactions); }); }); }); diff --git a/www/views/amount.html b/www/views/amount.html index 867258a99..023e2125e 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -74,7 +74,7 @@ Payment Method Deposit into - diff --git a/www/views/coinbase.html b/www/views/coinbase.html index f531b2e07..a8cae44a4 100644 --- a/www/views/coinbase.html +++ b/www/views/coinbase.html @@ -86,8 +86,8 @@ Activity diff --git a/www/views/confirm.html b/www/views/confirm.html index c2c2a9471..2010d13c8 100644 --- a/www/views/confirm.html +++ b/www/views/confirm.html @@ -46,19 +46,18 @@ will be sent to your Coinbase account, and sold when Coinbase accepts the transaction (usually one hour). -
-
- Estimated sale value: - - {{coinbaseSellPrice.amount * coinbaseAmountBTC | currency : 'USD ' : 2}} - -
- Still sell if price fall until: - - {{(coinbaseSellPrice.amount - (selectedPriceSensitivity.data.value / 100) * - coinbaseSellPrice.amount) * coinbaseAmountBTC | currency : 'USD ' : 2}} - -
+ Estimated sale value: + {{coinbaseSellPrice.amount * coinbaseAmountBTC | currency : 'USD ' : 2}} + + Still sell if price fall until: + {{(coinbaseSellPrice.amount - (selectedPriceSensitivity.data.value / 100) * + coinbaseSellPrice.amount) * coinbaseAmountBTC | currency : 'USD ' : 2}} + + +
+ Payment Method + Deposit into + {{coinbasePaymentMethodInfo.name}}
To @@ -147,15 +146,19 @@
-
-
- Subtotal: {{coinbaseBuyRequest.subtotal.amount}} {{coinbaseBuyRequest.subtotal.currency}} +
+
+ Subtotal + {{coinbaseBuyRequest.subtotal.amount}} + {{coinbaseBuyRequest.subtotal.currency}}
-
- Total: {{coinbaseBuyRequest.total.amount}} {{coinbaseBuyRequest.total.currency}} +
+ Total + {{coinbaseBuyRequest.total.amount}} {{coinbaseBuyRequest.total.currency}}
-
- Payout at: {{coinbaseBuyRequest.payout_at | amCalendar}} +
+ Payout at + {{coinbaseBuyRequest.payout_at | amCalendar}}
@@ -191,7 +194,6 @@ slide-success-hide-on-confirm="true"> Bought Funds sent to Coinbase Account - Sale initiated
Payment Sent Proposal Created @@ -204,18 +206,12 @@
- Bitcoin purchase completed. Coinbase has queued the transfer to your selected Copay wallet - - - Buy confirmed. Funds will be send soon to your selected wallet + Bitcoin purchase completed. Coinbase has queued the transfer to your selected wallet - The transaction is not yet confirmed, and will show as "Processing" in your Activity. The bitcoin sale will be completed automatically once it is confirmed by Coinbase. - - - A transfer has been initiated to your bank account and should arrive at {{coinbaseSellRequest.payout_at | amCalendar}}. + The transaction is not yet confirmed, and will show as "Pending" in your Activity. The bitcoin sale will be completed automatically once it is confirmed by Coinbase.
diff --git a/www/views/modals/coinbase-tx-details.html b/www/views/modals/coinbase-tx-details.html index 1ff0969ef..6d6dce8b4 100644 --- a/www/views/modals/coinbase-tx-details.html +++ b/www/views/modals/coinbase-tx-details.html @@ -40,11 +40,9 @@
-
-
    -
  • -
-
+
    +
  • +