mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Returning whole invoice serialized as JSON on $ajax call
This commit is contained in:
parent
bc28571174
commit
e49f25af09
@ -125,9 +125,18 @@ namespace BTCPayServer.Controllers
|
||||
id = invoiceId;
|
||||
////
|
||||
|
||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
||||
if(invoice == null)
|
||||
var model = await GetInvoiceModel(invoiceId);
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
|
||||
return View(nameof(Checkout), model);
|
||||
}
|
||||
|
||||
private async Task<PaymentModel> GetInvoiceModel(string invoiceId)
|
||||
{
|
||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
||||
if (invoice == null)
|
||||
return null;
|
||||
var store = await _StoreRepository.FindStore(invoice.StoreId);
|
||||
var dto = invoice.EntityToDTO();
|
||||
|
||||
@ -154,11 +163,9 @@ namespace BTCPayServer.Controllers
|
||||
status = invoice.Status
|
||||
};
|
||||
|
||||
|
||||
|
||||
var expiration = TimeSpan.FromSeconds((double)model.expirationSeconds);
|
||||
var expiration = TimeSpan.FromSeconds(model.expirationSeconds);
|
||||
model.TimeLeft = PrettyPrint(expiration);
|
||||
return View(nameof(Checkout), model);
|
||||
return model;
|
||||
}
|
||||
|
||||
private string PrettyPrint(TimeSpan expiration)
|
||||
@ -176,10 +183,10 @@ namespace BTCPayServer.Controllers
|
||||
[Route("i/{invoiceId}/status")]
|
||||
public async Task<IActionResult> GetStatus(string invoiceId)
|
||||
{
|
||||
var invoice = await _InvoiceRepository.GetInvoice(null, invoiceId);
|
||||
if(invoice == null)
|
||||
var model = await GetInvoiceModel(invoiceId);
|
||||
if(model == null)
|
||||
return NotFound();
|
||||
return Content(invoice.Status);
|
||||
return Json(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
@ -158,7 +158,9 @@ $("#copy-tab").click(function () {
|
||||
var oldStat = srvModel.status;
|
||||
onDataCallback(srvModel.status);
|
||||
|
||||
function onDataCallback(newStatus) {
|
||||
function onDataCallback(jsonData) {
|
||||
var newStatus = jsonData.status;
|
||||
|
||||
if (oldStat != newStatus) {
|
||||
oldStat = newStatus;
|
||||
window.parent.postMessage({ "invoiceId": srvModel.invoiceId, "status": newStatus }, "*");
|
||||
@ -206,8 +208,7 @@ var watcher = setInterval(function () {
|
||||
url: path,
|
||||
type: "GET"
|
||||
}).done(function (data) {
|
||||
status = data;
|
||||
onDataCallback(status);
|
||||
onDataCallback(data);
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user