btcpayserver/BTCPayServer/Payments/PaymentMethodExtensions.cs

26 lines
739 B
C#
Raw Normal View History

2020-06-29 04:44:35 +02:00
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Payments
{
public class PaymentMethodExtensions
{
public static JToken Serialize(ISupportedPaymentMethod factory)
{
// Legacy
if (factory.PaymentId.PaymentType == PaymentTypes.BTCLike)
{
var derivation = (DerivationSchemeSettings)factory;
var str = derivation.Network.NBXplorerNetwork.Serializer.ToString(derivation);
return JObject.Parse(str);
}
//////////////
else
{
var str = JsonConvert.SerializeObject(factory);
return JObject.Parse(str);
}
}
}
}