mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Fix infinite loop happening if payment method unavailable with on invoices with lazy activation (#2914)
This commit is contained in:
@@ -517,9 +517,11 @@ namespace BTCPayServer.Controllers
|
|||||||
var paymentMethodDetails = paymentMethod.GetPaymentMethodDetails();
|
var paymentMethodDetails = paymentMethod.GetPaymentMethodDetails();
|
||||||
if (!paymentMethodDetails.Activated)
|
if (!paymentMethodDetails.Activated)
|
||||||
{
|
{
|
||||||
await _InvoiceRepository.ActivateInvoicePaymentMethod(_EventAggregator, _NetworkProvider,
|
if (await _InvoiceRepository.ActivateInvoicePaymentMethod(_EventAggregator, _NetworkProvider,
|
||||||
_paymentMethodHandlerDictionary, store, invoice, paymentMethod.GetId());
|
_paymentMethodHandlerDictionary, store, invoice, paymentMethod.GetId()))
|
||||||
return await GetInvoiceModel(invoiceId, paymentMethodId, lang);
|
{
|
||||||
|
return await GetInvoiceModel(invoiceId, paymentMethodId, lang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var dto = invoice.EntityToDTO();
|
var dto = invoice.EntityToDTO();
|
||||||
var storeBlob = store.GetStoreBlob();
|
var storeBlob = store.GetStoreBlob();
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
public static class InvoiceExtensions
|
public static class InvoiceExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
public static async Task ActivateInvoicePaymentMethod(this InvoiceRepository invoiceRepository,
|
public static async Task<bool> ActivateInvoicePaymentMethod(this InvoiceRepository invoiceRepository,
|
||||||
EventAggregator eventAggregator, BTCPayNetworkProvider btcPayNetworkProvider, PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
|
EventAggregator eventAggregator, BTCPayNetworkProvider btcPayNetworkProvider, PaymentMethodHandlerDictionary paymentMethodHandlerDictionary,
|
||||||
StoreData store,InvoiceEntity invoice, PaymentMethodId paymentMethodId)
|
StoreData store,InvoiceEntity invoice, PaymentMethodId paymentMethodId)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
var eligibleMethodToActivate = invoice.GetPaymentMethod(paymentMethodId);
|
var eligibleMethodToActivate = invoice.GetPaymentMethod(paymentMethodId);
|
||||||
if (!eligibleMethodToActivate.GetPaymentMethodDetails().Activated)
|
if (!eligibleMethodToActivate.GetPaymentMethodDetails().Activated)
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,8 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
eligibleMethodToActivate.SetPaymentMethodDetails(newDetails);
|
eligibleMethodToActivate.SetPaymentMethodDetails(newDetails);
|
||||||
await invoiceRepository.UpdateInvoicePaymentMethod(invoice.Id, eligibleMethodToActivate);
|
await invoiceRepository.UpdateInvoicePaymentMethod(invoice.Id, eligibleMethodToActivate);
|
||||||
eventAggregator.Publish(new InvoicePaymentMethodActivated(paymentMethodId, invoice));
|
eventAggregator.Publish(new InvoicePaymentMethodActivated(paymentMethodId, invoice));
|
||||||
|
eventAggregator.Publish(new InvoiceNeedUpdateEvent(invoice.Id));
|
||||||
|
success = true;
|
||||||
}
|
}
|
||||||
catch (PaymentMethodUnavailableException ex)
|
catch (PaymentMethodUnavailableException ex)
|
||||||
{
|
{
|
||||||
@@ -45,8 +48,8 @@ namespace BTCPayServer.Services.Invoices
|
|||||||
}
|
}
|
||||||
|
|
||||||
await invoiceRepository.AddInvoiceLogs(invoice.Id, logs);
|
await invoiceRepository.AddInvoiceLogs(invoice.Id, logs);
|
||||||
eventAggregator.Publish(new InvoiceNeedUpdateEvent(invoice.Id));
|
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user