mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-28 16:58:00 +01:00
27 lines
881 B
C#
27 lines
881 B
C#
using System.Linq;
|
|
using System.Text;
|
|
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, Payments.PaymentMethodId paymentId)
|
|
{
|
|
return data.GetBlob().SupportedPaymentMethods.Contains(paymentId);
|
|
}
|
|
}
|
|
}
|