mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Remove useless argument from GetInvoice
This commit is contained in:
@@ -1801,7 +1801,7 @@ ReceivedDate,StoreId,OrderId,InvoiceId,CreatedDate,ExpirationDate,MonitoringDate
|
|||||||
Assert.True(IsMapped(invoice, ctx));
|
Assert.True(IsMapped(invoice, ctx));
|
||||||
cashCow.SendToAddress(invoiceAddress, firstPayment);
|
cashCow.SendToAddress(invoiceAddress, firstPayment);
|
||||||
|
|
||||||
var invoiceEntity = repo.GetInvoice(null, invoice.Id, true).GetAwaiter().GetResult();
|
var invoiceEntity = repo.GetInvoice(invoice.Id, true).GetAwaiter().GetResult();
|
||||||
Assert.Single(invoiceEntity.HistoricalAddresses);
|
Assert.Single(invoiceEntity.HistoricalAddresses);
|
||||||
Assert.Null(invoiceEntity.HistoricalAddresses[0].UnAssigned);
|
Assert.Null(invoiceEntity.HistoricalAddresses[0].UnAssigned);
|
||||||
|
|
||||||
@@ -1819,7 +1819,7 @@ ReceivedDate,StoreId,OrderId,InvoiceId,CreatedDate,ExpirationDate,MonitoringDate
|
|||||||
Assert.True(IsMapped(invoice, ctx));
|
Assert.True(IsMapped(invoice, ctx));
|
||||||
Assert.True(IsMapped(localInvoice, ctx));
|
Assert.True(IsMapped(localInvoice, ctx));
|
||||||
|
|
||||||
invoiceEntity = repo.GetInvoice(null, invoice.Id, true).GetAwaiter().GetResult();
|
invoiceEntity = repo.GetInvoice(invoice.Id, true).GetAwaiter().GetResult();
|
||||||
var historical1 = invoiceEntity.HistoricalAddresses.FirstOrDefault(h => h.GetAddress() == invoice.BitcoinAddress);
|
var historical1 = invoiceEntity.HistoricalAddresses.FirstOrDefault(h => h.GetAddress() == invoice.BitcoinAddress);
|
||||||
Assert.NotNull(historical1.UnAssigned);
|
Assert.NotNull(historical1.UnAssigned);
|
||||||
var historical2 = invoiceEntity.HistoricalAddresses.FirstOrDefault(h => h.GetAddress() == localInvoice.BitcoinAddress);
|
var historical2 = invoiceEntity.HistoricalAddresses.FirstOrDefault(h => h.GetAddress() == localInvoice.BitcoinAddress);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
if (cryptoCode == null)
|
if (cryptoCode == null)
|
||||||
cryptoCode = "BTC";
|
cryptoCode = "BTC";
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
var network = _NetworkProvider.GetNetwork(cryptoCode);
|
var network = _NetworkProvider.GetNetwork(cryptoCode);
|
||||||
var paymentMethodId = new PaymentMethodId(cryptoCode, Payments.PaymentTypes.BTCLike);
|
var paymentMethodId = new PaymentMethodId(cryptoCode, Payments.PaymentTypes.BTCLike);
|
||||||
if (invoice == null || invoice.IsExpired() || network == null || !invoice.Support(paymentMethodId))
|
if (invoice == null || invoice.IsExpired() || network == null || !invoice.Support(paymentMethodId))
|
||||||
@@ -66,7 +66,7 @@ namespace BTCPayServer.Controllers
|
|||||||
[MediaTypeConstraint("application/bitcoin-payment")]
|
[MediaTypeConstraint("application/bitcoin-payment")]
|
||||||
public async Task<IActionResult> PostPayment(string invoiceId, string cryptoCode = null)
|
public async Task<IActionResult> PostPayment(string invoiceId, string cryptoCode = null)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
if (cryptoCode == null)
|
if (cryptoCode == null)
|
||||||
cryptoCode = "BTC";
|
cryptoCode = "BTC";
|
||||||
var network = _NetworkProvider.GetNetwork(cryptoCode);
|
var network = _NetworkProvider.GetNetwork(cryptoCode);
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
private async Task<PaymentModel> GetInvoiceModel(string invoiceId, string paymentMethodIdStr)
|
private async Task<PaymentModel> GetInvoiceModel(string invoiceId, string paymentMethodIdStr)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return null;
|
return null;
|
||||||
var store = await _StoreRepository.FindStore(invoice.StoreId);
|
var store = await _StoreRepository.FindStore(invoice.StoreId);
|
||||||
@@ -371,7 +371,7 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
if (!HttpContext.WebSockets.IsWebSocketRequest)
|
if (!HttpContext.WebSockets.IsWebSocketRequest)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
if (invoice == null || invoice.Status == "complete" || invoice.Status == "invalid" || invoice.Status == "expired")
|
if (invoice == null || invoice.Status == "complete" || invoice.Status == "invalid" || invoice.Status == "expired")
|
||||||
return NotFound();
|
return NotFound();
|
||||||
var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync();
|
var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync();
|
||||||
@@ -593,7 +593,7 @@ namespace BTCPayServer.Controllers
|
|||||||
[BitpayAPIConstraint(false)]
|
[BitpayAPIConstraint(false)]
|
||||||
public async Task<IActionResult> InvalidatePaidInvoice(string invoiceId)
|
public async Task<IActionResult> InvalidatePaidInvoice(string invoiceId)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
await _InvoiceRepository.UpdatePaidInvoiceToInvalid(invoiceId);
|
await _InvoiceRepository.UpdatePaidInvoiceToInvalid(invoiceId);
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ namespace BTCPayServer.HostedServices
|
|||||||
{
|
{
|
||||||
leases.Add(_EventAggregator.Subscribe<InvoiceEvent>(async e =>
|
leases.Add(_EventAggregator.Subscribe<InvoiceEvent>(async e =>
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, e.Invoice.Id);
|
var invoice = await _InvoiceRepository.GetInvoice(e.Invoice.Id);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return;
|
return;
|
||||||
List<Task> tasks = new List<Task>();
|
List<Task> tasks = new List<Task>();
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ namespace BTCPayServer.HostedServices
|
|||||||
|
|
||||||
private async Task Wait(string invoiceId)
|
private async Task Wait(string invoiceId)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var delay = invoice.ExpirationTime - DateTimeOffset.UtcNow;
|
var delay = invoice.ExpirationTime - DateTimeOffset.UtcNow;
|
||||||
@@ -283,7 +283,7 @@ namespace BTCPayServer.HostedServices
|
|||||||
loopCount++;
|
loopCount++;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, true);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId, true);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
break;
|
break;
|
||||||
var updateContext = new UpdateInvoiceContext(invoice);
|
var updateContext = new UpdateInvoiceContext(invoice);
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||||||
|
|
||||||
async Task<InvoiceEntity> UpdatePaymentStates(BTCPayWallet wallet, string invoiceId)
|
async Task<InvoiceEntity> UpdatePaymentStates(BTCPayWallet wallet, string invoiceId)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, false);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId, false);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return null;
|
return null;
|
||||||
List<PaymentEntity> updatedPaymentEntities = new List<PaymentEntity>();
|
List<PaymentEntity> updatedPaymentEntities = new List<PaymentEntity>();
|
||||||
@@ -315,7 +315,7 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||||||
var invoices = await _InvoiceRepository.GetPendingInvoices();
|
var invoices = await _InvoiceRepository.GetPendingInvoices();
|
||||||
foreach (var invoiceId in invoices)
|
foreach (var invoiceId in invoices)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId, true);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId, true);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
continue;
|
continue;
|
||||||
var alreadyAccounted = GetAllBitcoinPaymentData(invoice).Select(p => p.Outpoint).ToHashSet();
|
var alreadyAccounted = GetAllBitcoinPaymentData(invoice).Select(p => p.Outpoint).ToHashSet();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
{
|
{
|
||||||
if (Listening(invoiceId))
|
if (Listening(invoiceId))
|
||||||
return;
|
return;
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||||
foreach (var paymentMethod in invoice.GetPaymentMethods(_NetworkProvider)
|
foreach (var paymentMethod in invoice.GetPaymentMethods(_NetworkProvider)
|
||||||
.Where(c => c.GetId().PaymentType == PaymentTypes.LightningLike))
|
.Where(c => c.GetId().PaymentType == PaymentTypes.LightningLike))
|
||||||
{
|
{
|
||||||
@@ -194,7 +194,7 @@ namespace BTCPayServer.Payments.Lightning
|
|||||||
}, network.CryptoCode, accounted: true);
|
}, network.CryptoCode, accounted: true);
|
||||||
if (payment != null)
|
if (payment != null)
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, listenedInvoice.InvoiceId);
|
var invoice = await _InvoiceRepository.GetInvoice(listenedInvoice.InvoiceId);
|
||||||
if (invoice != null)
|
if (invoice != null)
|
||||||
_Aggregator.Publish(new InvoiceEvent(invoice.EntityToDTO(_NetworkProvider), 1002, "invoice_receivedPayment"));
|
_Aggregator.Publish(new InvoiceEvent(invoice.EntityToDTO(_NetworkProvider), 1002, "invoice_receivedPayment"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<InvoiceEntity> GetInvoice(string storeId, string id, bool inludeAddressData = false)
|
public async Task<InvoiceEntity> GetInvoice(string id, bool inludeAddressData = false)
|
||||||
{
|
{
|
||||||
using (var context = _ContextFactory.CreateContext())
|
using (var context = _ContextFactory.CreateContext())
|
||||||
{
|
{
|
||||||
@@ -353,9 +353,6 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
query = query.Include(o => o.HistoricalAddressInvoices).Include(o => o.AddressInvoices);
|
query = query.Include(o => o.HistoricalAddressInvoices).Include(o => o.AddressInvoices);
|
||||||
query = query.Where(i => i.Id == id);
|
query = query.Where(i => i.Id == id);
|
||||||
|
|
||||||
if (storeId != null)
|
|
||||||
query = query.Where(i => i.StoreDataId == storeId);
|
|
||||||
|
|
||||||
var invoice = await query.FirstOrDefaultAsync().ConfigureAwait(false);
|
var invoice = await query.FirstOrDefaultAsync().ConfigureAwait(false);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user