btcpayserver/BTCPayServer/Data/PullPayments/PullPaymentsExtensions.cs
2024-05-01 10:22:07 +09:00

28 lines
899 B
C#

using System.Linq;
using System.Text;
using BTCPayServer.Payouts;
using NBitcoin.JsonConverters;
using Newtonsoft.Json;
namespace BTCPayServer.Data
{
public static class PullPaymentsExtensions
{
public static PullPaymentBlob GetBlob(this PullPaymentData data)
{
var result = JsonConvert.DeserializeObject<PullPaymentBlob>(data.Blob);
result!.SupportedPaymentMethods = result.SupportedPaymentMethods.Where(id => id is not null).ToArray();
return result;
}
public static void SetBlob(this PullPaymentData data, PullPaymentBlob blob)
{
data.Blob = JsonConvert.SerializeObject(blob).ToString();
}
public static bool IsSupported(this PullPaymentData data, PayoutMethodId paymentId)
{
return data.GetBlob().SupportedPaymentMethods.Contains(paymentId);
}
}
}