summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/request_payment.en.must13
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c57
2 files changed, 47 insertions, 23 deletions
diff --git a/contrib/request_payment.en.must b/contrib/request_payment.en.must
index 56063cbb..048f6de2 100644
--- a/contrib/request_payment.en.must
+++ b/contrib/request_payment.en.must
@@ -90,8 +90,8 @@ body {
<body>
<script>
+ let delayMs = 60000;
let checkUrl = "{{order_status_url}}";
- let delayMs = 500;
function check() {
let req = new XMLHttpRequest();
req.onreadystatechange = function () {
@@ -106,12 +106,23 @@ body {
console.error("could not parse response:", e);
}
}
+ if (req.status === 302) {
+ try {
+ document.location.reload(true);
+ } catch (e) {
+ console.error("could not parse response:", e);
+ }
+ }
setTimeout(check, delayMs);
}
};
req.onerror = function () {
setTimeout(check, delayMs);
}
+ req.ontimeout = function () {
+ setTimeout(check, delayMs);
+ }
+ req.timeout = delayMs;
req.open("GET", checkUrl);
req.send();
}
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 732e3cfc..ba92316c 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -1157,30 +1157,43 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
if ( (! token_match) &&
(! contract_match) )
{
- /* Contract was claimed (maybe by another device), so this client
- cannot get the status information. Redirect to fulfillment page,
- where the client may be able to pickup a fresh order -- or might
- be able authenticate via session ID */
- struct MHD_Response *reply;
- MHD_RESULT ret;
-
- reply = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
- if (NULL == reply)
+ if (god->generate_html)
{
- GNUNET_break (0);
- return MHD_NO;
+ /* Contract was claimed (maybe by another device), so this client
+ cannot get the status information. Redirect to fulfillment page,
+ where the client may be able to pickup a fresh order -- or might
+ be able authenticate via session ID */
+ struct MHD_Response *reply;
+ MHD_RESULT ret;
+
+ reply = MHD_create_response_from_buffer (0,
+ NULL,
+ MHD_RESPMEM_PERSISTENT);
+ if (NULL == reply)
+ {
+ GNUNET_break (0);
+ return MHD_NO;
+ }
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (reply,
+ MHD_HTTP_HEADER_LOCATION,
+ god->fulfillment_url));
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_FOUND,
+ reply);
+ MHD_destroy_response (reply);
+ return ret;
+ }
+ else
+ {
+ /* Need to generate JSON reply */
+ return TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_ACCEPTED,
+ "{s:s}",
+ "fulfillment_url",
+ god->fulfillment_url);
}
- GNUNET_break (MHD_YES ==
- MHD_add_response_header (reply,
- MHD_HTTP_HEADER_LOCATION,
- god->fulfillment_url));
- ret = MHD_queue_response (connection,
- MHD_HTTP_FOUND,
- reply);
- MHD_destroy_response (reply);
- return ret;
}
} /* end of first-time initialization / sanity checks */