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

ci(cypress): verify existence of `payment_id` after redirection (#7657)

Pa1NarK01bdea783a9c
diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js
index ce2cbb1923..aa73bff78b 100644
--- a/cypress-tests/cypress/support/redirectionHandler.js
+++ b/cypress-tests/cypress/support/redirectionHandler.js
@@ -468,12 +468,24 @@ function verifyReturnUrl(redirectionUrl, expectedUrl, forwardFlow) {
try {
const redirectionHost = new URL(redirectionUrl).host;
const expectedHost = new URL(expectedUrl).host;
- if (redirectionHost.endsWith(expectedHost)) {
- cy.wait(constants.WAIT_TIME / 2);
- cy.window()
- .its("location")
- .then((location) => {
+ cy.window()
+ .its("location")
+ .then((location) => {
+ // Check for payment_id in the URL
+ const urlParams = new URLSearchParams(location.search);
+ const paymentId = urlParams.get("payment_id");
+
+ if (!paymentId) {
+ // eslint-disable-next-line cypress/assertion-before-screenshot
+ cy.screenshot("missing-payment-id-error");
+ throw new Error("URL does not contain payment_id parameter");
+ }
+
+ // Proceed with other verifications based on whether redirection host ends with expected host
+ if (redirectionHost.endsWith(expectedHost)) {
+ cy.wait(constants.WAIT_TIME / 2);
+
// Check page state before taking screenshots
cy.document().then((doc) => {
const pageText = doc.body.innerText.toLowerCase();
@@ -495,7 +507,6 @@ function verifyReturnUrl(redirectionUrl, expectedUrl, forwardFlow) {
}
});
- const urlParams = new URLSearchParams(location.search);
const paymentStatus = urlParams.get("status");
if (
@@ -507,21 +518,21 @@ function verifyReturnUrl(redirectionUrl, expectedUrl, forwardFlow) {
`Redirection failed with payment status: ${paymentStatus}`
);
}
- });
- } else {
- cy.window().its("location.origin").should("eq", expectedUrl);
-
- Cypress.on("uncaught:exception", (err, runnable) => {
- // Log the error details
- // eslint-disable-next-line no-console
- console.error(
- `Error: ${err.message}\nOccurred in: ${runnable.title}\nStack: ${err.stack}`
- );
+ } else {
+ cy.window().its("location.origin").should("eq", expectedUrl);
+
+ Cypress.on("uncaught:exception", (err, runnable) => {
+ // Log the error details
+ // eslint-disable-next-line no-console
+ console.error(
+ `Error: ${err.message}\nOccurred in: ${runnable.title}\nStack: ${err.stack}`
+ );
- // Return false to prevent the error from failing the test
- return false;
+ // Return false to prevent the error from failing the test
+ return false;
+ });
+ }
});
- }
} catch (error) {
throw new Error(`Redirection verification failed: ${error}`);
}