better handle case when BTC is not supported by a store

This commit is contained in:
nicolas.dorier
2018-01-12 16:30:34 +09:00
parent 58194cb060
commit 39fb8dbb6a
4 changed files with 56 additions and 18 deletions

View File

@@ -123,11 +123,22 @@ namespace BTCPayServer.Controllers
if (invoice == null)
return null;
var store = await _StoreRepository.FindStore(invoice.StoreId);
bool isDefaultCrypto = false;
if (cryptoCode == null)
{
cryptoCode = store.GetDefaultCrypto();
isDefaultCrypto = true;
}
var network = _NetworkProvider.GetNetwork(cryptoCode);
if (invoice == null || network == null || !invoice.Support(network))
if (invoice == null || network == null)
return null;
if(!invoice.Support(network))
{
if(!isDefaultCrypto)
return null;
network = invoice.GetCryptoData(_NetworkProvider).First().Value.Network;
}
var cryptoData = invoice.GetCryptoData(network, _NetworkProvider);
var dto = invoice.EntityToDTO(_NetworkProvider);