mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 10:40:29 +01:00
88 lines
2.5 KiB
C#
88 lines
2.5 KiB
C#
using BTCPayServer.Services.Invoices;
|
|
using BTCPayServer.Validations;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BTCPayServer.Models.StoreViewModels
|
|
{
|
|
public class StoreViewModel
|
|
{
|
|
public class DerivationScheme
|
|
{
|
|
public string Crypto { get; set; }
|
|
public string Value { get; set; }
|
|
}
|
|
class Format
|
|
{
|
|
public string Name { get; set; }
|
|
public string Value { get; set; }
|
|
}
|
|
public StoreViewModel()
|
|
{
|
|
|
|
}
|
|
|
|
public string Id { get; set; }
|
|
[Display(Name = "Store Name")]
|
|
[Required]
|
|
[MaxLength(50)]
|
|
[MinLength(1)]
|
|
public string StoreName
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
[Url]
|
|
[Display(Name = "Store Website")]
|
|
[MaxLength(500)]
|
|
public string StoreWebsite
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public List<StoreViewModel.DerivationScheme> DerivationSchemes { get; set; } = new List<StoreViewModel.DerivationScheme>();
|
|
|
|
[Display(Name = "Payment invalid if transactions fails to confirm after ... minutes")]
|
|
[Range(10, 60 * 24 * 31)]
|
|
public int MonitoringExpiration
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Display(Name = "Consider the invoice confirmed when the payment transaction...")]
|
|
public SpeedPolicy SpeedPolicy
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
[Display(Name = "Add network fee to invoice (vary with mining fees)")]
|
|
public bool NetworkFee
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public string StatusMessage
|
|
{
|
|
get; set;
|
|
}
|
|
public SelectList CryptoCurrencies { get; set; }
|
|
|
|
[Display(Name = "Default crypto currency on checkout")]
|
|
public string DefaultCryptoCurrency { get; set; }
|
|
|
|
public void SetCryptoCurrencies(ExplorerClientProvider explorerProvider, string defaultCrypto)
|
|
{
|
|
var choices = explorerProvider.GetAll().Select(o => new Format() { Name = o.Item1.CryptoCode, Value = o.Item1.CryptoCode }).ToArray();
|
|
var chosen = choices.FirstOrDefault(f => f.Name == defaultCrypto) ?? choices.FirstOrDefault();
|
|
CryptoCurrencies = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
|
|
DefaultCryptoCurrency = chosen.Name;
|
|
}
|
|
}
|
|
}
|