Merge pull request #6581 from cmgustavo/bug/coinbase-03

Purchase throught Coinbase: Force buyInfo request until get tran…
This commit is contained in:
Matias Alejo Garcia 2017-08-17 15:00:57 +02:00 committed by GitHub
commit 548c4e3465

View file

@ -209,21 +209,31 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
}); });
}; };
var _processBuyOrder = 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() {
_processBuyOrder();
}, 5000);
}
});
}
$timeout(function() { $timeout(function() {
var tx = b.data ? b.data.transaction : null; var tx = b.data ? b.data.transaction : null;
if (tx) { if (tx && tx.id) {
processBuyTx(tx); processBuyTx(tx);
} }
else { else {
coinbaseService.getBuyOrder(accessToken, accountId, b.data.id, function (err, buyResp) { _processBuyOrder();
if (err) {
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
showError(err);
return;
}
var tx = buyResp.data ? buyResp.data.transaction : null;
processBuyTx(tx);
});
} }
}, 8000); }, 8000);
}); });