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;
|
2019-01-31 19:07:38 +09:00
|
|
|
using BTCPayServer.Payments;
|
2018-03-27 14:48:32 +09:00
|
|
|
using BTCPayServer.Services;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Models.StoreViewModels
|
|
|
|
{
|
|
|
|
public class CheckoutExperienceViewModel
|
|
|
|
{
|
2019-01-31 22:03:28 +09:00
|
|
|
public class Format
|
2018-03-27 14:48:32 +09:00
|
|
|
{
|
|
|
|
public string Name { get; set; }
|
|
|
|
public string Value { get; set; }
|
2019-01-31 22:03:28 +09:00
|
|
|
public PaymentMethodId PaymentId { get; set; }
|
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";
|
|
|
|
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;
|
|
|
|
}
|
2018-03-27 14:48:32 +09:00
|
|
|
public SelectList Languages { 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-06-06 13:44:54 +02:00
|
|
|
|
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-07-27 08:17:56 +02:00
|
|
|
|
|
|
|
[Display(Name = "Auto-detect language on checkout")]
|
|
|
|
public bool AutoDetectLanguage { get; set; }
|
|
|
|
|
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; }
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
public CriteriaType Type { get; set; }
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-27 14:48:32 +09:00
|
|
|
}
|
|
|
|
}
|