diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index c0f27133c..45ea48083 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -517,9 +517,11 @@ namespace BTCPayServer.Controllers var paymentMethodDetails = paymentMethod.GetPaymentMethodDetails(); if (!paymentMethodDetails.Activated) { - await _InvoiceRepository.ActivateInvoicePaymentMethod(_EventAggregator, _NetworkProvider, - _paymentMethodHandlerDictionary, store, invoice, paymentMethod.GetId()); - return await GetInvoiceModel(invoiceId, paymentMethodId, lang); + if (await _InvoiceRepository.ActivateInvoicePaymentMethod(_EventAggregator, _NetworkProvider, + _paymentMethodHandlerDictionary, store, invoice, paymentMethod.GetId())) + { + return await GetInvoiceModel(invoiceId, paymentMethodId, lang); + } } var dto = invoice.EntityToDTO(); var storeBlob = store.GetStoreBlob(); diff --git a/BTCPayServer/Services/Invoices/InvoiceExtensions.cs b/BTCPayServer/Services/Invoices/InvoiceExtensions.cs index 280387d63..39e1037e8 100644 --- a/BTCPayServer/Services/Invoices/InvoiceExtensions.cs +++ b/BTCPayServer/Services/Invoices/InvoiceExtensions.cs @@ -11,10 +11,11 @@ namespace BTCPayServer.Services.Invoices public static class InvoiceExtensions { - public static async Task ActivateInvoicePaymentMethod(this InvoiceRepository invoiceRepository, + public static async Task ActivateInvoicePaymentMethod(this InvoiceRepository invoiceRepository, EventAggregator eventAggregator, BTCPayNetworkProvider btcPayNetworkProvider, PaymentMethodHandlerDictionary paymentMethodHandlerDictionary, StoreData store,InvoiceEntity invoice, PaymentMethodId paymentMethodId) { + bool success = false; var eligibleMethodToActivate = invoice.GetPaymentMethod(paymentMethodId); if (!eligibleMethodToActivate.GetPaymentMethodDetails().Activated) { @@ -34,6 +35,8 @@ namespace BTCPayServer.Services.Invoices eligibleMethodToActivate.SetPaymentMethodDetails(newDetails); await invoiceRepository.UpdateInvoicePaymentMethod(invoice.Id, eligibleMethodToActivate); eventAggregator.Publish(new InvoicePaymentMethodActivated(paymentMethodId, invoice)); + eventAggregator.Publish(new InvoiceNeedUpdateEvent(invoice.Id)); + success = true; } catch (PaymentMethodUnavailableException ex) { @@ -45,8 +48,8 @@ namespace BTCPayServer.Services.Invoices } await invoiceRepository.AddInvoiceLogs(invoice.Id, logs); - eventAggregator.Publish(new InvoiceNeedUpdateEvent(invoice.Id)); } + return success; } } }