From 16e5e2d7570877abc6f8740efdc202d40199a378 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Mon, 7 Dec 2020 20:04:50 -0800 Subject: [PATCH 1/2] Add ability to associate custom CSS with a pull payment --- .../Controllers/WalletsController.PullPayments.cs | 8 ++++++-- .../HostedServices/PullPaymentHostedService.cs | 6 ++++-- .../Models/WalletViewModels/PullPaymentsModel.cs | 5 +++++ BTCPayServer/Views/Wallets/NewPullPayment.cshtml | 13 +++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Controllers/WalletsController.PullPayments.cs b/BTCPayServer/Controllers/WalletsController.PullPayments.cs index 6e50d7723..7f56f4cfb 100644 --- a/BTCPayServer/Controllers/WalletsController.PullPayments.cs +++ b/BTCPayServer/Controllers/WalletsController.PullPayments.cs @@ -30,7 +30,9 @@ namespace BTCPayServer.Controllers return View(new NewPullPaymentModel() { Name = "", - Currency = "BTC" + Currency = "BTC", + CustomCSSLink = "", + EmbeddedCSS = "", }); } @@ -65,7 +67,9 @@ namespace BTCPayServer.Controllers Amount = model.Amount, Currency = model.Currency, StoreId = walletId.StoreId, - PaymentMethodIds = new[] { paymentMethodId } + PaymentMethodIds = new[] { paymentMethodId }, + EmbeddedCSS = model.EmbeddedCSS, + CustomCSSLink = model.CustomCSSLink }); this.TempData.SetStatusMessageModel(new StatusMessageModel() { diff --git a/BTCPayServer/HostedServices/PullPaymentHostedService.cs b/BTCPayServer/HostedServices/PullPaymentHostedService.cs index 4f5ec876c..667a9b7ad 100644 --- a/BTCPayServer/HostedServices/PullPaymentHostedService.cs +++ b/BTCPayServer/HostedServices/PullPaymentHostedService.cs @@ -29,6 +29,8 @@ namespace BTCPayServer.HostedServices public string Name { get; set; } public decimal Amount { get; set; } public string Currency { get; set; } + public string CustomCSSLink { get; set; } + public string EmbeddedCSS { get; set; } public PaymentMethodId[] PaymentMethodIds { get; set; } public TimeSpan? Period { get; set; } } @@ -110,9 +112,9 @@ namespace BTCPayServer.HostedServices { Title = create.Name ?? string.Empty, Description = string.Empty, - CustomCSSLink = null, + CustomCSSLink = create.CustomCSSLink, Email = null, - EmbeddedCSS = null, + EmbeddedCSS = create.EmbeddedCSS, } }); ctx.PullPayments.Add(o); diff --git a/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs b/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs index 723c4411d..c8ca77303 100644 --- a/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs +++ b/BTCPayServer/Models/WalletViewModels/PullPaymentsModel.cs @@ -42,5 +42,10 @@ namespace BTCPayServer.Models.WalletViewModels [Required] [ReadOnly(true)] public string Currency { get; set; } + [MaxLength(500)] + [Display(Name = "Custom bootstrap CSS file")] + public string CustomCSSLink { get; set; } + [Display(Name = "Custom CSS Code")] + public string EmbeddedCSS { get; set; } } } diff --git a/BTCPayServer/Views/Wallets/NewPullPayment.cshtml b/BTCPayServer/Views/Wallets/NewPullPayment.cshtml index 3ae87ab39..b178373bb 100644 --- a/BTCPayServer/Views/Wallets/NewPullPayment.cshtml +++ b/BTCPayServer/Views/Wallets/NewPullPayment.cshtml @@ -79,6 +79,19 @@ +
+ + + + + + +
+
+ + + +
From e0b561b12a16ddc5d3b42e569f77a12590c81f4e Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Mon, 7 Dec 2020 20:16:51 -0800 Subject: [PATCH 2/2] Update new pull payment page heading --- BTCPayServer/Views/Wallets/NewPullPayment.cshtml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BTCPayServer/Views/Wallets/NewPullPayment.cshtml b/BTCPayServer/Views/Wallets/NewPullPayment.cshtml index b178373bb..0b6de6c66 100644 --- a/BTCPayServer/Views/Wallets/NewPullPayment.cshtml +++ b/BTCPayServer/Views/Wallets/NewPullPayment.cshtml @@ -1,8 +1,7 @@ @model NewPullPaymentModel @{ Layout = "../Shared/_NavLayout.cshtml"; - ViewData["Title"] = "Manage pull payments"; - ViewData.SetActivePageAndTitle(WalletsNavPages.PullPayments); + ViewData["Title"] = "New pull payment"; }