mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Adding setting to CheckoutExperience to pick checkout theme
This commit is contained in:
@@ -231,9 +231,10 @@ namespace BTCPayServer.Controllers
|
||||
OrderId = invoice.OrderId,
|
||||
InvoiceId = invoice.Id,
|
||||
DefaultLang = storeBlob.DefaultLang ?? "en",
|
||||
HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice",
|
||||
CustomCSSLink = storeBlob.CustomCSS,
|
||||
CustomLogoLink = storeBlob.CustomLogo,
|
||||
HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice",
|
||||
CheckoutTheme = storeBlob.CheckoutTheme ?? "Default",
|
||||
CryptoImage = Request.GetRelativePathOrAbsolute(paymentMethodHandler.GetCryptoImage(paymentMethodId)),
|
||||
BtcAddress = paymentMethodDetails.GetPaymentDestination(),
|
||||
BtcDue = accounting.Due.ToString(),
|
||||
|
||||
@@ -373,6 +373,8 @@ namespace BTCPayServer.Controllers
|
||||
vm.CustomCSS = storeBlob.CustomCSS;
|
||||
vm.CustomLogo = storeBlob.CustomLogo;
|
||||
vm.HtmlTitle = storeBlob.HtmlTitle;
|
||||
vm.SetCheckoutThemes(storeBlob.CheckoutTheme);
|
||||
vm.CheckoutTheme = storeBlob.CheckoutTheme;
|
||||
vm.SetLanguages(_LangService, storeBlob.DefaultLang);
|
||||
vm.RequiresRefundEmail = storeBlob.RequiresRefundEmail;
|
||||
vm.ShowRecommendedFee = storeBlob.ShowRecommendedFee;
|
||||
@@ -428,11 +430,13 @@ namespace BTCPayServer.Controllers
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
model.SetCheckoutThemes(blob.CheckoutTheme);
|
||||
return View(model);
|
||||
}
|
||||
blob.CustomLogo = model.CustomLogo;
|
||||
blob.CustomCSS = model.CustomCSS;
|
||||
blob.HtmlTitle = string.IsNullOrWhiteSpace(model.HtmlTitle) ? null : model.HtmlTitle;
|
||||
blob.CheckoutTheme = model.CheckoutTheme;
|
||||
blob.DefaultLang = model.DefaultLang;
|
||||
blob.RequiresRefundEmail = model.RequiresRefundEmail;
|
||||
blob.ShowRecommendedFee = model.ShowRecommendedFee;
|
||||
|
||||
@@ -93,10 +93,10 @@ namespace BTCPayServer.Data
|
||||
public CurrencyValue LightningMaxValue { get; set; }
|
||||
public bool LightningAmountInSatoshi { get; set; }
|
||||
|
||||
public string CustomLogo { get; set; }
|
||||
|
||||
public string CustomCSS { get; set; }
|
||||
public string CustomLogo { get; set; }
|
||||
public string HtmlTitle { get; set; }
|
||||
public string CheckoutTheme { get; set; }
|
||||
|
||||
public bool RateScripting { get; set; }
|
||||
|
||||
|
||||
@@ -24,9 +24,10 @@ namespace BTCPayServer.Models.InvoicingModels
|
||||
public bool IsLightning { get; set; }
|
||||
public string CryptoCode { get; set; }
|
||||
}
|
||||
public string HtmlTitle { get; set; }
|
||||
public string CustomCSSLink { get; set; }
|
||||
public string CustomLogoLink { get; set; }
|
||||
public string HtmlTitle { get; set; }
|
||||
public string CheckoutTheme { get; set; }
|
||||
public string DefaultLang { get; set; }
|
||||
public bool LightningAmountInSatoshi { get; set; }
|
||||
public List<AvailableCrypto> AvailableCryptos { get; set; } = new List<AvailableCrypto>();
|
||||
|
||||
@@ -19,8 +19,32 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||
public PaymentMethodId PaymentId { get; set; }
|
||||
}
|
||||
public SelectList CryptoCurrencies { get; set; }
|
||||
|
||||
public void SetLanguages(LanguageService langService, string defaultLang)
|
||||
{
|
||||
defaultLang = langService.GetLanguages().Any(language => language.Code == defaultLang) ? defaultLang : "en";
|
||||
var choices = langService.GetLanguages().Select(o => new Format() { Name = o.DisplayName, Value = o.Code }).ToArray();
|
||||
var chosen = choices.FirstOrDefault(f => f.Value == defaultLang) ?? choices.FirstOrDefault();
|
||||
Languages = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
|
||||
DefaultLang = chosen.Value;
|
||||
}
|
||||
public SelectList Languages { get; set; }
|
||||
|
||||
public SelectList ListCheckoutThemes { get; set; }
|
||||
public void SetCheckoutThemes(string dbtheme)
|
||||
{
|
||||
var list = new List<string>
|
||||
{
|
||||
"Default",
|
||||
"Legacy"
|
||||
};
|
||||
if (!list.Any(a => a == dbtheme))
|
||||
dbtheme = "Default"; // select default if not present
|
||||
|
||||
ListCheckoutThemes = new SelectList(list);
|
||||
CheckoutTheme = dbtheme;
|
||||
}
|
||||
|
||||
[Display(Name = "Default payment method on checkout")]
|
||||
public string DefaultPaymentMethod { get; set; }
|
||||
[Display(Name = "Default language on checkout")]
|
||||
@@ -34,6 +58,9 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||
[Display(Name = "Custom HTML title to display on Checkout page")]
|
||||
public string HtmlTitle { get; set; }
|
||||
|
||||
[Display(Name = "Theme used on Checkout page")]
|
||||
public string CheckoutTheme { get; set; }
|
||||
|
||||
[Display(Name = "Requires a refund email")]
|
||||
public bool RequiresRefundEmail { get; set; }
|
||||
|
||||
@@ -57,14 +84,5 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||
|
||||
[Display(Name = "Redirect invoice to redirect url automatically after paid")]
|
||||
public bool RedirectAutomatically { get; set; }
|
||||
|
||||
public void SetLanguages(LanguageService langService, string defaultLang)
|
||||
{
|
||||
defaultLang = langService.GetLanguages().Any(language => language.Code == defaultLang) ? defaultLang : "en";
|
||||
var choices = langService.GetLanguages().Select(o => new Format() { Name = o.DisplayName, Value = o.Code }).ToArray();
|
||||
var chosen = choices.FirstOrDefault(f => f.Value == defaultLang) ?? choices.FirstOrDefault();
|
||||
Languages = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
|
||||
DefaultLang = chosen.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<bundle name="wwwroot/bundles/checkout-bundle.min.js" />
|
||||
<script>vex.defaultOptions.className = 'vex-theme-btcpay'</script>
|
||||
|
||||
<link href="/checkout/css/themes/default.css" rel="stylesheet" />
|
||||
<link href="/checkout/css/themes/@(Model.CheckoutTheme.ToLower()).css" rel="stylesheet" />
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.CustomCSSLink))
|
||||
{
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
<input asp-for="HtmlTitle" class="form-control" />
|
||||
<span asp-validation-for="HtmlTitle" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="CheckoutTheme"></label>
|
||||
<select asp-for="CheckoutTheme" asp-items="Model.ListCheckoutThemes" class="form-control"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="DefaultPaymentMethod"></label>
|
||||
<select asp-for="DefaultPaymentMethod" asp-items="Model.CryptoCurrencies" class="form-control"></select>
|
||||
|
||||
11553
BTCPayServer/wwwroot/checkout/css/themes/legacy.css
Normal file
11553
BTCPayServer/wwwroot/checkout/css/themes/legacy.css
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user