diff --git a/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorController.cs b/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorController.cs index bf3445b..f4610cf 100644 --- a/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorController.cs +++ b/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorController.cs @@ -11,6 +11,7 @@ using BTCPayServer.Client; using BTCPayServer.Client.Models; using BTCPayServer.Controllers; using BTCPayServer.Data; +using BTCPayServer.Models; using BTCPayServer.Services.Apps; using BTCPayServer.Services.Invoices; using Microsoft.AspNetCore.Authorization; @@ -68,7 +69,7 @@ namespace BTCPayServer.Plugins.TicketTailor [HttpGet("plugins/TicketTailor/{appId}")] public async Task View(string appId) { - var app = await _appService.GetApp(appId, TicketTailorApp.AppType); + var app = await _appService.GetApp(appId, TicketTailorApp.AppType, true); if (app is null) return NotFound(); try @@ -83,7 +84,11 @@ namespace BTCPayServer.Plugins.TicketTailor return NotFound(); } - return View(new TicketTailorViewModel() {Event = evt, Settings = config}); + return View(new TicketTailorViewModel() + { + Event = evt, Settings = config, + StoreBranding = new StoreBrandingViewModel(app.StoreData.GetStoreBlob()) + }); } } catch (Exception e) @@ -380,6 +385,7 @@ namespace BTCPayServer.Plugins.TicketTailor vm.ApiKey = tt.ApiKey; vm.EventId = tt.EventId; vm.ShowDescription = tt.ShowDescription; + vm.SendEmail = tt.SendEmail; vm.BypassAvailabilityCheck = tt.BypassAvailabilityCheck; vm.CustomCSS = tt.CustomCSS; vm.RequireFullName = tt.RequireFullName; @@ -483,7 +489,8 @@ namespace BTCPayServer.Plugins.TicketTailor SpecificTickets = vm.SpecificTickets, BypassAvailabilityCheck = vm.BypassAvailabilityCheck, RequireFullName = vm.RequireFullName, - AllowDiscountCodes = vm.AllowDiscountCodes + AllowDiscountCodes = vm.AllowDiscountCodes, + SendEmail = vm.SendEmail }; diff --git a/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorService.cs b/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorService.cs index f17db6f..dfaedb4 100644 --- a/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorService.cs +++ b/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorService.cs @@ -238,24 +238,30 @@ public class TicketTailorService : EventHostedServiceBase } await _invoiceRepository.UpdateInvoiceMetadata(invoice.Id, invoice.StoreId, invoice.Metadata.ToJObject()); await _invoiceRepository.AddInvoiceLogs(invoice.Id, invLogs); - var uri = new Uri(btcpayUrl); - var url = - _linkGenerator.GetUriByAction("Receipt", - "TicketTailor", - new {invoiceId = invoice.Id}, - uri.Scheme, - new HostString(uri.Host), - uri.AbsolutePath); - try + if (settings.SendEmail) { - var sender = await _emailSenderFactory.GetEmailSender(issueTicket.Invoice.StoreId); - sender.SendEmail(MailboxAddress.Parse(email), "Your ticket is available now.", - $"Your payment has been settled and the event ticket has been issued successfully. Please go to {url}"); - } - catch (Exception e) - { - // ignored + + var uri = new Uri(btcpayUrl); + var url = + _linkGenerator.GetUriByAction("Receipt", + "TicketTailor", + new {invoiceId = invoice.Id}, + uri.Scheme, + new HostString(uri.Host), + uri.AbsolutePath); + + try + { + var sender = await _emailSenderFactory.GetEmailSender(issueTicket.Invoice.StoreId); + sender.SendEmail(MailboxAddress.Parse(email), "Your ticket is available now.", + $"Your payment has been settled and the event ticket has been issued successfully. Please go to {url}"); + } + catch (Exception e) + { + // ignored + } + } } catch (Exception e) diff --git a/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorSettings.cs b/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorSettings.cs index 88be59a..7e7c890 100644 --- a/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorSettings.cs +++ b/Plugins/BTCPayServer.Plugins.TicketTailor/TicketTailorSettings.cs @@ -13,5 +13,6 @@ namespace BTCPayServer.Plugins.TicketTailor public bool BypassAvailabilityCheck { get; set; } public bool RequireFullName { get; set; } public bool AllowDiscountCodes { get; set; } + public bool SendEmail { get; set; } = true; } } diff --git a/Plugins/BTCPayServer.Plugins.TicketTailor/UpdateTicketTailorSettingsViewModel.cs b/Plugins/BTCPayServer.Plugins.TicketTailor/UpdateTicketTailorSettingsViewModel.cs index 7d946d2..886ad2b 100644 --- a/Plugins/BTCPayServer.Plugins.TicketTailor/UpdateTicketTailorSettingsViewModel.cs +++ b/Plugins/BTCPayServer.Plugins.TicketTailor/UpdateTicketTailorSettingsViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using BTCPayServer.Models; using Microsoft.AspNetCore.Mvc.Rendering; namespace BTCPayServer.Plugins.TicketTailor; @@ -12,6 +13,7 @@ public class UpdateTicketTailorSettingsViewModel public SelectList Events { get; set; } public string EventId { get; set; } public bool ShowDescription { get; set; } + public bool SendEmail { get; set; } public string CustomCSS { get; set; } public TicketTailorClient.TicketType[] TicketTypes { get; set; } @@ -41,6 +43,7 @@ public class TicketTailorViewModel public PurchaseRequestItem[] Items { get; set; } public string AccessCode { get; set; } public string DiscountCode { get; set; } + public StoreBrandingViewModel StoreBranding { get; set; } public class PurchaseRequestItem { diff --git a/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/UpdateTicketTailorSettings.cshtml b/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/UpdateTicketTailorSettings.cshtml index c56a936..844a995 100644 --- a/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/UpdateTicketTailorSettings.cshtml +++ b/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/UpdateTicketTailorSettings.cshtml @@ -53,7 +53,7 @@ -
+
@@ -89,6 +89,11 @@
+
+ + + +
@@ -162,7 +167,7 @@
Invoices
-
- + \ No newline at end of file diff --git a/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/View.cshtml b/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/View.cshtml index aeb0db7..6733a5f 100644 --- a/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/View.cshtml +++ b/Plugins/BTCPayServer.Plugins.TicketTailor/Views/TicketTailor/View.cshtml @@ -4,7 +4,8 @@ @model BTCPayServer.Plugins.TicketTailor.TicketTailorViewModel @{ var appId = Context.GetRouteValue("appId"); - Layout = "_LayoutSimple"; + ViewData["StoreBranding"] = Model.StoreBranding; + Layout = null; var available = Model.Settings.BypassAvailabilityCheck || (Model.Event.Unavailable != "true" && Model.Event.TicketsAvailable == "true"); Model.Settings.SpecificTickets ??= new List(); Context.Request.Query.TryGetValue("accessCode", out var accessCode); @@ -13,85 +14,36 @@ Model.DiscountCode = discount; } } - - -
-
+ + +
+ +
- -

