mirror of https://github.com/BTCPrivate/copay.git
get updated buy order if it does not initally include a transaction
This commit is contained in:
parent
211c489fbf
commit
34adb9ebe5
|
@ -166,14 +166,14 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
||||||
showError(err);
|
showError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tx = b.data ? b.data.transaction : null;
|
|
||||||
|
var processBuyTx = function (tx) {
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||||
showError('Transaction not found');
|
showError('Transaction not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
coinbaseService.getTransaction(accessToken, accountId, tx.id, function(err, updatedTx) {
|
coinbaseService.getTransaction(accessToken, accountId, tx.id, function(err, updatedTx) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||||
|
@ -196,7 +196,23 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 8000);
|
};
|
||||||
|
|
||||||
|
var tx = b.data ? b.data.transaction : null;
|
||||||
|
if (tx) {
|
||||||
|
processBuyTx(tx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
coinbaseService.getBuyOrder(accessToken, accountId, b.data.id, function (err, buyResp) {
|
||||||
|
if (err) {
|
||||||
|
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||||
|
showError(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var tx = buyResp.data ? buyResp.data.transaction : null;
|
||||||
|
processBuyTx(tx);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -302,6 +302,17 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.getBuyOrder = function(token, accountId, buyId, cb) {
|
||||||
|
if (!token) return cb('Invalid Token');
|
||||||
|
$http(_get('/accounts/' + accountId + '/buys/' + buyId, token)).then(function(data) {
|
||||||
|
$log.info('Coinbase Buy Info: SUCCESS');
|
||||||
|
return cb(null, data.data);
|
||||||
|
}, function(data) {
|
||||||
|
$log.error('Coinbase Buy Info: ERROR ' + data.statusText);
|
||||||
|
return cb(data.data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
root.getTransaction = function(token, accountId, transactionId, cb) {
|
root.getTransaction = function(token, accountId, transactionId, cb) {
|
||||||
if (!token) return cb('Invalid Token');
|
if (!token) return cb('Invalid Token');
|
||||||
$http(_get('/accounts/' + accountId + '/transactions/' + transactionId, token)).then(function(data) {
|
$http(_get('/accounts/' + accountId + '/transactions/' + transactionId, token)).then(function(data) {
|
||||||
|
|
Loading…
Reference in New Issue