mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Invoice: Improve zero amount invoice handling (#6199)
This is for the checkout page to properly redirect paid invoices with no payment methods (e.g. free invoices with zero amount) to either the receipt page or redirect URL. Only fall back to 404 if there is neither. Fixes #6123.
This commit is contained in:
@@ -199,16 +199,13 @@ namespace BTCPayServer.Controllers
|
||||
return NotFound();
|
||||
|
||||
var receipt = InvoiceDataBase.ReceiptOptions.Merge(store.GetStoreBlob().ReceiptOptions, i.ReceiptOptions);
|
||||
|
||||
if (receipt.Enabled is not true)
|
||||
{
|
||||
if (i.RedirectURL is not null)
|
||||
{
|
||||
return Redirect(i.RedirectURL.ToString());
|
||||
}
|
||||
return NotFound();
|
||||
|
||||
return i.RedirectURL is not null
|
||||
? Redirect(i.RedirectURL.ToString())
|
||||
: NotFound();
|
||||
}
|
||||
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
var vm = new InvoiceReceiptViewModel
|
||||
{
|
||||
@@ -699,7 +696,16 @@ namespace BTCPayServer.Controllers
|
||||
|
||||
var model = await GetInvoiceModel(invoiceId, paymentMethodId == null ? null : PaymentMethodId.Parse(paymentMethodId), lang);
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
{
|
||||
// see if the invoice actually exists and is in a state for which we do not display the checkout
|
||||
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||
var store = invoice != null ? await _StoreRepository.GetStoreByInvoiceId(invoice.Id) : null;
|
||||
var receipt = invoice != null && store != null ? InvoiceDataBase.ReceiptOptions.Merge(store.GetStoreBlob().ReceiptOptions, invoice.ReceiptOptions) : null;
|
||||
var redirectUrl = invoice?.RedirectURL?.ToString();
|
||||
return receipt?.Enabled is true
|
||||
? RedirectToAction(nameof(InvoiceReceipt), new { invoiceId })
|
||||
: !string.IsNullOrEmpty(redirectUrl) ? Redirect(redirectUrl) : NotFound();
|
||||
}
|
||||
|
||||
if (view == "modal")
|
||||
model.IsModal = true;
|
||||
|
||||
Reference in New Issue
Block a user