2023-06-22 08:57:29 +02:00
@model BTCPayServer.Models.InvoicingModels.InvoiceReceiptViewModel
@using BTCPayServer.Client.Models
@using BTCPayServer.Components.QRCode
@using BTCPayServer.Services
@inject DisplayFormatter DisplayFormatter
@{
Layout = null;
ViewData["Title"] = $"Receipt from {Model.StoreName}";
var isProcessing = Model.Status == InvoiceStatus.Processing;
2023-11-17 22:45:37 -06:00
var isFreeInvoice = (Model.Status == InvoiceStatus.New && Model.Amount == 0);
2023-06-22 08:57:29 +02:00
var isSettled = Model.Status == InvoiceStatus.Settled;
}
2023-11-23 19:05:08 +01:00
<!DOCTYPE html>
<html lang="en">
2023-11-17 22:45:37 -06:00
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="~/favicon.ico" type="image/x-icon">
<meta name="robots" content="noindex">
<title>@ViewData["Title"]</title>
@* CSS *@
<link href="~/main/bootstrap/bootstrap.css" asp-append-version="true" rel="stylesheet" />
<link href="~/main/fonts/OpenSans.css" asp-append-version="true" rel="stylesheet" />
<link href="~/main/layout.css" asp-append-version="true" rel="stylesheet" />
<link href="~/main/site.css" asp-append-version="true" rel="stylesheet" />
<link href="~/main/themes/default.css" asp-append-version="true" rel="stylesheet" />
<meta name="robots" content="noindex,nofollow">
@if (isProcessing)
{
<script type="text/javascript">
setTimeout(() => { window.location.reload(); }, 10000);
</script>
}
else if (isFreeInvoice)
{
<script type="text/javascript">
setTimeout(() => { window.location.reload(); }, 2000);
</script>
}
<style>
h1 {
margin: 0;
}
2023-06-22 08:57:29 +02:00
2023-11-17 22:45:37 -06:00
.qr-code {
width: 128px;
}
2023-06-22 08:57:29 +02:00
2023-11-17 22:45:37 -06:00
/* change height as you like */
@@media print {
body {
width: 58mm;
margin: 0;
padding: 0;
}
2023-06-22 08:57:29 +02:00
2023-11-17 22:45:37 -06:00
.p-1 {
padding: 1mm !important;
}
2023-06-22 08:57:29 +02:00
2023-11-17 22:45:37 -06:00
.m-1 {
margin: 1mm !important;
}
2023-06-22 08:57:29 +02:00
}
2023-11-17 22:45:37 -06:00
/* this line is needed for fixing Chrome's bug */
@@page {
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
margin-bottom: 0px;
}
</style>
</head>
2023-06-22 08:57:29 +02:00
2023-11-23 19:05:08 +01:00
<body class="m-0 p-0 bg-white">
<center>
2023-12-01 16:13:44 +01:00
<partial name="_StoreHeader" model="(Model.StoreName, Model.StoreBranding)" />
2023-11-23 19:05:08 +01:00
<div id="InvoiceSummary" style="max-width:600px">
@if (isProcessing)
{
<div class="lead text-center fw-semibold" id="invoice-processing">
The invoice has detected a payment but is still waiting to be settled.
</div>
}
else if (!isSettled)
{
<div class="lead text-center fw-semibold" id="invoice-unsettled">
The invoice is not settled.
</div>
}
else
{
2024-04-24 10:22:00 +02:00
var hasCart = Model.CartData?.Any() is true;
2023-11-23 19:05:08 +01:00
<div id="PaymentDetails">
<div class="my-2 text-center small">
@if (!string.IsNullOrEmpty(Model.OrderId))
2023-11-17 22:45:37 -06:00
{
2023-11-23 19:05:08 +01:00
<div>Order ID: @Model.OrderId</div>
2023-11-17 22:45:37 -06:00
}
2023-11-23 19:05:08 +01:00
@Model.Timestamp.ToBrowserDate()
</div>
<table class="table table-borderless table-sm small my-0">
2024-04-24 10:22:00 +02:00
@if (Model.AdditionalData?.Any() is true)
2023-11-17 22:45:37 -06:00
{
2024-04-24 10:22:00 +02:00
@foreach (var (key, value) in Model.AdditionalData)
2023-11-23 19:05:08 +01:00
{
2024-04-24 10:22:00 +02:00
<tr>
<td class="text-secondary">@key</td>
<td class="text-end">@value</td>
</tr>
}
<tr>
<td colspan="2"><hr class="w-100 my-0"/></td>
</tr>
}
@if (hasCart)
{
_ = Model.CartData.TryGetValue("cart", out var cart) || Model.CartData.TryGetValue("Cart", out cart);
var hasTotal = Model.CartData.TryGetValue("total", out var total) || Model.CartData.TryGetValue("Total", out total);
var hasSubtotal = Model.CartData.TryGetValue("subtotal", out var subtotal) || Model.CartData.TryGetValue("subTotal", out subtotal) || Model.CartData.TryGetValue("Subtotal", out subtotal);
var hasDiscount = Model.CartData.TryGetValue("discount", out var discount) || Model.CartData.TryGetValue("Discount", out discount);
var hasTip = Model.CartData.TryGetValue("tip", out var tip) || Model.CartData.TryGetValue("Tip", out tip);
if (cart is Dictionary<string, object> { Keys.Count: > 0 } cartDict)
{
@foreach (var (key, value) in cartDict)
2023-11-23 19:05:08 +01:00
{
<tr>
<td class="text-secondary">@key</td>
<td class="text-end">@value</td>
</tr>
}
}
2024-04-24 10:22:00 +02:00
else if (cart is ICollection<object> { Count: > 0 } cartCollection)
{
@foreach (var value in cartCollection)
{
<tr>
<td class="text-end">@value</td>
</tr>
}
}
if (hasSubtotal && (hasDiscount || hasTip))
2023-11-23 19:05:08 +01:00
{
2024-04-24 10:22:00 +02:00
<tr>
<td colspan="2"><hr class="w-100 my-0"/></td>
</tr>
2023-11-23 19:05:08 +01:00
<tr>
<td class="text-secondary">Subtotal</td>
2024-04-24 10:22:00 +02:00
<td class="text-end">@subtotal</td>
2023-11-23 19:05:08 +01:00
</tr>
}
2024-04-24 10:22:00 +02:00
if (hasDiscount)
2023-11-23 19:05:08 +01:00
{
<tr>
<td class="text-secondary">Discount</td>
2024-04-24 10:22:00 +02:00
<td class="text-end">@discount</td>
2023-11-23 19:05:08 +01:00
</tr>
}
2024-04-24 10:22:00 +02:00
if (hasTip)
2023-11-23 19:05:08 +01:00
{
<tr>
<td class="text-secondary">Tip</td>
2024-04-24 10:22:00 +02:00
<td class="text-end">@tip</td>
</tr>
}
if (hasTotal)
{
<tr>
<td colspan="2"><hr class="w-100 my-0"/></td>
</tr>
<tr>
<th class="text-secondary">Total</th>
<td class="text-end fw-semibold">@total</td>
2023-11-23 19:05:08 +01:00
</tr>
}
2024-04-24 10:22:00 +02:00
}
else
{
2023-11-23 19:05:08 +01:00
<tr>
2024-04-24 10:22:00 +02:00
<td class="text-nowrap text-secondary">Total</td>
<td class="text-end fw-semibold">@DisplayFormatter.Currency(Model.Amount, Model.Currency, DisplayFormatter.CurrencyFormat.Symbol)</td>
2023-11-23 19:05:08 +01:00
</tr>
2023-11-17 22:45:37 -06:00
}
2023-11-23 19:05:08 +01:00
@if (Model.Payments?.Any() is true)
2023-11-17 22:45:37 -06:00
{
2024-04-24 10:22:00 +02:00
<tr>
<td colspan="2"><hr class="w-100 my-0"/></td>
</tr>
2023-11-23 19:05:08 +01:00
@for (var i = 0; i < Model.Payments.Count; i++)
2023-11-17 22:45:37 -06:00
{
2023-11-23 19:05:08 +01:00
var payment = Model.Payments[i];
@if (Model.Payments.Count > 1)
{
<tr>
<td colspan="2" class="text-nowrap text-secondary">Payment @(i + 1)</td>
</tr>
<tr>
<td class="text-nowrap">Received</td>
<td>@payment.ReceivedDate.ToBrowserDate()</td>
</tr>
}
<tr>
<td class="text-nowrap text-secondary">@(Model.Payments.Count == 1 ? "Paid" : "")</td>
<td class="text-end">@payment.AmountFormatted</td>
</tr>
<tr>
<td colspan="2" class="text-end">@payment.PaidFormatted</td>
</tr>
<tr>
<td class="text-nowrap text-secondary">Rate</td>
<td class="text-end">@payment.RateFormatted</td>
</tr>
@if (!string.IsNullOrEmpty(payment.Destination))
{
<tr>
<td class="text-nowrap text-secondary">Destination</td>
2024-03-21 09:30:34 +01:00
<td class="text-break">
@if (payment.Destination.Length > 69)
{
<span>
<span>@payment.Destination[..30]</span>
<span>...</span>
<span>@payment.Destination.Substring(payment.Destination.Length - 30, 30)</span>
</span>
}
else
{
@payment.Destination
}
</td>
2023-11-23 19:05:08 +01:00
</tr>
}
@if (!string.IsNullOrEmpty(payment.PaymentProof))
{
<tr>
<td class="text-nowrap text-secondary">Pay Proof</td>
<td class="text-break">@payment.PaymentProof</td>
</tr>
}
2023-11-17 22:45:37 -06:00
}
2023-11-23 19:05:08 +01:00
<tr>
<td colspan="2"><hr class="w-100 my-0"/></td>
</tr>
2023-11-17 22:45:37 -06:00
}
2023-11-23 19:05:08 +01:00
</table>
2023-11-17 22:45:37 -06:00
</div>
2023-11-23 19:05:08 +01:00
if (Model.ReceiptOptions.ShowQR is true)
{
<vc:qr-code data="@Context.Request.GetCurrentUrl()" size="128" />
}
}
</div>
<div class="store-footer p-3">
<a class="store-powered-by" style="color:#000;">Powered by <partial name="_StoreFooterLogo" /></a>
</div>
<hr class="w-100 my-0 bg-none"/>
</center>
2023-11-17 22:45:37 -06:00
</body>
2024-04-24 10:22:00 +02:00
<script src="~/main/utils.js" asp-append-version="true"></script>
2023-11-17 22:45:37 -06:00
<script>
2024-04-24 10:22:00 +02:00
formatDateTimes();
2023-11-17 22:45:37 -06:00
window.print();
</script>
2023-11-23 19:05:08 +01:00
</html>