mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-20 15:34:24 +01:00
Greenfield: Improve invoice receipt (#6483)
Assembles and provides the same data as the UIInvoiceController. Merging the invoice's receipt options with the store ones was missing in Greenfield.
This commit is contained in:
@@ -12,10 +12,8 @@ using BTCPayServer.Client.Models;
|
|||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.HostedServices;
|
using BTCPayServer.HostedServices;
|
||||||
using BTCPayServer.Payments;
|
using BTCPayServer.Payments;
|
||||||
using BTCPayServer.Payments.Bitcoin;
|
|
||||||
using BTCPayServer.Payouts;
|
using BTCPayServer.Payouts;
|
||||||
using BTCPayServer.Rating;
|
using BTCPayServer.Rating;
|
||||||
using BTCPayServer.Security;
|
|
||||||
using BTCPayServer.Security.Greenfield;
|
using BTCPayServer.Security.Greenfield;
|
||||||
using BTCPayServer.Services;
|
using BTCPayServer.Services;
|
||||||
using BTCPayServer.Services.Invoices;
|
using BTCPayServer.Services.Invoices;
|
||||||
@@ -25,9 +23,6 @@ using Microsoft.AspNetCore.Cors;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
||||||
using NBitcoin;
|
|
||||||
using NBitpayClient;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using CreateInvoiceRequest = BTCPayServer.Client.Models.CreateInvoiceRequest;
|
using CreateInvoiceRequest = BTCPayServer.Client.Models.CreateInvoiceRequest;
|
||||||
using InvoiceData = BTCPayServer.Client.Models.InvoiceData;
|
using InvoiceData = BTCPayServer.Client.Models.InvoiceData;
|
||||||
@@ -600,12 +595,13 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
{
|
{
|
||||||
statuses.Add(InvoiceStatus.Settled);
|
statuses.Add(InvoiceStatus.Settled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.CanMarkInvalid())
|
if (state.CanMarkInvalid())
|
||||||
{
|
{
|
||||||
statuses.Add(InvoiceStatus.Invalid);
|
statuses.Add(InvoiceStatus.Invalid);
|
||||||
}
|
}
|
||||||
return new InvoiceData()
|
var store = request?.HttpContext.GetStoreData();
|
||||||
|
var receipt = store == null ? entity.ReceiptOptions : InvoiceDataBase.ReceiptOptions.Merge(store.GetStoreBlob().ReceiptOptions, entity.ReceiptOptions);
|
||||||
|
return new InvoiceData
|
||||||
{
|
{
|
||||||
StoreId = entity.StoreId,
|
StoreId = entity.StoreId,
|
||||||
ExpirationTime = entity.ExpirationTime,
|
ExpirationTime = entity.ExpirationTime,
|
||||||
@@ -621,7 +617,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
Archived = entity.Archived,
|
Archived = entity.Archived,
|
||||||
Metadata = entity.Metadata.ToJObject(),
|
Metadata = entity.Metadata.ToJObject(),
|
||||||
AvailableStatusesForManualMarking = statuses.ToArray(),
|
AvailableStatusesForManualMarking = statuses.ToArray(),
|
||||||
Checkout = new CreateInvoiceRequest.CheckoutOptions()
|
Checkout = new InvoiceDataBase.CheckoutOptions
|
||||||
{
|
{
|
||||||
Expiration = entity.ExpirationTime - entity.InvoiceTime,
|
Expiration = entity.ExpirationTime - entity.InvoiceTime,
|
||||||
Monitoring = entity.MonitoringExpiration - entity.ExpirationTime,
|
Monitoring = entity.MonitoringExpiration - entity.ExpirationTime,
|
||||||
@@ -634,7 +630,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
RedirectAutomatically = entity.RedirectAutomatically,
|
RedirectAutomatically = entity.RedirectAutomatically,
|
||||||
RedirectURL = entity.RedirectURLTemplate
|
RedirectURL = entity.RedirectURLTemplate
|
||||||
},
|
},
|
||||||
Receipt = entity.ReceiptOptions
|
Receipt = receipt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user