From de8147d5dd94d43fe60a0a0d86d536bf7d365628 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 26 Apr 2018 11:13:44 +0900 Subject: [PATCH] Can opt out required refund email from customer --- BTCPayServer/Controllers/InvoiceController.UI.cs | 1 + BTCPayServer/Controllers/StoresController.cs | 2 ++ BTCPayServer/Data/StoreData.cs | 4 ++++ BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 1 + .../Models/StoreViewModels/CheckoutExperienceViewModel.cs | 6 ++++++ BTCPayServer/Views/Stores/CheckoutExperience.cshtml | 4 ++++ BTCPayServer/wwwroot/checkout/js/core.js | 2 +- 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 0a3f58ffd..356ed2486 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -232,6 +232,7 @@ namespace BTCPayServer.Controllers OrderAmount = (accounting.TotalDue - accounting.NetworkFee).ToString(), BtcDue = accounting.Due.ToString(), CustomerEmail = invoice.RefundMail, + RequiresRefundEmail = storeBlob.RequiresRefundEmail, ExpirationSeconds = Math.Max(0, (int)(invoice.ExpirationTime - DateTimeOffset.UtcNow).TotalSeconds), MaxTimeSeconds = (int)(invoice.ExpirationTime - invoice.InvoiceTime).TotalSeconds, MaxTimeMinutes = (int)(invoice.ExpirationTime - invoice.InvoiceTime).TotalMinutes, diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 936172127..c7f74e2ed 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -201,6 +201,7 @@ namespace BTCPayServer.Controllers vm.LightningMaxValue = storeBlob.LightningMaxValue?.ToString() ?? ""; vm.OnChainMinValue = storeBlob.OnChainMinValue?.ToString() ?? ""; vm.AllowCoinConversion = storeBlob.AllowCoinConversion; + vm.RequiresRefundEmail = storeBlob.RequiresRefundEmail; vm.CustomCSS = storeBlob.CustomCSS?.AbsoluteUri; vm.CustomLogo = storeBlob.CustomLogo?.AbsoluteUri; return View(vm); @@ -247,6 +248,7 @@ namespace BTCPayServer.Controllers } blob.DefaultLang = model.DefaultLang; blob.AllowCoinConversion = model.AllowCoinConversion; + blob.RequiresRefundEmail = model.RequiresRefundEmail; blob.LightningMaxValue = lightningMaxValue; blob.OnChainMinValue = onchainMinValue; blob.CustomLogo = string.IsNullOrWhiteSpace(model.CustomLogo) ? null : new Uri(model.CustomLogo, UriKind.Absolute); diff --git a/BTCPayServer/Data/StoreData.cs b/BTCPayServer/Data/StoreData.cs index 6ac02a0d1..58923bbf1 100644 --- a/BTCPayServer/Data/StoreData.cs +++ b/BTCPayServer/Data/StoreData.cs @@ -214,6 +214,7 @@ namespace BTCPayServer.Data { InvoiceExpiration = 15; MonitoringExpiration = 60; + RequiresRefundEmail = true; } public bool NetworkFeeDisabled { @@ -223,6 +224,9 @@ namespace BTCPayServer.Data { get; set; } + + public bool RequiresRefundEmail { get; set; } + public string DefaultLang { get; set; } [DefaultValue(60)] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index ec42fd82c..9cd26cbf1 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -24,6 +24,7 @@ namespace BTCPayServer.Models.InvoicingModels public string BtcAddress { get; set; } public string BtcDue { get; set; } public string CustomerEmail { get; set; } + public bool RequiresRefundEmail { get; set; } public int ExpirationSeconds { get; set; } public string Status { get; set; } public string MerchantRefLink { get; set; } diff --git a/BTCPayServer/Models/StoreViewModels/CheckoutExperienceViewModel.cs b/BTCPayServer/Models/StoreViewModels/CheckoutExperienceViewModel.cs index 06bbe2c3c..758350d49 100644 --- a/BTCPayServer/Models/StoreViewModels/CheckoutExperienceViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/CheckoutExperienceViewModel.cs @@ -31,6 +31,12 @@ namespace BTCPayServer.Models.StoreViewModels [MaxLength(20)] public string LightningMaxValue { get; set; } + [Display(Name = "Requires a refund email")] + public bool RequiresRefundEmail + { + get; set; + } + [Display(Name = "Do not propose on chain payment if the value of the invoice is below...")] [MaxLength(20)] public string OnChainMinValue { get; set; } diff --git a/BTCPayServer/Views/Stores/CheckoutExperience.cshtml b/BTCPayServer/Views/Stores/CheckoutExperience.cshtml index 93d552083..8e2b29279 100644 --- a/BTCPayServer/Views/Stores/CheckoutExperience.cshtml +++ b/BTCPayServer/Views/Stores/CheckoutExperience.cshtml @@ -38,6 +38,10 @@ +
+ + +
diff --git a/BTCPayServer/wwwroot/checkout/js/core.js b/BTCPayServer/wwwroot/checkout/js/core.js index a5e7d734e..89120ef3f 100644 --- a/BTCPayServer/wwwroot/checkout/js/core.js +++ b/BTCPayServer/wwwroot/checkout/js/core.js @@ -108,7 +108,7 @@ $(document).ready(function () { if (srvModel.expirationSeconds > 0) { progressStart(srvModel.maxTimeSeconds); // Progress bar - if (!validateEmail(srvModel.customerEmail)) + if (srvModel.requiresRefundEmail && !validateEmail(srvModel.customerEmail)) emailForm(); // Email form Display else hideEmailForm();