diff --git a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs
index 29b7f5080..37d3048c1 100644
--- a/BTCPayServer/HostedServices/InvoiceNotificationManager.cs
+++ b/BTCPayServer/HostedServices/InvoiceNotificationManager.cs
@@ -13,6 +13,7 @@ using BTCPayServer.Payments;
using BTCPayServer.Services;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Mails;
+using BTCPayServer.Services.Stores;
using Microsoft.Extensions.Hosting;
using NBitpayClient;
using NBXplorer;
@@ -42,13 +43,14 @@ namespace BTCPayServer.HostedServices
readonly EventAggregator _EventAggregator;
readonly InvoiceRepository _InvoiceRepository;
private readonly EmailSenderFactory _EmailSenderFactory;
+ private readonly StoreRepository _StoreRepository;
public InvoiceNotificationManager(
IHttpClientFactory httpClientFactory,
IBackgroundJobClient jobClient,
EventAggregator eventAggregator,
InvoiceRepository invoiceRepository,
- BTCPayNetworkProvider networkProvider,
+ StoreRepository storeRepository,
EmailSenderFactory emailSenderFactory)
{
_Client = httpClientFactory.CreateClient();
@@ -56,9 +58,10 @@ namespace BTCPayServer.HostedServices
_EventAggregator = eventAggregator;
_InvoiceRepository = invoiceRepository;
_EmailSenderFactory = emailSenderFactory;
+ _StoreRepository = storeRepository;
}
- void Notify(InvoiceEntity invoice, InvoiceEvent invoiceEvent, bool extendedNotification)
+ async Task Notify(InvoiceEntity invoice, InvoiceEvent invoiceEvent, bool extendedNotification)
{
var dto = invoice.EntityToDTO();
var notification = new InvoicePaymentNotificationEventWrapper()
@@ -118,15 +121,21 @@ namespace BTCPayServer.HostedServices
#pragma warning restore CS0618
}
- if (!String.IsNullOrEmpty(invoice.NotificationEmail))
+ if (invoiceEvent.Name != InvoiceEvent.Expired && !String.IsNullOrEmpty(invoice.NotificationEmail))
{
- var emailBody = NBitcoin.JsonConverters.Serializer.ToString(notification);
+ var json = NBitcoin.JsonConverters.Serializer.ToString(notification);
+ var store = await _StoreRepository.FindStore(invoice.StoreId);
+ var storeName = store.StoreName ?? "BTCPay Server";
+ var emailBody = $"Store: {storeName}
" +
+ $"Invoice ID: {notification.Data.Id}
" +
+ $"Status: {notification.Data.Status}
" +
+ $"Amount: {notification.Data.Price} {notification.Data.Currency}
" +
+ $"
Details
{json} ";
_EmailSenderFactory.GetEmailSender(invoice.StoreId).SendEmail(
invoice.NotificationEmail,
- $"BtcPayServer Invoice Notification - ${invoice.StoreId}",
+ $"{storeName} Invoice Notification - ${invoice.StoreId}",
emailBody);
-
}
if (invoice.NotificationURL != null)