Receipt page fixes (#6079)

* Receipt: Don't assign empty values to data; hide present empty values
* Receipt: Use same URL on "Return to Store" link as on invoice
This commit is contained in:
d11n 2024-07-09 16:56:34 +02:00 committed by Dennis Reimann
parent b5ad5a5f6f
commit ddb07a7ba9
No known key found for this signature in database
GPG Key ID: 5009E1797F03F8D0
4 changed files with 11 additions and 11 deletions

View File

@ -214,7 +214,7 @@ namespace BTCPayServer.Controllers
{
InvoiceId = i.Id,
OrderId = i.Metadata?.OrderId,
OrderUrl = i.Metadata?.OrderUrl,
RedirectUrl = i.RedirectURL?.AbsoluteUri ?? i.Metadata?.OrderUrl,
Status = i.Status,
Currency = i.Currency,
Timestamp = i.InvoiceTime,
@ -250,10 +250,12 @@ namespace BTCPayServer.Controllers
receiptData.Remove(key);
}
}
// assign the rest to additional data
// assign the rest to additional data and remove empty values
if (receiptData.Any())
{
vm.AdditionalData = receiptData;
vm.AdditionalData = receiptData
.Where(x => !string.IsNullOrEmpty(x.Value.ToString()))
.ToDictionary(x => x.Key, x => x.Value);
}
}

View File

@ -20,6 +20,6 @@ namespace BTCPayServer.Models.InvoicingModels
public Dictionary<string, object> CartData { get; set; }
public ReceiptOptions ReceiptOptions { get; set; }
public List<ViewPaymentRequestViewModel.PaymentRequestInvoicePayment> Payments { get; set; }
public string OrderUrl { get; set; }
public string RedirectUrl { get; set; }
}
}

View File

@ -348,11 +348,9 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
var receiptData = new JObject();
if (choice is not null)
{
receiptData = JObject.FromObject(new Dictionary<string, string>
{
{"Title", choice.Title},
{"Description", choice.Description},
});
var dict = new Dictionary<string, string> { { "Title", choice.Title } };
if (!string.IsNullOrEmpty(choice.Description)) dict["Description"] = choice.Description;
receiptData = JObject.FromObject(dict);
}
else if (jposData is not null)
{

View File

@ -173,9 +173,9 @@
</div>
}
}
@if (!string.IsNullOrEmpty(Model.OrderUrl))
@if (!string.IsNullOrEmpty(Model.RedirectUrl))
{
<a href="@Model.OrderUrl" class="btn btn-secondary rounded-pill mx-auto mt-3" rel="noreferrer noopener" target="_blank">Return to @(string.IsNullOrEmpty(Model.StoreName) ? "store" : Model.StoreName)</a>
<a href="@Model.RedirectUrl" class="btn btn-secondary rounded-pill mx-auto mt-3" rel="noreferrer noopener" target="_blank">Return to @(string.IsNullOrEmpty(Model.StoreName) ? "store" : Model.StoreName)</a>
}
</div>
</main>