btcpayserver/BTCPayServer/Data/InvoiceDataExtensions.cs
Andrew Camilleri 6e3d6125c2
Payment Settled Webhook event (#2944)
* Payment Settled Webhook event

resolves #2691

* Move payment methods to payment services
2021-10-05 18:10:41 +09:00

30 lines
992 B
C#

using BTCPayServer.Services.Invoices;
namespace BTCPayServer.Data
{
public static class InvoiceDataExtensions
{
public static InvoiceEntity GetBlob(this Data.InvoiceData invoiceData, BTCPayNetworkProvider networks)
{
var entity = NBitcoin.JsonConverters.Serializer.ToObject<InvoiceEntity>(ZipUtils.Unzip(invoiceData.Blob), null);
entity.Networks = networks;
if (entity.Metadata is null)
{
if (entity.Version < InvoiceEntity.GreenfieldInvoices_Version)
{
entity.MigrateLegacyInvoice();
}
else
{
entity.Metadata = new InvoiceMetadata();
}
}
return entity;
}
public static InvoiceState GetInvoiceState(this InvoiceData invoiceData)
{
return new InvoiceState(invoiceData.Status, invoiceData.ExceptionStatus);
}
}
}