diff --git a/BTCPayServer.Client/Models/WebhookEventType.cs b/BTCPayServer.Client/Models/WebhookEventType.cs index b7c1e6bcb..db168ebc1 100644 --- a/BTCPayServer.Client/Models/WebhookEventType.cs +++ b/BTCPayServer.Client/Models/WebhookEventType.cs @@ -5,11 +5,13 @@ public static class WebhookEventType { public const string InvoiceCreated = nameof(InvoiceCreated); public const string InvoiceReceivedPayment = nameof(InvoiceReceivedPayment); + public const string InvoicePaymentSettled = nameof(InvoicePaymentSettled); public const string InvoiceProcessing = nameof(InvoiceProcessing); public const string InvoiceExpired = nameof(InvoiceExpired); public const string InvoiceSettled = nameof(InvoiceSettled); public const string InvoiceInvalid = nameof(InvoiceInvalid); - public const string InvoicePaymentSettled = nameof(InvoicePaymentSettled); + public const string InvoiceExpiredPaidPartial = nameof(InvoiceExpiredPaidPartial); + public const string InvoicePaidAfterExpiration = nameof(InvoicePaidAfterExpiration); public const string PayoutCreated = nameof(PayoutCreated); public const string PayoutApproved = nameof(PayoutApproved); public const string PayoutUpdated = nameof(PayoutUpdated); @@ -18,5 +20,4 @@ public static class WebhookEventType public const string PaymentRequestArchived = nameof(PaymentRequestArchived); public const string PaymentRequestStatusChanged = nameof(PaymentRequestStatusChanged); public const string PaymentRequestCompleted = nameof(PaymentRequestCompleted); - } diff --git a/BTCPayServer/HostedServices/Webhooks/InvoiceWebhookProvider.cs b/BTCPayServer/HostedServices/Webhooks/InvoiceWebhookProvider.cs index 7be8a8546..06d0de9d6 100644 --- a/BTCPayServer/HostedServices/Webhooks/InvoiceWebhookProvider.cs +++ b/BTCPayServer/HostedServices/Webhooks/InvoiceWebhookProvider.cs @@ -29,6 +29,8 @@ public class InvoiceWebhookProvider : WebhookProvider {WebhookEventType.InvoiceExpired, "Invoice - Expired"}, {WebhookEventType.InvoiceSettled, "Invoice - Is Settled"}, {WebhookEventType.InvoiceInvalid, "Invoice - Became Invalid"}, + {WebhookEventType.InvoiceExpiredPaidPartial, "Invoice - Expired Paid Partial"}, + {WebhookEventType.InvoicePaidAfterExpiration, "Invoice - Expired Paid Late"}, }; } @@ -113,6 +115,26 @@ public class InvoiceWebhookProvider : WebhookProvider Payment = GreenfieldInvoiceController.ToPaymentModel(invoiceEvent.Invoice, invoiceEvent.Payment), StoreId = invoiceEvent.Invoice.StoreId }; + case InvoiceEventCode.ExpiredPaidPartial: + return new WebhookInvoiceReceivedPaymentEvent(WebhookEventType.InvoiceExpiredPaidPartial, storeId) + { + AfterExpiration = + invoiceEvent.Invoice.Status == InvoiceStatus.Expired || + invoiceEvent.Invoice.Status == InvoiceStatus.Invalid, + PaymentMethodId = invoiceEvent.Payment.PaymentMethodId.ToString(), + Payment = GreenfieldInvoiceController.ToPaymentModel(invoiceEvent.Invoice, invoiceEvent.Payment), + StoreId = invoiceEvent.Invoice.StoreId + }; + case InvoiceEventCode.PaidAfterExpiration: + return new WebhookInvoiceReceivedPaymentEvent(WebhookEventType.InvoicePaidAfterExpiration, storeId) + { + AfterExpiration = + invoiceEvent.Invoice.Status == InvoiceStatus.Expired || + invoiceEvent.Invoice.Status == InvoiceStatus.Invalid, + PaymentMethodId = invoiceEvent.Payment.PaymentMethodId.ToString(), + Payment = GreenfieldInvoiceController.ToPaymentModel(invoiceEvent.Invoice, invoiceEvent.Payment), + StoreId = invoiceEvent.Invoice.StoreId + }; default: return null; } diff --git a/BTCPayServer/Views/UIStores/StoreEmailRulesManage.cshtml b/BTCPayServer/Views/UIStores/StoreEmailRulesManage.cshtml index c5d453552..bd52653f1 100644 --- a/BTCPayServer/Views/UIStores/StoreEmailRulesManage.cshtml +++ b/BTCPayServer/Views/UIStores/StoreEmailRulesManage.cshtml @@ -42,7 +42,7 @@
Choose what event sends the email.
@@ -66,7 +66,7 @@
- +
@@ -163,6 +163,14 @@ subject: 'Invoice {Invoice.Id} payment settled', body: 'Invoice {Invoice.Id} (Order Id: {Invoice.OrderId}) payment settled.' }, + @WebhookEventType.InvoiceExpiredPaidPartial: { + subject: 'Invoice {Invoice.Id} Expired Paid Partial', + body: 'Invoice {Invoice.Id} (Order Id: {Invoice.OrderId}) has expired partially paid.' + }, + @WebhookEventType.InvoicePaidAfterExpiration: { + subject: 'Invoice {Invoice.Id} Expired Paid Late', + body: 'Invoice {Invoice.Id} (Order Id: {Invoice.OrderId}) has been paid after expiration.' + }, @{ var paymentRequestsLink = CallbackGenerator.PaymentRequestListLink(storeId, this.Context.Request); } @WebhookEventType.PaymentRequestCompleted: { subject: 'Payment Request {PaymentRequest.Title} {PaymentRequest.ReferenceId} Completed',