2020-06-28 21:44:35 -05:00
|
|
|
using System;
|
2020-09-15 11:09:09 +02:00
|
|
|
using System.Collections.Generic;
|
2018-03-27 14:48:32 +09:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.Linq;
|
|
|
|
using BTCPayServer.Services;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
2022-07-06 14:14:55 +02:00
|
|
|
using Newtonsoft.Json.Linq;
|
2018-03-27 14:48:32 +09:00
|
|
|
|
|
|
|
namespace BTCPayServer.Models.StoreViewModels
|
|
|
|
{
|
2021-10-29 08:25:43 +02:00
|
|
|
public class CheckoutAppearanceViewModel
|
2018-03-27 14:48:32 +09:00
|
|
|
{
|
2020-09-15 11:09:09 +02:00
|
|
|
public SelectList PaymentMethods { get; set; }
|
2020-03-26 18:26:06 -05:00
|
|
|
|
|
|
|
public void SetLanguages(LanguageService langService, string defaultLang)
|
|
|
|
{
|
|
|
|
defaultLang = langService.GetLanguages().Any(language => language.Code == defaultLang) ? defaultLang : "en";
|
2022-04-11 01:48:12 -07:00
|
|
|
var choices = langService.GetLanguages().Select(o => new PaymentMethodOptionViewModel.Format() { Name = o.DisplayName, Value = o.Code }).ToArray().OrderBy(o => o.Name);
|
2020-03-26 18:26:06 -05:00
|
|
|
var chosen = choices.FirstOrDefault(f => f.Value == defaultLang) ?? choices.FirstOrDefault();
|
|
|
|
Languages = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
|
|
|
|
DefaultLang = chosen.Value;
|
|
|
|
}
|
2023-01-06 14:18:07 +01:00
|
|
|
|
2018-03-27 14:48:32 +09:00
|
|
|
public SelectList Languages { get; set; }
|
|
|
|
|
2022-11-24 00:53:32 +01:00
|
|
|
[Display(Name = "Unify on-chain and lightning payment URL/QR code")]
|
2022-11-02 10:21:33 +01:00
|
|
|
public bool OnChainWithLnInvoiceFallback { get; set; }
|
|
|
|
|
2023-04-04 10:45:40 +09:00
|
|
|
[Display(Name = "Show \"Pay in wallet\" button")]
|
|
|
|
public bool ShowPayInWalletButton { get; set; }
|
2023-04-10 11:07:03 +09:00
|
|
|
|
2023-04-04 10:45:40 +09:00
|
|
|
[Display(Name = "Show the store header")]
|
|
|
|
public bool ShowStoreHeader { get; set; }
|
|
|
|
|
2023-03-09 21:36:11 +01:00
|
|
|
[Display(Name = "Display Lightning payment amounts in Satoshis")]
|
|
|
|
public bool LightningAmountInSatoshi { get; set; }
|
|
|
|
|
2019-04-11 00:41:30 -06:00
|
|
|
[Display(Name = "Default payment method on checkout")]
|
2019-01-31 19:07:38 +09:00
|
|
|
public string DefaultPaymentMethod { get; set; }
|
2021-12-31 16:59:02 +09:00
|
|
|
|
2023-04-05 08:35:50 +09:00
|
|
|
[Display(Name = "Use the classic checkout")]
|
|
|
|
public bool UseClassicCheckout { get; set; }
|
2023-01-06 14:18:07 +01:00
|
|
|
|
2023-03-13 02:09:56 +01:00
|
|
|
[Display(Name = "Celebrate payment with confetti")]
|
|
|
|
public bool CelebratePayment { get; set; }
|
|
|
|
|
2019-03-15 22:43:57 -05:00
|
|
|
[Display(Name = "Requires a refund email")]
|
|
|
|
public bool RequiresRefundEmail { get; set; }
|
|
|
|
|
2021-04-07 06:08:42 +02:00
|
|
|
[Display(Name = "Only enable the payment method after user explicitly chooses it")]
|
|
|
|
public bool LazyPaymentMethods { get; set; }
|
|
|
|
|
2019-04-11 11:53:31 +02:00
|
|
|
[Display(Name = "Redirect invoice to redirect url automatically after paid")]
|
2020-06-28 17:55:27 +09:00
|
|
|
public bool RedirectAutomatically { get; set; }
|
2021-12-31 16:59:02 +09:00
|
|
|
|
2021-07-27 08:17:56 +02:00
|
|
|
[Display(Name = "Auto-detect language on checkout")]
|
|
|
|
public bool AutoDetectLanguage { get; set; }
|
2021-12-31 16:59:02 +09:00
|
|
|
|
2020-11-09 01:11:03 -06:00
|
|
|
[Display(Name = "Default language on checkout")]
|
|
|
|
public string DefaultLang { get; set; }
|
|
|
|
|
|
|
|
[Display(Name = "Link to a custom CSS stylesheet")]
|
|
|
|
public string CustomCSS { get; set; }
|
|
|
|
[Display(Name = "Link to a custom logo")]
|
|
|
|
public string CustomLogo { get; set; }
|
|
|
|
|
|
|
|
[Display(Name = "Custom HTML title to display on Checkout page")]
|
|
|
|
public string HtmlTitle { get; set; }
|
|
|
|
|
2023-01-16 12:45:19 +01:00
|
|
|
[Display(Name = "Show a timer … minutes before invoice expiration")]
|
|
|
|
[Range(1, 60 * 24 * 24)]
|
|
|
|
public int DisplayExpirationTimer { get; set; }
|
|
|
|
|
2022-07-06 14:14:55 +02:00
|
|
|
public class ReceiptOptionsViewModel
|
|
|
|
{
|
|
|
|
public static ReceiptOptionsViewModel Create(Client.Models.InvoiceDataBase.ReceiptOptions opts)
|
|
|
|
{
|
|
|
|
return JObject.FromObject(opts).ToObject<ReceiptOptionsViewModel>();
|
|
|
|
}
|
|
|
|
[Display(Name = "Enable public receipt page for settled invoices")]
|
|
|
|
public bool Enabled { get; set; }
|
2023-01-06 14:18:07 +01:00
|
|
|
|
2022-07-06 14:14:55 +02:00
|
|
|
[Display(Name = "Show the QR code of the receipt in the public receipt page")]
|
|
|
|
public bool ShowQR { get; set; }
|
|
|
|
|
|
|
|
[Display(Name = "Show the payment list in the public receipt page")]
|
|
|
|
public bool ShowPayments { get; set; }
|
|
|
|
public Client.Models.InvoiceDataBase.ReceiptOptions ToDTO()
|
|
|
|
{
|
|
|
|
return JObject.FromObject(this).ToObject<Client.Models.InvoiceDataBase.ReceiptOptions>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public ReceiptOptionsViewModel ReceiptOptions { get; set; } = ReceiptOptionsViewModel.Create(Client.Models.InvoiceDataBase.ReceiptOptions.CreateDefault());
|
2020-09-15 11:09:09 +02:00
|
|
|
public List<PaymentMethodCriteriaViewModel> PaymentMethodCriteria { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class PaymentMethodCriteriaViewModel
|
|
|
|
{
|
|
|
|
public string PaymentMethod { get; set; }
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
2021-12-31 16:59:02 +09:00
|
|
|
public CriteriaType Type { get; set; }
|
2020-09-15 11:09:09 +02:00
|
|
|
|
|
|
|
public enum CriteriaType
|
|
|
|
{
|
|
|
|
GreaterThan,
|
|
|
|
LessThan
|
|
|
|
}
|
|
|
|
public static string ToString(CriteriaType type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CriteriaType.GreaterThan:
|
|
|
|
return "Greater than";
|
|
|
|
case CriteriaType.LessThan:
|
|
|
|
return "Less than";
|
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
|
|
|
}
|
|
|
|
}
|
2021-12-31 16:59:02 +09:00
|
|
|
|
2018-03-27 14:48:32 +09:00
|
|
|
}
|
|
|
|
}
|