@Model.Event.Title

-

@Model.Event.Start.Formatted - @Model.Event.EventEnd.Formatted

+
@Model.Event.Start.Formatted - @Model.Event.EventEnd.Formatted
@if (Model.Settings.ShowDescription && !string.IsNullOrEmpty(Model.Event.Description)) { -
-
@Safe.Raw(Model.Event.Description)
-
+
@Safe.Raw(Model.Event.Description)
} + +
@@ -108,7 +60,7 @@ document.addEventListener("DOMContentLoaded", ()=>{
- +
@@ -122,7 +74,6 @@ document.addEventListener("DOMContentLoaded", ()=>{
- @if (!string.IsNullOrEmpty(groupedTickets.Key)) { var group = Model.Event.TicketGroups.First(ticketGroup => ticketGroup.Id == groupedTickets.Key); @@ -140,25 +91,31 @@ document.addEventListener("DOMContentLoaded", ()=>{ { continue; } + if (matched.Price is not null) { item.Price = matched.Price.Value; } + if (!string.IsNullOrEmpty(matched.Name)) { item.Name = matched.Name; } + if (!string.IsNullOrEmpty(matched.Description)) { item.Description = matched.Description; } + availableToShow = true; specific = true; } + if (!availableToShow) { continue; } + index++; @@ -200,20 +157,19 @@ document.addEventListener("DOMContentLoaded", ()=>{
} - }
- @if (Model.Settings.AllowDiscountCodes) - { -
-
- - -
-
- } + @if (Model.Settings.AllowDiscountCodes) + { +
+
+ + +
+
+ }
@@ -221,14 +177,18 @@ document.addEventListener("DOMContentLoaded", ()=>{
+ -
- -
- Powered by BTCPay Server -
-
-
-
\ No newline at end of file + +
+ + + + \ No newline at end of file