mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +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,
|
OrderId = invoice.OrderId,
|
||||||
InvoiceId = invoice.Id,
|
InvoiceId = invoice.Id,
|
||||||
DefaultLang = storeBlob.DefaultLang ?? "en",
|
DefaultLang = storeBlob.DefaultLang ?? "en",
|
||||||
HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice",
|
|
||||||
CustomCSSLink = storeBlob.CustomCSS,
|
CustomCSSLink = storeBlob.CustomCSS,
|
||||||
CustomLogoLink = storeBlob.CustomLogo,
|
CustomLogoLink = storeBlob.CustomLogo,
|
||||||
|
HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice",
|
||||||
|
CheckoutTheme = storeBlob.CheckoutTheme ?? "Default",
|
||||||
CryptoImage = Request.GetRelativePathOrAbsolute(paymentMethodHandler.GetCryptoImage(paymentMethodId)),
|
CryptoImage = Request.GetRelativePathOrAbsolute(paymentMethodHandler.GetCryptoImage(paymentMethodId)),
|
||||||
BtcAddress = paymentMethodDetails.GetPaymentDestination(),
|
BtcAddress = paymentMethodDetails.GetPaymentDestination(),
|
||||||
BtcDue = accounting.Due.ToString(),
|
BtcDue = accounting.Due.ToString(),
|
||||||
|
|||||||
@@ -373,6 +373,8 @@ namespace BTCPayServer.Controllers
|
|||||||
vm.CustomCSS = storeBlob.CustomCSS;
|
vm.CustomCSS = storeBlob.CustomCSS;
|
||||||
vm.CustomLogo = storeBlob.CustomLogo;
|
vm.CustomLogo = storeBlob.CustomLogo;
|
||||||
vm.HtmlTitle = storeBlob.HtmlTitle;
|
vm.HtmlTitle = storeBlob.HtmlTitle;
|
||||||
|
vm.SetCheckoutThemes(storeBlob.CheckoutTheme);
|
||||||
|
vm.CheckoutTheme = storeBlob.CheckoutTheme;
|
||||||
vm.SetLanguages(_LangService, storeBlob.DefaultLang);
|
vm.SetLanguages(_LangService, storeBlob.DefaultLang);
|
||||||
vm.RequiresRefundEmail = storeBlob.RequiresRefundEmail;
|
vm.RequiresRefundEmail = storeBlob.RequiresRefundEmail;
|
||||||
vm.ShowRecommendedFee = storeBlob.ShowRecommendedFee;
|
vm.ShowRecommendedFee = storeBlob.ShowRecommendedFee;
|
||||||
@@ -428,11 +430,13 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
|
model.SetCheckoutThemes(blob.CheckoutTheme);
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
blob.CustomLogo = model.CustomLogo;
|
blob.CustomLogo = model.CustomLogo;
|
||||||
blob.CustomCSS = model.CustomCSS;
|
blob.CustomCSS = model.CustomCSS;
|
||||||
blob.HtmlTitle = string.IsNullOrWhiteSpace(model.HtmlTitle) ? null : model.HtmlTitle;
|
blob.HtmlTitle = string.IsNullOrWhiteSpace(model.HtmlTitle) ? null : model.HtmlTitle;
|
||||||
|
blob.CheckoutTheme = model.CheckoutTheme;
|
||||||
blob.DefaultLang = model.DefaultLang;
|
blob.DefaultLang = model.DefaultLang;
|
||||||
blob.RequiresRefundEmail = model.RequiresRefundEmail;
|
blob.RequiresRefundEmail = model.RequiresRefundEmail;
|
||||||
blob.ShowRecommendedFee = model.ShowRecommendedFee;
|
blob.ShowRecommendedFee = model.ShowRecommendedFee;
|
||||||
|
|||||||
@@ -93,10 +93,10 @@ namespace BTCPayServer.Data
|
|||||||
public CurrencyValue LightningMaxValue { get; set; }
|
public CurrencyValue LightningMaxValue { get; set; }
|
||||||
public bool LightningAmountInSatoshi { get; set; }
|
public bool LightningAmountInSatoshi { get; set; }
|
||||||
|
|
||||||
public string CustomLogo { get; set; }
|
|
||||||
|
|
||||||
public string CustomCSS { get; set; }
|
public string CustomCSS { get; set; }
|
||||||
|
public string CustomLogo { get; set; }
|
||||||
public string HtmlTitle { get; set; }
|
public string HtmlTitle { get; set; }
|
||||||
|
public string CheckoutTheme { get; set; }
|
||||||
|
|
||||||
public bool RateScripting { get; set; }
|
public bool RateScripting { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ namespace BTCPayServer.Models.InvoicingModels
|
|||||||
public bool IsLightning { get; set; }
|
public bool IsLightning { get; set; }
|
||||||
public string CryptoCode { get; set; }
|
public string CryptoCode { get; set; }
|
||||||
}
|
}
|
||||||
public string HtmlTitle { get; set; }
|
|
||||||
public string CustomCSSLink { get; set; }
|
public string CustomCSSLink { get; set; }
|
||||||
public string CustomLogoLink { get; set; }
|
public string CustomLogoLink { get; set; }
|
||||||
|
public string HtmlTitle { get; set; }
|
||||||
|
public string CheckoutTheme { get; set; }
|
||||||
public string DefaultLang { get; set; }
|
public string DefaultLang { get; set; }
|
||||||
public bool LightningAmountInSatoshi { get; set; }
|
public bool LightningAmountInSatoshi { get; set; }
|
||||||
public List<AvailableCrypto> AvailableCryptos { get; set; } = new List<AvailableCrypto>();
|
public List<AvailableCrypto> AvailableCryptos { get; set; } = new List<AvailableCrypto>();
|
||||||
|
|||||||
@@ -19,8 +19,32 @@ namespace BTCPayServer.Models.StoreViewModels
|
|||||||
public PaymentMethodId PaymentId { get; set; }
|
public PaymentMethodId PaymentId { get; set; }
|
||||||
}
|
}
|
||||||
public SelectList CryptoCurrencies { 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 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")]
|
[Display(Name = "Default payment method on checkout")]
|
||||||
public string DefaultPaymentMethod { get; set; }
|
public string DefaultPaymentMethod { get; set; }
|
||||||
[Display(Name = "Default language on checkout")]
|
[Display(Name = "Default language on checkout")]
|
||||||
@@ -34,6 +58,9 @@ namespace BTCPayServer.Models.StoreViewModels
|
|||||||
[Display(Name = "Custom HTML title to display on Checkout page")]
|
[Display(Name = "Custom HTML title to display on Checkout page")]
|
||||||
public string HtmlTitle { get; set; }
|
public string HtmlTitle { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Theme used on Checkout page")]
|
||||||
|
public string CheckoutTheme { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Requires a refund email")]
|
[Display(Name = "Requires a refund email")]
|
||||||
public bool RequiresRefundEmail { get; set; }
|
public bool RequiresRefundEmail { get; set; }
|
||||||
|
|
||||||
@@ -57,14 +84,5 @@ namespace BTCPayServer.Models.StoreViewModels
|
|||||||
|
|
||||||
[Display(Name = "Redirect invoice to redirect url automatically after paid")]
|
[Display(Name = "Redirect invoice to redirect url automatically after paid")]
|
||||||
public bool RedirectAutomatically { get; set; }
|
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" />
|
<bundle name="wwwroot/bundles/checkout-bundle.min.js" />
|
||||||
<script>vex.defaultOptions.className = 'vex-theme-btcpay'</script>
|
<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))
|
@if (!string.IsNullOrEmpty(Model.CustomCSSLink))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
<input asp-for="HtmlTitle" class="form-control" />
|
<input asp-for="HtmlTitle" class="form-control" />
|
||||||
<span asp-validation-for="HtmlTitle" class="text-danger"></span>
|
<span asp-validation-for="HtmlTitle" class="text-danger"></span>
|
||||||
</div>
|
</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">
|
<div class="form-group">
|
||||||
<label asp-for="DefaultPaymentMethod"></label>
|
<label asp-for="DefaultPaymentMethod"></label>
|
||||||
<select asp-for="DefaultPaymentMethod" asp-items="Model.CryptoCurrencies" class="form-control"></select>
|
<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