diff --git a/BTCPayServer/Events/InvoiceEvent.cs b/BTCPayServer/Events/InvoiceEvent.cs index 1d3f75e2a..29813b43c 100644 --- a/BTCPayServer/Events/InvoiceEvent.cs +++ b/BTCPayServer/Events/InvoiceEvent.cs @@ -62,6 +62,10 @@ namespace BTCPayServer.Events public string Name { get; set; } public PaymentEntity Payment { get; set; } + /// + /// Only set for Expired event + /// + public bool PaidPartial { get; internal set; } public override string ToString() { diff --git a/BTCPayServer/HostedServices/InvoiceWatcher.cs b/BTCPayServer/HostedServices/InvoiceWatcher.cs index 9d923db47..4c8e3fb94 100644 --- a/BTCPayServer/HostedServices/InvoiceWatcher.cs +++ b/BTCPayServer/HostedServices/InvoiceWatcher.cs @@ -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); diff --git a/BTCPayServer/HostedServices/WebhookNotificationManager.cs b/BTCPayServer/HostedServices/WebhookNotificationManager.cs index 47ab12269..75b2d6382 100644 --- a/BTCPayServer/HostedServices/WebhookNotificationManager.cs +++ b/BTCPayServer/HostedServices/WebhookNotificationManager.cs @@ -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: