diff --git a/payments/types.py b/payments/types.py
index 49425bf0..04d3091b 100644
--- a/payments/types.py
+++ b/payments/types.py
@@ -142,6 +142,7 @@ class Proceeded:
class ActionAfterProcessed:
href: str
label: str
+ redirect_after_milliseconds: int | None = None
@dataclass
diff --git a/payments/www/pay.html b/payments/www/pay.html
index 48dbd95c..bb4fabe6 100644
--- a/payments/www/pay.html
+++ b/payments/www/pay.html
@@ -89,6 +89,7 @@
class='btn btn-primary btn-sm btn-block'
style='display: none;'
>
+
{{ _("Redirecting in") }} 10 {{ _("seconds") }}
{{ gateway_wrapper }}
{% endif %}
diff --git a/payments/www/pay.js b/payments/www/pay.js
index 2128752f..7c914731 100644
--- a/payments/www/pay.js
+++ b/payments/www/pay.js
@@ -66,5 +66,20 @@ $(document).on("payment-processed", function (e, r) {
cta.attr("href", r.message.action.href)
cta.toggle(true)
cta.focus()
+ if (r.message.action.redirect_after_milliseconds) {
+ const message = $("#action-redirect-message");
+ const secondsCounter = $("#action-redirect-message-seconds");
+ let seconds = Math.floor(r.message.action.redirect_after_milliseconds / 1000);
+ secondsCounter.html(seconds);
+ function updateCounter() {
+ seconds--;
+ secondsCounter.html(seconds);
+ }
+ message.toggle(true)
+ setInterval(updateCounter, 1000);
+ setTimeout(function() {
+ window.location.href = r.message.action.href
+ }, r.message.action.redirect_after_milliseconds);
+ }
}
})