btcpayserver/BTCPayServer/Services/Invoices/PaymentBlob.cs
2024-09-17 17:28:58 +09:00

29 lines
932 B
C#

using BTCPayServer.JsonConverters;
using BTCPayServer.Payments;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Services.Invoices
{
public class PaymentBlob
{
public int Version { get; set; } = 2;
[JsonConverter(typeof(NumericStringJsonConverter))]
public decimal PaymentMethodFee { get; set; }
public string Destination { get; set; }
public JToken Details { get; set; }
public int Divisibility { get; set; }
public PaymentBlob SetDetails(IPaymentMethodHandler handler, object details)
{
Details = JToken.FromObject(details, handler.Serializer);
return this;
}
public T GetDetails<T>(IPaymentMethodHandler handler) where T : class
{
if (handler.Id != handler.Id)
return null;
return handler.ParsePaymentDetails(Details) as T;
}
}
}