mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
* Disable shapeshift and use changelly * UI to manage changelly payment method * wip on changelly api * Add in Vue component for changelly and remove target currency from payment method * add changelly merhcant id * Small fixes to get Conversion to load * wip fixing the component * fix merge conflict * fixes to UI * remove debug, fix fee calc and move changelly to own partials * Update ChangellyController.cs * move original vue setup back to checkout * Update core.js * Extracting Changelly component to js file * Proposal for loading spinner * remove zone * imrpove changelly ui * add in changelly config checks * try new method to calculate amount + remove to currency from list * abstract changelly lofgic to provider and reduce dependency on js component * Add UTs for Changelly * refactor changelly backend * fix failing UT * add shitcoin tax * pr changes * pr changes
68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BTCPayServer.Services.Stores;
|
|
using Changelly.ResponseModel;
|
|
|
|
namespace BTCPayServer.Payments.Changelly
|
|
{
|
|
public class ChangellyClientProvider
|
|
{
|
|
private readonly StoreRepository _storeRepository;
|
|
private readonly BTCPayNetworkProvider _btcPayNetworkProvider;
|
|
|
|
|
|
public ChangellyClientProvider(StoreRepository storeRepository, BTCPayNetworkProvider btcPayNetworkProvider)
|
|
{
|
|
_storeRepository = storeRepository;
|
|
_btcPayNetworkProvider = btcPayNetworkProvider;
|
|
}
|
|
|
|
|
|
public virtual bool TryGetChangellyClient(string storeId, out string error,
|
|
out global::Changelly.Changelly changelly)
|
|
{
|
|
changelly = null;
|
|
|
|
|
|
var store = _storeRepository.FindStore(storeId).Result;
|
|
if (store == null)
|
|
{
|
|
error = "Store not found";
|
|
return false;
|
|
}
|
|
|
|
var blob = store.GetStoreBlob();
|
|
var changellySettings = blob.ChangellySettings;
|
|
|
|
|
|
if (changellySettings == null || !changellySettings.IsConfigured())
|
|
{
|
|
error = "Changelly not configured for this store";
|
|
return false;
|
|
}
|
|
|
|
if (!changellySettings.Enabled)
|
|
{
|
|
error = "Changelly not enabled for this store";
|
|
return false;
|
|
}
|
|
|
|
changelly = new global::Changelly.Changelly(changellySettings.ApiKey, changellySettings.ApiSecret,
|
|
changellySettings.ApiUrl);
|
|
error = null;
|
|
return true;
|
|
}
|
|
|
|
public virtual (IList<CurrencyFull> currency, bool Success, string Error) GetCurrenciesFull(global::Changelly.Changelly client)
|
|
{
|
|
return client.GetCurrenciesFull();
|
|
}
|
|
|
|
public virtual (double amount, bool Success, string Error) GetExchangeAmount(global::Changelly.Changelly client, string fromCurrency, string toCurrency,
|
|
double amount)
|
|
{
|
|
|
|
return client.GetExchangeAmount(fromCurrency, toCurrency, amount);
|
|
}
|
|
}
|
|
}
|