remove changelly fiat option

closes #728
This commit is contained in:
Kukks 2020-02-25 16:44:19 +01:00
parent fec5637040
commit b71fd1653e
6 changed files with 9 additions and 42 deletions

View file

@ -33,8 +33,6 @@ namespace BTCPayServer.Controllers
vm.ChangellyMerchantId = existing.ChangellyMerchantId; vm.ChangellyMerchantId = existing.ChangellyMerchantId;
vm.Enabled = existing.Enabled; vm.Enabled = existing.Enabled;
vm.AmountMarkupPercentage = existing.AmountMarkupPercentage; vm.AmountMarkupPercentage = existing.AmountMarkupPercentage;
vm.ShowFiat = existing.ShowFiat;
} }
[HttpPost] [HttpPost]
@ -60,8 +58,7 @@ namespace BTCPayServer.Controllers
ApiUrl = vm.ApiUrl, ApiUrl = vm.ApiUrl,
ChangellyMerchantId = vm.ChangellyMerchantId, ChangellyMerchantId = vm.ChangellyMerchantId,
Enabled = vm.Enabled, Enabled = vm.Enabled,
AmountMarkupPercentage = vm.AmountMarkupPercentage, AmountMarkupPercentage = vm.AmountMarkupPercentage
ShowFiat = vm.ShowFiat
}; };
switch (command) switch (command)

View file

@ -17,9 +17,6 @@ namespace BTCPayServer.Models.StoreViewModels
[Display(Name = "Optional, Changelly Merchant Id")] [Display(Name = "Optional, Changelly Merchant Id")]
public string ChangellyMerchantId { get; set; } public string ChangellyMerchantId { get; set; }
[Display(Name = "Show Fiat Currencies as option in conversion")]
public bool ShowFiat { get; set; } = true;
[Required] [Required]
[Range(0, 100)] [Range(0, 100)]
[Display(Name = [Display(Name =

View file

@ -16,13 +16,11 @@ namespace BTCPayServer.Payments.Changelly
public class Changelly public class Changelly
{ {
private readonly string _apisecret; private readonly string _apisecret;
private readonly bool _showFiat;
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
public Changelly(HttpClient httpClient, string apiKey, string apiSecret, string apiUrl, bool showFiat = true) public Changelly(HttpClient httpClient, string apiKey, string apiSecret, string apiUrl)
{ {
_apisecret = apiSecret; _apisecret = apiSecret;
_showFiat = showFiat;
_httpClient = httpClient; _httpClient = httpClient;
_httpClient.BaseAddress = new Uri(apiUrl); _httpClient.BaseAddress = new Uri(apiUrl);
_httpClient.DefaultRequestHeaders.Add("api-key", apiKey); _httpClient.DefaultRequestHeaders.Add("api-key", apiKey);
@ -62,36 +60,16 @@ namespace BTCPayServer.Payments.Changelly
public virtual async Task<IEnumerable<CurrencyFull>> GetCurrenciesFull() public virtual async Task<IEnumerable<CurrencyFull>> GetCurrenciesFull()
{ {
const string message = @"{ const string message = @"{
""jsonrpc"": ""2.0"", ""jsonrpc"": ""2.0"",
""id"": 1, ""id"": 1,
""method"": ""getCurrenciesFull"", ""method"": ""getCurrenciesFull"",
""params"": [] ""params"": []
}"; }";
var result = await PostToApi<IEnumerable<CurrencyFull>>(message); var result = await PostToApi<IEnumerable<CurrencyFull>>(message);
var appendedResult = _showFiat
? result.Result.Concat(new[] return result.Result;
{
new CurrencyFull()
{
Enable = true,
Name = "EUR",
FullName = "Euro",
PayInConfirmations = 0,
ImageLink = "https://changelly.com/api/coins/eur.png"
},
new CurrencyFull()
{
Enable = true,
Name = "USD",
FullName = "US Dollar",
PayInConfirmations = 0,
ImageLink = "https://changelly.com/api/coins/usd.png"
}
})
: result.Result;
return appendedResult;
} }
public virtual async Task<decimal> GetExchangeAmount(string fromCurrency, public virtual async Task<decimal> GetExchangeAmount(string fromCurrency,

View file

@ -61,8 +61,9 @@ namespace BTCPayServer.Payments.Changelly
throw new ChangellyException("Changelly not enabled for this store"); throw new ChangellyException("Changelly not enabled for this store");
} }
var changelly = new Changelly(_httpClientFactory.CreateClient("Changelly"), changellySettings.ApiKey, changellySettings.ApiSecret, var changelly = new Changelly(_httpClientFactory.CreateClient("Changelly"), changellySettings.ApiKey,
changellySettings.ApiUrl, changellySettings.ShowFiat); changellySettings.ApiSecret,
changellySettings.ApiUrl);
_clientCache.AddOrReplace(storeId, changelly); _clientCache.AddOrReplace(storeId, changelly);
return changelly; return changelly;
} }

View file

@ -8,7 +8,6 @@ namespace BTCPayServer.Payments.Changelly
public bool Enabled { get; set; } public bool Enabled { get; set; }
public string ChangellyMerchantId { get; set; } public string ChangellyMerchantId { get; set; }
public decimal AmountMarkupPercentage { get; set; } public decimal AmountMarkupPercentage { get; set; }
public bool ShowFiat { get; set; }
public bool IsConfigured() public bool IsConfigured()
{ {

View file

@ -38,11 +38,6 @@
<input asp-for="AmountMarkupPercentage" class="form-control"/> <input asp-for="AmountMarkupPercentage" class="form-control"/>
<span asp-validation-for="AmountMarkupPercentage" class="text-danger"></span> <span asp-validation-for="AmountMarkupPercentage" class="text-danger"></span>
</div> </div>
<div class="form-group">
<label asp-for="ShowFiat"></label>
<input asp-for="ShowFiat" class="form-check"/>
<span asp-validation-for="ShowFiat" class="text-danger"></span>
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="Enabled"></label> <label asp-for="Enabled"></label>
<input asp-for="Enabled" type="checkbox" class="form-check"/> <input asp-for="Enabled" type="checkbox" class="form-check"/>