make free invoices from pos redirect to receipt and make receipt reload fast on such case

This commit is contained in:
Kukks 2023-05-30 10:04:23 +02:00
parent 8cb06f9c6c
commit 79836ef1de
No known key found for this signature in database
GPG key ID: 8E5530D9D1C93097
2 changed files with 12 additions and 1 deletions

View file

@ -240,6 +240,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
} }
var store = await _appService.GetStore(app); var store = await _appService.GetStore(app);
var storeBlob = store.GetStoreBlob();
var posFormId = settings.FormId; var posFormId = settings.FormId;
var formData = await FormDataService.GetForm(posFormId); var formData = await FormDataService.GetForm(posFormId);
@ -297,7 +298,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
RedirectAutomatically = settings.RedirectAutomatically, RedirectAutomatically = settings.RedirectAutomatically,
SupportedTransactionCurrencies = paymentMethods, SupportedTransactionCurrencies = paymentMethods,
RequiresRefundEmail = requiresRefundEmail == RequiresRefundEmail.InheritFromStore RequiresRefundEmail = requiresRefundEmail == RequiresRefundEmail.InheritFromStore
? store.GetStoreBlob().RequiresRefundEmail ? storeBlob.RequiresRefundEmail
: requiresRefundEmail == RequiresRefundEmail.On, : requiresRefundEmail == RequiresRefundEmail.On,
}, store, HttpContext.Request.GetAbsoluteRoot(), }, store, HttpContext.Request.GetAbsoluteRoot(),
new List<string> { AppService.GetAppInternalTag(appId) }, new List<string> { AppService.GetAppInternalTag(appId) },
@ -355,6 +356,10 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
meta.Merge(formResponseJObject); meta.Merge(formResponseJObject);
entity.Metadata = InvoiceMetadata.FromJObject(meta); entity.Metadata = InvoiceMetadata.FromJObject(meta);
}); });
if (price is 0 && storeBlob.ReceiptOptions.Enabled is true)
{
return RedirectToAction(nameof(UIInvoiceController.InvoiceReceipt), "UIInvoice", new { invoiceId = invoice.Data.Id });
}
return RedirectToAction(nameof(UIInvoiceController.Checkout), "UIInvoice", new { invoiceId = invoice.Data.Id }); return RedirectToAction(nameof(UIInvoiceController.Checkout), "UIInvoice", new { invoiceId = invoice.Data.Id });
} }
catch (BitpayHttpException e) catch (BitpayHttpException e)

View file

@ -12,6 +12,7 @@
Layout = null; Layout = null;
ViewData["Title"] = $"Receipt from {Model.StoreName}"; ViewData["Title"] = $"Receipt from {Model.StoreName}";
var isProcessing = Model.Status == InvoiceStatus.Processing; var isProcessing = Model.Status == InvoiceStatus.Processing;
var isFreeInvoice = (Model.Status == InvoiceStatus.New && Model.Amount == 0);
var isSettled = Model.Status == InvoiceStatus.Settled; var isSettled = Model.Status == InvoiceStatus.Settled;
} }
<!DOCTYPE html> <!DOCTYPE html>
@ -25,6 +26,11 @@
<script type="text/javascript"> <script type="text/javascript">
setTimeout(() => { window.location.reload(); }, 10000); setTimeout(() => { window.location.reload(); }, 10000);
</script> </script>
}else if (isFreeInvoice)
{
<script type="text/javascript">
setTimeout(() => { window.location.reload(); }, 2000);
</script>
} }
<style> <style>
#InvoiceSummary { gap: var(--btcpay-space-l); } #InvoiceSummary { gap: var(--btcpay-space-l); }