mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
parent
fec5637040
commit
b71fd1653e
6 changed files with 9 additions and 42 deletions
|
@ -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)
|
||||||
|
|
|
@ -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 =
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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"/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue