Skip to content

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

fix(core): fix redirection for Worldpay for specific payment IDs (#8027)

Kashifa2d641278a81
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index 3fef01a8c2..4bc57cfdaa 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -1733,7 +1733,7 @@ pub fn build_redirection_form(
(PreEscaped(format!(
r#"
function submitCollectionReference(collectionReference) {{
- var redirectPathname = window.location.pathname.replace(/payments\/redirect\/(\w+)\/(\w+)\/\w+/, "payments/$1/$2/redirect/complete/worldpay");
+ var redirectPathname = window.location.pathname.replace(/payments\/redirect\/([^\/]+)\/([^\/]+)\/[^\/]+/, "payments/$1/$2/redirect/complete/worldpay");
var redirectUrl = window.location.origin + redirectPathname;
try {{
if (typeof collectionReference === "string" && collectionReference.length > 0) {{
@@ -1746,7 +1746,7 @@ pub fn build_redirection_form(
input.value = collectionReference;
form.appendChild(input);
document.body.appendChild(form);
- form.submit();;
+ form.submit();
}} else {{
window.location.replace(redirectUrl);
}}