mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Do not fire InvoiceExpired twice if invoice partially paid (Fix #3004)
This commit is contained in:
parent
8a0660cbd6
commit
0b5d0349d4
@ -62,6 +62,10 @@ namespace BTCPayServer.Events
|
||||
public string Name { get; set; }
|
||||
|
||||
public PaymentEntity Payment { get; set; }
|
||||
/// <summary>
|
||||
/// Only set for Expired event
|
||||
/// </summary>
|
||||
public bool PaidPartial { get; internal set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
@ -83,9 +83,10 @@ namespace BTCPayServer.HostedServices
|
||||
context.MarkDirty();
|
||||
context.UnaffectAddresses();
|
||||
invoice.Status = InvoiceStatusLegacy.Expired;
|
||||
context.Events.Add(new InvoiceEvent(invoice, InvoiceEvent.Expired));
|
||||
var paidPartial = invoice.ExceptionStatus == InvoiceExceptionStatus.PaidPartial;
|
||||
context.Events.Add(new InvoiceEvent(invoice, InvoiceEvent.Expired) { PaidPartial = paidPartial });
|
||||
if (invoice.ExceptionStatus == InvoiceExceptionStatus.PaidPartial)
|
||||
context.Events.Add(new InvoiceEvent(invoice, InvoiceEvent.ExpiredPaidPartial));
|
||||
context.Events.Add(new InvoiceEvent(invoice, InvoiceEvent.ExpiredPaidPartial) { PaidPartial = paidPartial });
|
||||
}
|
||||
var allPaymentMethods = invoice.GetPaymentMethods();
|
||||
var paymentMethod = GetNearestClearedPayment(allPaymentMethods, out var accounting);
|
||||
|
@ -216,10 +216,9 @@ namespace BTCPayServer.HostedServices
|
||||
case InvoiceEventCode.Created:
|
||||
return new WebhookInvoiceEvent(WebhookEventType.InvoiceCreated);
|
||||
case InvoiceEventCode.Expired:
|
||||
case InvoiceEventCode.ExpiredPaidPartial:
|
||||
return new WebhookInvoiceExpiredEvent(WebhookEventType.InvoiceExpired)
|
||||
{
|
||||
PartiallyPaid = eventCode == InvoiceEventCode.ExpiredPaidPartial
|
||||
PartiallyPaid = invoiceEvent.PaidPartial
|
||||
};
|
||||
case InvoiceEventCode.FailedToConfirm:
|
||||
case InvoiceEventCode.MarkedInvalid:
|
||||
|
Loading…
Reference in New Issue
Block a user