Purchase throught from Coinbase: Force buyInfo request until get transaction id

This commit is contained in:
Gustavo Maximiliano Cortez 2017-08-16 11:12:56 -03:00
commit 23cc08574e
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF

View file

@ -209,21 +209,31 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
});
};
var _getBuyOrder = function() {
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;
if (tx && tx.id) {
processBuyTx(tx);
} else {
$timeout(function() {
_getBuyOrder();
}, 5000);
}
});
}
$timeout(function() {
var tx = b.data ? b.data.transaction : null;
if (tx) {
if (tx && tx.id) {
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);
});
_getBuyOrder();
}
}, 8000);
});