Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor: handle redirections for iframed content (#5591)
Kashif1bb8f5e8ebd8
diff --git a/crates/router/src/core/generic_link/payout_link/status/script.js b/crates/router/src/core/generic_link/payout_link/status/script.jsindex aa75676153..473af49b2e 100644--- a/crates/router/src/core/generic_link/payout_link/status/script.js+++ b/crates/router/src/core/generic_link/payout_link/status/script.js@@ -173,7 +173,17 @@ function redirectToEndUrl(returnUrl) {}if (secondsLeft === 0) {setTimeout(function () {- window.location.href = returnUrl.toString();+ try {+ window.top.location.href = returnUrl.toString();+ } catch (error) {+ console.error(+ "CRITICAL ERROR",+ "Failed to redirect top document. Error - ",+ error+ );+ console.info("Redirecting in current document");+ window.location.href = returnUrl.toString();+ }}, 1000);}}, i * 1000);diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.htmlindex b66242305b..54e48a5241 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html@@ -325,10 +325,10 @@</svg></div><script>+ {{logging_template}}{{locale_template}}{{rendered_js}}{{payment_link_initiator}}- {{logging_template}}</script>{{ hyperloader_sdk_link }}</body>diff --git a/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js b/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.jsindex 777cfd8cad..48974a564d 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js+++ b/crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js@@ -57,7 +57,7 @@ if (!isFramed) {});var type =paymentDetails.sdk_layout === "spaced_accordion" ||- paymentDetails.sdk_layout === "accordion"+ paymentDetails.sdk_layout === "accordion"? "accordion": paymentDetails.sdk_layout;@@ -103,6 +103,35 @@ if (!isFramed) {arr.splice(0, 3);arr.unshift("status");arr.unshift("payment_link");- window.location.href = window.location.origin + "/" + arr.join("/")+ "?locale=" + paymentDetails.locale;+ let returnUrl =+ window.location.origin ++ "/" ++ arr.join("/") ++ "?locale=" ++ paymentDetails.locale;+ try {+ window.top.location.href = returnUrl;++ // Push logs to logs endpoint+ } catch (error) {+ var url = window.location.href;+ var { paymentId, merchantId, attemptId, connector } = parseRoute(url);+ var urlToPost = getEnvRoute(url);+ var message = {+ message: "CRITICAL ERROR - Failed to redirect top document. Falling back to redirecting using window.location",+ reason: error.message,+ }+ var log = {+ message,+ url,+ paymentId,+ merchantId,+ attemptId,+ connector,+ };+ postLog(log, urlToPost);++ window.location.href = returnUrl;+ }}}diff --git a/crates/router/src/core/payment_link/payment_link_status/status.html b/crates/router/src/core/payment_link/payment_link_status/status.htmlindex fdc0c3012b..c78a0bb556 100644--- a/crates/router/src/core/payment_link/payment_link_status/status.html+++ b/crates/router/src/core/payment_link/payment_link_status/status.html@@ -11,9 +11,9 @@href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800"/><script>+ {{logging_template}}{{locale_template}}{{ rendered_js }}- {{logging_template}}</script></head><body onload="boot()">