Adding support for noscript invoices

This commit is contained in:
rockstardev 2019-03-31 13:46:38 -05:00
parent 320826a4b9
commit e8b71f36b2
4 changed files with 71 additions and 5 deletions

View File

@ -188,7 +188,7 @@ namespace BTCPayServer.Controllers
//Keep compatibility with Bitpay
invoiceId = invoiceId ?? id;
id = invoiceId;
////
//
var model = await GetInvoiceModel(invoiceId, paymentMethodId == null ? null : PaymentMethodId.Parse(paymentMethodId));
if (model == null)
@ -213,6 +213,23 @@ namespace BTCPayServer.Controllers
return View(nameof(Checkout), model);
}
[HttpGet]
[Route("invoice-noscript")]
public async Task<IActionResult> CheckoutNoScript(string invoiceId, string id = null, string paymentMethodId = null)
{
//Keep compatibility with Bitpay
invoiceId = invoiceId ?? id;
id = invoiceId;
//
var model = await GetInvoiceModel(invoiceId, paymentMethodId == null ? null : PaymentMethodId.Parse(paymentMethodId));
if (model == null)
return NotFound();
return View(nameof(CheckoutNoScript), model);
}
private async Task<PaymentModel> GetInvoiceModel(string invoiceId, PaymentMethodId paymentMethodId)
{
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);

View File

@ -51,9 +51,9 @@
<p>Alternatively, click below to continue to our HTML-only invoice.</p>
<form action="/invoice-noscript" method="GET">
<button style="text-decoration: underline; color: blue">Continue to javascript-disabled invoice &gt;</button>
</form>
<a href="/invoice-noscript?id=@Model.InvoiceId" style="text-decoration: underline; color: blue">
Continue to javascript-disabled invoice &gt;
</a>
</center>
</noscript>

View File

@ -0,0 +1,49 @@
@model PaymentModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<META NAME="robots" CONTENT="noindex,nofollow">
<title>@Model.HtmlTitle</title>
</head>
<body>
<h1>Pay with @Model.StoreName</h1>
@if (Model.Status == "new")
{
<div>
<p>To complete payment, please send <b>@Model.BtcDue @Model.CryptoCode</b> to <b>@Model.BtcAddress</b></p>
<p>Time remaining: @Model.TimeLeft</p>
<p><a href="@Model.InvoiceBitcoinUrl">@Model.InvoiceBitcoinUrl</a></p>
</div>
}
else if (Model.Status == "paid" || Model.Status == "complete" || Model.Status == "confirmed")
{
<div>
<p>This invoice has been paid</p>
</div>
}
else if (Model.Status == "expired" || Model.Status == "invalid")
{
<div>
<p>This invoice has expired</p>
</div>
}
else
{
<div>
<p>Non-supported state of invoice</p>
</div>
}
<hr />
<p>
<a href="/i/@Model.InvoiceId">Go back to Javascript enabled invoice</a>
</p>
</body>
</html>

View File

@ -11513,7 +11513,7 @@ low-fee-timeline {
}
[v-cloak] > * { display:none }
[v-cloak]::before { content: "loading…" }
[v-cloak]::before { content: "" }
.btn-link {