Allow email notifications when creating invoices from Web UI (#2959)

Currently invoice email notifications are only sent when the invoice is created via the API. This commit adds an option to set an email address for notifications when an invoice is created from the Web UI.
This commit is contained in:
Aaron Clauson 2021-10-10 07:54:25 +01:00 committed by GitHub
parent 86956c1e7b
commit a7c093a0eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -868,6 +868,8 @@ namespace BTCPayServer.Controllers
Enabled = true
}),
DefaultPaymentMethod = model.DefaultPaymentMethod,
NotificationEmail = model.NotificationEmail,
ExtendedNotifications = model.NotificationEmail != null
}, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken: cancellationToken);
TempData[WellKnownTempData.SuccessMessage] = $"Invoice {result.Data.Id} just created!";

View file

@ -121,7 +121,7 @@ namespace BTCPayServer.HostedServices
#pragma warning restore CS0618
}
if (invoiceEvent.Name != InvoiceEvent.Expired && !String.IsNullOrEmpty(invoice.NotificationEmail))
if ((invoice.ExtendedNotifications || invoiceEvent.Name != InvoiceEvent.Expired) && !String.IsNullOrEmpty(invoice.NotificationEmail))
{
var json = NBitcoin.JsonConverters.Serializer.ToString(notification);
var store = await _StoreRepository.FindStore(invoice.StoreId);

View file

@ -86,5 +86,12 @@ namespace BTCPayServer.Models.InvoicingModels
{
get; set;
}
[EmailAddress]
[DisplayName("Notification Email")]
public string NotificationEmail
{
get; set;
}
}
}

View file

@ -84,6 +84,11 @@
<select asp-for="DefaultPaymentMethod" asp-items="Model.AvailablePaymentMethods" class="form-select"></select>
<span asp-validation-for="DefaultPaymentMethod" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="NotificationEmail" class="form-label"></label>
<input asp-for="NotificationEmail" class="form-control" />
<span asp-validation-for="NotificationEmail" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" id="Create" />
<a asp-action="ListInvoices" class="text-muted ms-3">Back to list</a>