mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
refactor: handle redirections for iframed content (#5591)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -173,7 +173,17 @@ function redirectToEndUrl(returnUrl) {
|
|||||||
}
|
}
|
||||||
if (secondsLeft === 0) {
|
if (secondsLeft === 0) {
|
||||||
setTimeout(function () {
|
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);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}, i * 1000);
|
}, i * 1000);
|
||||||
|
|||||||
@ -325,10 +325,10 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
{{logging_template}}
|
||||||
{{locale_template}}
|
{{locale_template}}
|
||||||
{{rendered_js}}
|
{{rendered_js}}
|
||||||
{{payment_link_initiator}}
|
{{payment_link_initiator}}
|
||||||
{{logging_template}}
|
|
||||||
</script>
|
</script>
|
||||||
{{ hyperloader_sdk_link }}
|
{{ hyperloader_sdk_link }}
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -57,7 +57,7 @@ if (!isFramed) {
|
|||||||
});
|
});
|
||||||
var type =
|
var type =
|
||||||
paymentDetails.sdk_layout === "spaced_accordion" ||
|
paymentDetails.sdk_layout === "spaced_accordion" ||
|
||||||
paymentDetails.sdk_layout === "accordion"
|
paymentDetails.sdk_layout === "accordion"
|
||||||
? "accordion"
|
? "accordion"
|
||||||
: paymentDetails.sdk_layout;
|
: paymentDetails.sdk_layout;
|
||||||
|
|
||||||
@ -103,6 +103,35 @@ if (!isFramed) {
|
|||||||
arr.splice(0, 3);
|
arr.splice(0, 3);
|
||||||
arr.unshift("status");
|
arr.unshift("status");
|
||||||
arr.unshift("payment_link");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,9 +11,9 @@
|
|||||||
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800"
|
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800"
|
||||||
/>
|
/>
|
||||||
<script>
|
<script>
|
||||||
|
{{logging_template}}
|
||||||
{{locale_template}}
|
{{locale_template}}
|
||||||
{{ rendered_js }}
|
{{ rendered_js }}
|
||||||
{{logging_template}}
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="boot()">
|
<body onload="boot()">
|
||||||
|
|||||||
Reference in New Issue
Block a user