From 2317a7df551f1d35bc23879d05202c9cfdf67cfd Mon Sep 17 00:00:00 2001 From: Kukks Date: Mon, 1 Aug 2022 11:16:26 +0200 Subject: [PATCH] Make InvoicePaymentSettled return correct afterExpiration value fixes #3966 --- BTCPayServer/Services/Invoices/InvoiceRepository.cs | 2 +- BTCPayServer/Services/Invoices/PaymentService.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index 73b99a52a..5e6e643fe 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -540,7 +540,7 @@ namespace BTCPayServer.Services.Invoices return invoice; } - private InvoiceEntity ToEntity(Data.InvoiceData invoice) + public InvoiceEntity ToEntity(Data.InvoiceData invoice) { var entity = invoice.GetBlob(_btcPayNetworkProvider); PaymentMethodDictionary paymentMethods = null; diff --git a/BTCPayServer/Services/Invoices/PaymentService.cs b/BTCPayServer/Services/Invoices/PaymentService.cs index b4aeaec04..9c24210cc 100644 --- a/BTCPayServer/Services/Invoices/PaymentService.cs +++ b/BTCPayServer/Services/Invoices/PaymentService.cs @@ -15,12 +15,16 @@ namespace BTCPayServer.Services.Invoices { private readonly ApplicationDbContextFactory _applicationDbContextFactory; private readonly BTCPayNetworkProvider _btcPayNetworkProvider; + private readonly InvoiceRepository _invoiceRepository; private readonly EventAggregator _eventAggregator; - public PaymentService(EventAggregator eventAggregator, ApplicationDbContextFactory applicationDbContextFactory, BTCPayNetworkProvider btcPayNetworkProvider) + public PaymentService(EventAggregator eventAggregator, + ApplicationDbContextFactory applicationDbContextFactory, + BTCPayNetworkProvider btcPayNetworkProvider, InvoiceRepository invoiceRepository) { _applicationDbContextFactory = applicationDbContextFactory; _btcPayNetworkProvider = btcPayNetworkProvider; + _invoiceRepository = invoiceRepository; _eventAggregator = eventAggregator; } /// @@ -109,7 +113,7 @@ namespace BTCPayServer.Services.Invoices foreach (KeyValuePair payment in paymentsDict) { var dbPayment = dbPayments[payment.Key]; - var invBlob = dbPayment.InvoiceData.GetBlob(_btcPayNetworkProvider); + var invBlob = _invoiceRepository.ToEntity(dbPayment.InvoiceData); var dbPaymentEntity = dbPayment.GetBlob(_btcPayNetworkProvider); var wasConfirmed = dbPayment.GetBlob(_btcPayNetworkProvider).GetCryptoPaymentData() .PaymentConfirmed(dbPaymentEntity, invBlob.SpeedPolicy);