2020-06-28 10:15:42 +02:00
|
|
|
using BTCPayServer.Services.Invoices;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
|
|
|
public static class PaymentDataExtensions
|
|
|
|
{
|
|
|
|
public static PaymentEntity GetBlob(this Data.PaymentData paymentData, BTCPayNetworkProvider networks)
|
|
|
|
{
|
|
|
|
var unziped = ZipUtils.Unzip(paymentData.Blob);
|
|
|
|
var cryptoCode = "BTC";
|
|
|
|
if (JObject.Parse(unziped).TryGetValue("cryptoCode", out var v) && v.Type == JTokenType.String)
|
|
|
|
cryptoCode = v.Value<string>();
|
|
|
|
var network = networks.GetNetwork<BTCPayNetworkBase>(cryptoCode);
|
|
|
|
PaymentEntity paymentEntity = null;
|
|
|
|
if (network == null)
|
|
|
|
{
|
2020-08-13 09:29:04 +02:00
|
|
|
return null;
|
2020-06-28 10:15:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
paymentEntity = network.ToObject<PaymentEntity>(unziped);
|
|
|
|
}
|
|
|
|
paymentEntity.Network = network;
|
|
|
|
paymentEntity.Accounted = paymentData.Accounted;
|
|
|
|
return paymentEntity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|