2018-03-27 07:48:32 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-01-31 11:07:38 +01:00
|
|
|
|
using BTCPayServer.Payments;
|
2018-03-27 07:48:32 +02:00
|
|
|
|
using BTCPayServer.Services;
|
2018-05-14 09:32:04 +02:00
|
|
|
|
using BTCPayServer.Validation;
|
2018-03-27 07:48:32 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
|
|
|
|
|
namespace BTCPayServer.Models.StoreViewModels
|
|
|
|
|
{
|
|
|
|
|
public class CheckoutExperienceViewModel
|
|
|
|
|
{
|
2019-01-31 14:03:28 +01:00
|
|
|
|
public class Format
|
2018-03-27 07:48:32 +02:00
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Value { get; set; }
|
2019-01-31 14:03:28 +01:00
|
|
|
|
public PaymentMethodId PaymentId { get; set; }
|
2018-03-27 07:48:32 +02:00
|
|
|
|
}
|
|
|
|
|
public SelectList CryptoCurrencies { get; set; }
|
|
|
|
|
public SelectList Languages { get; set; }
|
|
|
|
|
|
2019-04-11 08:41:30 +02:00
|
|
|
|
[Display(Name = "Default payment method on checkout")]
|
2019-01-31 11:07:38 +01:00
|
|
|
|
public string DefaultPaymentMethod { get; set; }
|
2018-03-27 07:48:32 +02:00
|
|
|
|
[Display(Name = "Default language on checkout")]
|
|
|
|
|
public string DefaultLang { get; set; }
|
2018-04-03 10:39:28 +02:00
|
|
|
|
|
2018-03-27 08:14:50 +02:00
|
|
|
|
[Display(Name = "Link to a custom CSS stylesheet")]
|
2018-04-05 04:34:25 +02:00
|
|
|
|
public string CustomCSS { get; set; }
|
2018-03-27 08:14:50 +02:00
|
|
|
|
[Display(Name = "Link to a custom logo")]
|
2018-04-05 04:34:25 +02:00
|
|
|
|
public string CustomLogo { get; set; }
|
2018-04-03 10:39:28 +02:00
|
|
|
|
|
2018-05-03 23:51:04 +02:00
|
|
|
|
[Display(Name = "Custom HTML title to display on Checkout page")]
|
|
|
|
|
public string HtmlTitle { get; set; }
|
|
|
|
|
|
2019-03-16 04:43:57 +01:00
|
|
|
|
[Display(Name = "Requires a refund email")]
|
|
|
|
|
public bool RequiresRefundEmail { get; set; }
|
|
|
|
|
|
2019-10-08 06:06:12 +02:00
|
|
|
|
[Display(Name = "Show recommended fee")]
|
|
|
|
|
public bool ShowRecommendedFee { get; set; }
|
|
|
|
|
|
2019-11-07 01:21:33 +01:00
|
|
|
|
[Display(Name = "Recommended fee confirmation target blocks")]
|
|
|
|
|
[Range(1, double.PositiveInfinity)]
|
|
|
|
|
public int RecommendedFeeBlockTarget { get; set; }
|
|
|
|
|
|
2019-03-16 04:43:57 +01:00
|
|
|
|
[Display(Name = "Do not propose on chain payment if the value of the invoice is below...")]
|
|
|
|
|
[MaxLength(20)]
|
|
|
|
|
public string OnChainMinValue { get; set; }
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Do not propose lightning payment if value of the invoice is above...")]
|
|
|
|
|
[MaxLength(20)]
|
|
|
|
|
public string LightningMaxValue { get; set; }
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Display lightning payment amounts in Satoshis")]
|
|
|
|
|
public bool LightningAmountInSatoshi { get; set; }
|
2019-04-11 11:53:31 +02:00
|
|
|
|
|
|
|
|
|
[Display(Name = "Redirect invoice to redirect url automatically after paid")]
|
|
|
|
|
public bool RedirectAutomatically { get; set; }
|
2019-03-16 04:43:57 +01:00
|
|
|
|
|
2018-03-27 07:48:32 +02:00
|
|
|
|
public void SetLanguages(LanguageService langService, string defaultLang)
|
|
|
|
|
{
|
2019-03-16 04:43:57 +01:00
|
|
|
|
defaultLang = langService.GetLanguages().Any(language => language.Code == defaultLang) ? defaultLang : "en";
|
2018-03-27 07:48:32 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|