From 275b590e8017a4da81e01f92614aa0823650a03a Mon Sep 17 00:00:00 2001 From: Kukks Date: Fri, 29 Mar 2019 07:51:00 +0100 Subject: [PATCH] add notif Email to crowdfund and pos + add notif url to pos closes #720 --- BTCPayServer/Controllers/AppsController.Crowdfund.cs | 1 + BTCPayServer/Controllers/AppsController.PointOfSale.cs | 6 +++++- BTCPayServer/Controllers/AppsPublicController.cs | 4 +++- .../Models/AppViewModels/UpdateCrowdfundViewModel.cs | 8 +++++++- .../Models/AppViewModels/UpdatePointOfSaleViewModel.cs | 8 ++++++++ BTCPayServer/Services/Apps/CrowdfundSettings.cs | 2 ++ BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml | 5 +++++ BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml | 10 ++++++++++ 8 files changed, 41 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Controllers/AppsController.Crowdfund.cs b/BTCPayServer/Controllers/AppsController.Crowdfund.cs index 6004c68b5..c9c9de22e 100644 --- a/BTCPayServer/Controllers/AppsController.Crowdfund.cs +++ b/BTCPayServer/Controllers/AppsController.Crowdfund.cs @@ -136,6 +136,7 @@ namespace BTCPayServer.Controllers MainImageUrl = vm.MainImageUrl, EmbeddedCSS = vm.EmbeddedCSS, NotificationUrl = vm.NotificationUrl, + NotificationEmail = vm.NotificationEmail, Tagline = vm.Tagline, PerksTemplate = vm.PerksTemplate, DisqusEnabled = vm.DisqusEnabled, diff --git a/BTCPayServer/Controllers/AppsController.PointOfSale.cs b/BTCPayServer/Controllers/AppsController.PointOfSale.cs index d348bddd8..b198c84c9 100644 --- a/BTCPayServer/Controllers/AppsController.PointOfSale.cs +++ b/BTCPayServer/Controllers/AppsController.PointOfSale.cs @@ -77,6 +77,8 @@ namespace BTCPayServer.Controllers public string CustomCSSLink { get; set; } + public string NotificationEmail { get; set; } + public string NotificationUrl { get; set; } } [HttpGet] @@ -101,7 +103,9 @@ namespace BTCPayServer.Controllers CustomButtonText = settings.CustomButtonText ?? PointOfSaleSettings.CUSTOM_BUTTON_TEXT_DEF, CustomTipText = settings.CustomTipText ?? PointOfSaleSettings.CUSTOM_TIP_TEXT_DEF, CustomTipPercentages = settings.CustomTipPercentages != null ? string.Join(",", settings.CustomTipPercentages) : string.Join(",", PointOfSaleSettings.CUSTOM_TIP_PERCENTAGES_DEF), - CustomCSSLink = settings.CustomCSSLink + CustomCSSLink = settings.CustomCSSLink, + NotificationEmail = settings.NotificationEmail, + NotificationUrl = settings.NotificationUrl }; if (HttpContext?.Request != null) { diff --git a/BTCPayServer/Controllers/AppsPublicController.cs b/BTCPayServer/Controllers/AppsPublicController.cs index 2646c4fd1..27c53bbab 100644 --- a/BTCPayServer/Controllers/AppsPublicController.cs +++ b/BTCPayServer/Controllers/AppsPublicController.cs @@ -184,6 +184,7 @@ namespace BTCPayServer.Controllers BuyerEmail = request.Email, Price = price, NotificationURL = settings.NotificationUrl, + NotificationEmail = settings.NotificationEmail, FullNotifications = true, ExtendedNotifications = true, RedirectURL = request.RedirectUrl ?? Request.GetDisplayUrl() @@ -262,7 +263,8 @@ namespace BTCPayServer.Controllers Price = price, BuyerEmail = email, OrderId = orderId, - NotificationURL = notificationUrl, + NotificationURL = string.IsNullOrEmpty(notificationUrl)? settings.NotificationUrl: notificationUrl, + NotificationEmail = settings.NotificationEmail, RedirectURL = redirectUrl ?? Request.GetDisplayUrl(), FullNotifications = true, PosData = string.IsNullOrEmpty(posData) ? null : posData diff --git a/BTCPayServer/Models/AppViewModels/UpdateCrowdfundViewModel.cs b/BTCPayServer/Models/AppViewModels/UpdateCrowdfundViewModel.cs index 2613eb271..126bd2e8b 100644 --- a/BTCPayServer/Models/AppViewModels/UpdateCrowdfundViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/UpdateCrowdfundViewModel.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using BTCPayServer.Services.Apps; +using BTCPayServer.Validation; namespace BTCPayServer.Models.AppViewModels { @@ -16,8 +17,13 @@ namespace BTCPayServer.Models.AppViewModels [Display(Name = "Featured Image")] public string MainImageUrl { get; set; } - + + [Display(Name = "Callback Notification Url")] + [Uri] public string NotificationUrl { get; set; } + [Display(Name = "Invoice Email Notification")] + [EmailAddress] + public string NotificationEmail { get; set; } [Required] [Display(Name = "Allow crowdfund to be publicly visible (still visible to you)")] diff --git a/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs b/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs index 321c0784e..2085d93e0 100644 --- a/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/UpdatePointOfSaleViewModel.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using BTCPayServer.Validation; namespace BTCPayServer.Models.AppViewModels { @@ -24,6 +25,13 @@ namespace BTCPayServer.Models.AppViewModels public string Example2 { get; internal set; } public string ExampleCallback { get; internal set; } public string InvoiceUrl { get; internal set; } + + [Display(Name = "Callback Notification Url")] + [Uri] + public string NotificationUrl { get; set; } + [Display(Name = "Invoice Email Notification")] + [EmailAddress] + public string NotificationEmail { get; set; } [Required] [MaxLength(30)] diff --git a/BTCPayServer/Services/Apps/CrowdfundSettings.cs b/BTCPayServer/Services/Apps/CrowdfundSettings.cs index afb5783df..d6091a6b9 100644 --- a/BTCPayServer/Services/Apps/CrowdfundSettings.cs +++ b/BTCPayServer/Services/Apps/CrowdfundSettings.cs @@ -82,6 +82,8 @@ namespace BTCPayServer.Services.Apps "//github.com/ClaudiuHKS/AdvancedQuakeSounds/raw/master/sound/QuakeSounds/unstoppable.wav", "//github.com/ClaudiuHKS/AdvancedQuakeSounds/raw/master/sound/QuakeSounds/whickedsick.wav" }; + + public string NotificationEmail { get; set; } } public enum CrowdfundResetEvery { diff --git a/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml b/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml index 9ace3808d..c4b1ceb20 100644 --- a/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml +++ b/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml @@ -137,6 +137,11 @@ +
+ + + +
diff --git a/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml b/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml index 4ef85cad5..a2bd1cf62 100644 --- a/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml +++ b/BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml @@ -104,6 +104,16 @@
+
+ + + +
+
+ + + +