mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
4b976c13c1
* 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 * WIP: getting rid of changelly dependency * client caching, compiling code, cleaner code * Cleaner changelly * fiat! * updat i18n, css and error styler * default keys * pr changes part 1 * part2 * fix tests * fix loader alignment and retry button responsiveness * final pr change
60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Payments.Changelly;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BTCPayServer.Payments
|
|
{
|
|
public class PaymentMethodExtensions
|
|
{
|
|
public static ISupportedPaymentMethod Deserialize(PaymentMethodId paymentMethodId, JToken value, BTCPayNetwork network)
|
|
{
|
|
// Legacy
|
|
if (paymentMethodId.PaymentType == PaymentTypes.BTCLike)
|
|
{
|
|
return BTCPayServer.DerivationStrategy.Parse(((JValue)value).Value<string>(), network);
|
|
}
|
|
//////////
|
|
else if (paymentMethodId.PaymentType == PaymentTypes.LightningLike)
|
|
{
|
|
return JsonConvert.DeserializeObject<Payments.Lightning.LightningSupportedPaymentMethod>(value.ToString());
|
|
}
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public static IPaymentMethodDetails DeserializePaymentMethodDetails(PaymentMethodId paymentMethodId, JObject jobj)
|
|
{
|
|
if(paymentMethodId.PaymentType == PaymentTypes.BTCLike)
|
|
{
|
|
return JsonConvert.DeserializeObject<Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod>(jobj.ToString());
|
|
}
|
|
if (paymentMethodId.PaymentType == PaymentTypes.LightningLike)
|
|
{
|
|
return JsonConvert.DeserializeObject<Payments.Lightning.LightningLikePaymentMethodDetails>(jobj.ToString());
|
|
}
|
|
throw new NotSupportedException(paymentMethodId.PaymentType.ToString());
|
|
}
|
|
|
|
|
|
public static JToken Serialize(ISupportedPaymentMethod factory)
|
|
{
|
|
// Legacy
|
|
if (factory.PaymentId.PaymentType == PaymentTypes.BTCLike)
|
|
{
|
|
return new JValue(((DerivationStrategy)factory).DerivationStrategyBase.ToString());
|
|
}
|
|
//////////////
|
|
else
|
|
{
|
|
var str = JsonConvert.SerializeObject(factory);
|
|
return JObject.Parse(str);
|
|
}
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
}
|
|
}
|