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
chore: bump cypress to `v14.0.0` (#7102)
Pa1NarK0e9966a54d87
diff --git a/cypress-tests/cypress.config.js b/cypress-tests/cypress.config.jsindex 913663c509..dce9048339 100644--- a/cypress-tests/cypress.config.js+++ b/cypress-tests/cypress.config.js@@ -30,14 +30,27 @@ export default defineConfig({},});on("after:spec", (spec, results) => {- if (results && results.video) {- // Do we have failures for any retry attempts?- const failures = results.tests.some((test) =>+ // Clean up resources after each spec+ if (+ results &&+ results.video &&+ !results.tests.some((test) =>test.attempts.some((attempt) => attempt.state === "failed")- );- if (!failures) {- // delete the video if the spec passed and no tests retried- fs.unlinkSync(results.video);+ )+ ) {+ // Only try to delete if the video file exists+ try {+ if (fs.existsSync(results.video)) {+ fs.unlinkSync(results.video);+ }+ } catch (error) {+ // Log the error but don't fail the test+ // eslint-disable-next-line no-console+ console.warn(+ `Warning: Could not delete video file: ${results.video}`+ );+ // eslint-disable-next-line no-console+ console.warn(error);}}});@@ -45,6 +58,9 @@ export default defineConfig({},experimentalRunAllSpecs: true,+ specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",+ supportFile: "cypress/support/e2e.js",+reporter: "cypress-mochawesome-reporter",reporterOptions: {reportDir: `cypress/reports/${connectorId}`,@@ -55,12 +71,13 @@ export default defineConfig({inlineAssets: true,saveJson: true,},+ defaultCommandTimeout: 10000,+ pageLoadTimeout: 20000,+ responseTimeout: 30000,+ screenshotsFolder: screenshotsFolderName,+ video: true,+ videoCompression: 32,+ videosFolder: `cypress/videos/${connectorId}`,+ chromeWebSecurity: false,},- chromeWebSecurity: false,- defaultCommandTimeout: 10000,- pageLoadTimeout: 20000,- responseTimeout: 30000,- screenshotsFolder: screenshotsFolderName,- video: true,- videoCompression: 32,});diff --git a/cypress-tests/cypress/e2e/configs/Payment/Nmi.js b/cypress-tests/cypress/e2e/configs/Payment/Nmi.jsindex 8ad218953d..e8cdd97e7a 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Nmi.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Nmi.js@@ -163,7 +163,9 @@ export const connectorDetails = {},},Void: {- Request: {},+ Request: {+ cancellation_reason: "user_cancel",+ },Response: {status: 200,body: {@@ -172,16 +174,13 @@ export const connectorDetails = {},},VoidAfterConfirm: {- Request: {},+ Request: {+ cancellation_reason: "user_cancel",+ },Response: {- status: 400,+ status: 200,body: {- error: {- code: "IR_16",- message:- "You cannot cancel this payment because it has status processing",- type: "invalid_request",- },+ status: "processing",},},},diff --git a/cypress-tests/cypress/e2e/configs/Payment/Stripe.js b/cypress-tests/cypress/e2e/configs/Payment/Stripe.jsindex d4d3c30fe2..b73bbf18dc 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Stripe.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Stripe.js@@ -23,7 +23,7 @@ const successfulThreeDSTestCardDetails = {const failedNo3DSCardDetails = {card_number: "4000000000000002",card_exp_month: "01",- card_exp_year: "25",+ card_exp_year: "35",card_holder_name: "joseph Doe",card_cvc: "123",};@@ -123,7 +123,7 @@ const requiredFields = {export const connectorDetails = {multi_credential_config: {- specName: ["connectorAgnostic"],+ specName: ["connectorAgnosticNTID"],value: "connector_2",},card_pm: {@@ -144,7 +144,7 @@ export const connectorDetails = {PaymentIntentOffSession: {Configs: {CONNECTOR_CREDENTIAL: {- specName: ["connectorAgnostic"],+ specName: ["connectorAgnosticNTID"],value: "connector_2",},},@@ -564,7 +564,7 @@ export const connectorDetails = {MITAutoCapture: getCustomExchange({Configs: {CONNECTOR_CREDENTIAL: {- specName: ["connectorAgnostic"],+ specName: ["connectorAgnosticNTID"],value: "connector_2",},},@@ -701,7 +701,7 @@ export const connectorDetails = {SaveCardUseNo3DSAutoCaptureOffSession: {Configs: {CONNECTOR_CREDENTIAL: {- specName: ["connectorAgnostic"],+ specName: ["connectorAgnosticNTID"],value: "connector_2",},},@@ -754,7 +754,7 @@ export const connectorDetails = {SaveCardConfirmAutoCaptureOffSession: {Configs: {CONNECTOR_CREDENTIAL: {- specName: ["connectorAgnostic"],+ specName: ["connectorAgnosticNTID"],value: "connector_2",},},diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex c35e5950b7..5a9baa32d7 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -4,10 +4,8 @@ import { connectorDetails as adyenConnectorDetails } from "./Adyen.js";import { connectorDetails as bankOfAmericaConnectorDetails } from "./BankOfAmerica.js";import { connectorDetails as bluesnapConnectorDetails } from "./Bluesnap.js";import { connectorDetails as checkoutConnectorDetails } from "./Checkout.js";-import {- connectorDetails as CommonConnectorDetails,- updateDefaultStatusCode,-} from "./Commons.js";+import { connectorDetails as CommonConnectorDetails } from "./Commons.js";+import { updateDefaultStatusCode } from "./Modifiers.js";import { connectorDetails as cybersourceConnectorDetails } from "./Cybersource.js";import { connectorDetails as datatransConnectorDetails } from "./Datatrans.js";import { connectorDetails as elavonConnectorDetails } from "./Elavon.js";@@ -227,12 +225,10 @@ function getConnectorConfig(const mcaConfig = getConnectorDetails(globalState.get("connectorId"));return {- config: {- CONNECTOR_CREDENTIAL:- multipleConnector?.nextConnector && multipleConnectors?.status- ? multipleConnector- : mcaConfig?.multi_credential_config || multipleConnector,- },+ CONNECTOR_CREDENTIAL:+ multipleConnector?.nextConnector && multipleConnectors?.status+ ? multipleConnector+ : mcaConfig?.multi_credential_config || multipleConnector,multipleConnectors,};}@@ -243,13 +239,12 @@ export function createBusinessProfile(globalState,multipleConnector = { nextConnector: false }) {- const { config, multipleConnectors } = getConnectorConfig(- globalState,- multipleConnector- );+ const config = getConnectorConfig(globalState, multipleConnector);const { profilePrefix } = execConfig(config);- if (shouldProceedWithOperation(multipleConnector, multipleConnectors)) {+ if (+ shouldProceedWithOperation(multipleConnector, config.multipleConnectors)+ ) {cy.createBusinessProfileTest(createBusinessProfileBody,globalState,@@ -266,13 +261,12 @@ export function createMerchantConnectorAccount(paymentMethodsEnabled,multipleConnector = { nextConnector: false }) {- const { config, multipleConnectors } = getConnectorConfig(- globalState,- multipleConnector- );+ const config = getConnectorConfig(globalState, multipleConnector);const { profilePrefix, merchantConnectorPrefix } = execConfig(config);- if (shouldProceedWithOperation(multipleConnector, multipleConnectors)) {+ if (+ shouldProceedWithOperation(multipleConnector, config.multipleConnectors)+ ) {cy.createConnectorCallTest(paymentType,createMerchantConnectorAccountBody,diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 60691899f7..45be704311 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -620,7 +620,6 @@ Cypress.Commands.add();if (stateUpdate) {- // cy.task("setGlobalState", stateUpdate);globalState.set("MULTIPLE_CONNECTORS",stateUpdate.MULTIPLE_CONNECTORS@@ -2202,13 +2201,19 @@ Cypress.Commands.add();Cypress.Commands.add("voidCallTest", (requestBody, data, globalState) => {- const { Configs: configs = {}, Response: resData } = data || {};+ const {+ Configs: configs = {},+ Response: resData,+ Request: reqData,+ } = data || {};const configInfo = execConfig(validateConfig(configs));const payment_id = globalState.get("paymentID");const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);requestBody.profile_id = profile_id;+ requestBody.cancellation_reason =+ reqData?.cancellation_reason ?? requestBody.cancellation_reason;cy.request({method: "POST",diff --git a/cypress-tests/cypress/support/e2e.js b/cypress-tests/cypress/support/e2e.jsindex eab7b99b62..1ec43cd03b 100644--- a/cypress-tests/cypress/support/e2e.js+++ b/cypress-tests/cypress/support/e2e.js@@ -16,12 +16,22 @@// Import commands.js using ES2015 syntax:import "cypress-mochawesome-reporter/register";import "./commands";+import "./redirectionHandler";++Cypress.on("window:before:load", (win) => {+ // Add security headers+ win.headers = {+ "Content-Security-Policy": "default-src 'self'",+ "X-Content-Type-Options": "nosniff",+ "X-Frame-Options": "DENY",+ };+});// Add error handling for dynamic importsCypress.on("uncaught:exception", (err, runnable) => {// Log the error details// eslint-disable-next-line no-console- console.log(+ console.error(`Error: ${err.message}\nError occurred in: ${runnable.title}\nStack trace: ${err.stack}`);diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex cc9c180b35..d840aab9e4 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -3,23 +3,38 @@import jsQR from "jsqr";// Define constants for wait times-const TIMEOUT = 20000; // 20 seconds-const WAIT_TIME = 10000; // 10 seconds+const CONSTANTS = {+ TIMEOUT: 20000, // 20 seconds+ WAIT_TIME: 10000, // 10 seconds+ ERROR_PATTERNS: [+ /4\d{2}/,+ /5\d{2}/,+ /error/i,+ /invalid request/i,+ /server error/i,+ ],+ VALID_TERMINAL_STATUSES: [+ "failed",+ "processing",+ "requires_capture",+ "succeeded",+ ],+};export function handleRedirection(- redirection_type,+ redirectionType,urls,connectorId,- payment_method_type,- handler_metadata+ paymentMethodType,+ handlerMetadata) {- switch (redirection_type) {+ switch (redirectionType) {case "bank_redirect":bankRedirectRedirection(urls.redirection_url,urls.expected_url,connectorId,- payment_method_type+ paymentMethodType);break;case "bank_transfer":@@ -27,8 +42,8 @@ export function handleRedirection(urls.redirection_url,urls.expected_url,connectorId,- payment_method_type,- handler_metadata.next_action_type+ paymentMethodType,+ handlerMetadata.next_action_type);break;case "three_ds":@@ -39,309 +54,358 @@ export function handleRedirection(urls.redirection_url,urls.expected_url,connectorId,- payment_method_type+ paymentMethodType);break;default:- throw new Error(`Redirection known: ${redirection_type}`);+ throw new Error(`Unknown redirection type: ${redirectionType}`);}}function bankTransferRedirection(- redirection_url,- expected_url,+ redirectionUrl,+ expectedUrl,connectorId,- payment_method_type,- next_action_type+ paymentMethodType,+ nextActionType) {- switch (next_action_type) {+ switch (nextActionType) {case "qr_code_url":- cy.request(redirection_url.href).then((response) => {+ cy.request(redirectionUrl.href).then((response) => {switch (connectorId) {case "adyen":- switch (payment_method_type) {+ switch (paymentMethodType) {case "pix":expect(response.status).to.eq(200);- fetchAndParseQRCode(redirection_url.href).then((qrCodeData) => {+ fetchAndParseQRCode(redirectionUrl.href).then((qrCodeData) => {expect(qrCodeData).to.eq("TestQRCodeEMVToken");});break;default:- verifyReturnUrl(redirection_url, expected_url, true);+ verifyReturnUrl(redirectionUrl, expectedUrl, true);// expected_redirection can be used here to handle other payment methods}break;default:- verifyReturnUrl(redirection_url, expected_url, true);+ verifyReturnUrl(redirectionUrl, expectedUrl, true);}});break;case "image_data_url":switch (connectorId) {case "itaubank":- switch (payment_method_type) {+ switch (paymentMethodType) {case "pix":- fetchAndParseImageData(redirection_url).then((qrCodeData) => {+ fetchAndParseImageData(redirectionUrl).then((qrCodeData) => {expect(qrCodeData).to.contains("itau.com.br/pix/qr/v2"); // image data contains the following value});break;default:- verifyReturnUrl(redirection_url, expected_url, true);+ verifyReturnUrl(redirectionUrl, expectedUrl, true);}break;default:- verifyReturnUrl(redirection_url, expected_url, true);+ verifyReturnUrl(redirectionUrl, expectedUrl, true);}break;default:- verifyReturnUrl(redirection_url, expected_url, true);+ verifyReturnUrl(redirectionUrl, expectedUrl, true);}}function bankRedirectRedirection(- redirection_url,- expected_url,+ redirectionUrl,+ expectedUrl,connectorId,- payment_method_type+ paymentMethodType) {let verifyUrl = false;- cy.visit(redirection_url.href);-- switch (connectorId) {- case "adyen":- switch (payment_method_type) {- case "eps":- cy.get("h1").should("contain.text", "Acquirer Simulator");- cy.get('[value="authorised"]').click();- cy.url().should("include", "status=succeeded");- cy.wait(5000);- break;- case "ideal":- cy.get(":nth-child(4) > td > p").should(- "contain.text",- "Your Payment was Authorised/Refused/Cancelled (It may take up to five minutes to show on the Payment List)"- );- cy.get(".btnLink").click();- cy.url().should("include", "status=succeeded");- cy.wait(5000);- break;- case "giropay":- cy.get(- ".rds-cookies-overlay__allow-all-cookies-btn > .rds-button"- ).click();- cy.wait(5000);- cy.get(".normal-3").should(- "contain.text",- "Bank suchen ‑ mit giropay zahlen."- );- cy.get("#bankSearch").type("giropay TestBank{enter}");- cy.get(".normal-2 > div").click();- cy.get('[data-testid="customerIban"]').type("DE48499999601234567890");- cy.get('[data-testid="customerIdentification"]').type("9123456789");- cy.get(":nth-child(3) > .rds-button").click();- cy.get('[data-testid="onlineBankingPin"]').type("1234");- cy.get(".rds-button--primary").click();- cy.get(":nth-child(5) > .rds-radio-input-group__label").click();- cy.get(".rds-button--primary").click();- cy.get('[data-testid="photoTan"]').type("123456");- cy.get(".rds-button--primary").click();- cy.wait(5000);- cy.url().should("include", "status=succeeded");- cy.wait(5000);- break;- case "sofort":- cy.get(".modal-overlay.modal-shown.in", { timeout: TIMEOUT }).then(- ($modal) => {- // If modal is found, handle it- if ($modal.length > 0) {- cy.get("button.cookie-modal-deny-all.button-tertiary")- .should("be.visible")- .should("contain", "Reject All")- .click({ multiple: true });- cy.get("div#TopBanks.top-banks-multistep")- .should("contain", "Demo Bank")- .as("btn")- .click();- cy.get("@btn").click();- } else {- cy.get("input.phone").type("9123456789");- cy.get("#button.onContinue")- .should("contain", "Continue")- .click();- }- }- );- break;- case "trustly":- break;- default:- throw new Error(- `Unsupported payment method type: ${payment_method_type}`- );- }- verifyUrl = true;- break;- case "paypal":- switch (payment_method_type) {- case "eps":- cy.get('button[name="Successful"][value="SUCCEEDED"]').click();- break;- case "ideal":- cy.get('button[name="Successful"][value="SUCCEEDED"]').click();- break;- case "giropay":- cy.get('button[name="Successful"][value="SUCCEEDED"]').click();- break;- default:- throw new Error(- `Unsupported payment method type: ${payment_method_type}`- );- }- verifyUrl = true;- break;- case "stripe":- switch (payment_method_type) {- case "eps":- cy.get('a[name="success"]').click();- break;- case "ideal":- cy.get('a[name="success"]').click();- break;- case "giropay":- cy.get('a[name="success"]').click();- break;- case "sofort":- cy.get('a[name="success"]').click();- break;- case "przelewy24":- cy.get('a[name="success"]').click();- break;- default:- throw new Error(- `Unsupported payment method type: ${payment_method_type}`- );- }- verifyUrl = true;- break;- case "trustpay":- switch (payment_method_type) {- case "eps":- cy.get("#bankname").type(- "Allgemeine Sparkasse Oberösterreich Bank AG (ASPKAT2LXXX / 20320)"- );- cy.get("#selectionSubmit").click();- cy.get("#user")- .should("be.visible")- .should("be.enabled")- .focus()- .type("Verfügernummer");- cy.get("input#submitButton.btn.btn-primary").click();- break;- case "ideal":- cy.contains("button", "Select your bank").click();- cy.get(- 'button[data-testid="bank-item"][id="bank-item-INGBNL2A"]'- ).click();++ cy.visit(redirectionUrl.href);+ waitForRedirect(redirectionUrl.href);++ handleFlow(+ redirectionUrl,+ expectedUrl,+ connectorId,+ ({ connectorId, paymentMethodType, constants }) => {+ switch (connectorId) {+ case "adyen":+ switch (paymentMethodType) {+ case "eps":+ cy.get("h1").should("contain.text", "Acquirer Simulator");+ cy.get('[value="authorised"]').click();+ break;+ case "ideal":+ cy.get(":nth-child(4) > td > p").should(+ "contain.text",+ "Your Payment was Authorised/Refused/Cancelled (It may take up to five minutes to show on the Payment List)"+ );+ cy.get(".btnLink").click();+ cy.url().should("include", "status=succeeded");+ cy.wait(5000);+ break;+ case "giropay":+ cy.get(+ ".rds-cookies-overlay__allow-all-cookies-btn > .rds-button"+ ).click();+ cy.wait(5000);+ cy.get(".normal-3").should(+ "contain.text",+ "Bank suchen ‑ mit giropay zahlen."+ );+ cy.get("#bankSearch").type("giropay TestBank{enter}");+ cy.get(".normal-2 > div").click();+ cy.get('[data-testid="customerIban"]').type(+ "DE48499999601234567890"+ );+ cy.get('[data-testid="customerIdentification"]').type(+ "9123456789"+ );+ cy.get(":nth-child(3) > .rds-button").click();+ cy.get('[data-testid="onlineBankingPin"]').type("1234");+ cy.get(".rds-button--primary").click();+ cy.get(":nth-child(5) > .rds-radio-input-group__label").click();+ cy.get(".rds-button--primary").click();+ cy.get('[data-testid="photoTan"]').type("123456");+ cy.get(".rds-button--primary").click();+ cy.wait(5000);+ cy.url().should("include", "status=succeeded");+ cy.wait(5000);+ break;+ case "sofort":+ cy.get(".modal-overlay.modal-shown.in", {+ timeout: constants.TIMEOUT,+ }).then(($modal) => {+ // If modal is found, handle it+ if ($modal.length > 0) {+ cy.get("button.cookie-modal-deny-all.button-tertiary")+ .should("be.visible")+ .should("contain", "Reject All")+ .click({ multiple: true });+ cy.get("div#TopBanks.top-banks-multistep")+ .should("contain", "Demo Bank")+ .as("btn")+ .click();+ cy.get("@btn").click();+ } else {+ cy.get("input.phone").type("9123456789");+ cy.get("#button.onContinue")+ .should("contain", "Continue")+ .click();+ }+ });+ break;+ default:+ throw new Error(+ `Unsupported payment method type: ${paymentMethodType}`+ );+ }+ verifyUrl = true;break;- case "giropay":- cy.get("._transactionId__header__iXVd_").should(- "contain.text",- "Bank suchen ‑ mit giropay zahlen."- );- cy.get(".BankSearch_searchInput__uX_9l").type(- "Volksbank Hildesheim{enter}"- );- cy.get(".BankSearch_searchIcon__EcVO7").click();- cy.get(".BankSearch_bankWrapper__R5fUK").click();- cy.get("._transactionId__primaryButton__nCa0r").click();- cy.get(".normal-3").should("contain.text", "Kontoauswahl");+ case "paypal":+ if (["eps", "ideal", "giropay"].includes(paymentMethodType)) {+ cy.get('button[name="Successful"][value="SUCCEEDED"]').click();+ verifyUrl = true;+ } else {+ throw new Error(+ `Unsupported payment method type: ${paymentMethodType}`+ );+ }+ verifyUrl = true;break;- case "sofort":+ case "stripe":+ if (+ ["eps", "ideal", "giropay", "sofort", "przelewy24"].includes(+ paymentMethodType+ )+ ) {+ cy.get('a[name="success"]').click();+ verifyUrl = true;+ } else {+ throw new Error(+ `Unsupported payment method type: ${paymentMethodType}`+ );+ }+ verifyUrl = true;break;- case "trustly":+ case "trustpay":+ switch (paymentMethodType) {+ case "eps":+ cy.get("#bankname").type(+ "Allgemeine Sparkasse Oberösterreich Bank AG (ASPKAT2LXXX / 20320)"+ );+ cy.get("#selectionSubmit").click();+ cy.get("#user")+ .should("be.visible")+ .should("be.enabled")+ .focus()+ .type("Verfügernummer");+ cy.get("input#submitButton.btn.btn-primary").click();+ break;+ case "ideal":+ cy.contains("button", "Select your bank").click();+ cy.get(+ 'button[data-testid="bank-item"][id="bank-item-INGBNL2A"]'+ ).click();+ break;+ case "giropay":+ cy.get("._transactionId__header__iXVd_").should(+ "contain.text",+ "Bank suchen ‑ mit giropay zahlen."+ );+ cy.get(".BankSearch_searchInput__uX_9l").type(+ "Volksbank Hildesheim{enter}"+ );+ cy.get(".BankSearch_searchIcon__EcVO7").click();+ cy.get(".BankSearch_bankWrapper__R5fUK").click();+ cy.get("._transactionId__primaryButton__nCa0r").click();+ cy.get(".normal-3").should("contain.text", "Kontoauswahl");+ break;+ default:+ throw new Error(+ `Unsupported payment method type: ${paymentMethodType}`+ );+ }+ verifyUrl = false;break;default:- throw new Error(- `Unsupported payment method type: ${payment_method_type}`- );+ throw new Error(`Unsupported connector: ${connectorId}`);}- verifyUrl = false;- break;- default:- throw new Error(`Unsupported connector: ${connectorId}`);- }+ },+ { paymentMethodType }+ );cy.then(() => {- verifyReturnUrl(redirection_url, expected_url, verifyUrl);+ verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);});}-function threeDsRedirection(redirection_url, expected_url, connectorId) {- cy.visit(redirection_url.href);-- switch (connectorId) {- case "adyen":- cy.get("iframe")- .its("0.contentDocument.body")- .within(() => {- cy.get('input[type="password"]').click();- cy.get('input[type="password"]').type("password");- cy.get("#buttonSubmit").click();- });- break;+function threeDsRedirection(redirectionUrl, expectedUrl, connectorId) {+ cy.visit(redirectionUrl.href);+ waitForRedirect(redirectionUrl.href);- case "bankofamerica":- case "wellsfargo":- cy.get("iframe", { timeout: TIMEOUT })- .should("be.visible")- .its("0.contentDocument.body")- .should("not.be.empty")- .within(() => {- cy.get(- 'input[type="text"], input[type="password"], input[name="challengeDataEntry"]',- { timeout: TIMEOUT }- )- .should("be.visible")- .should("be.enabled")- .click()- .type("1234");+ handleFlow(+ redirectionUrl,+ expectedUrl,+ connectorId,+ ({ connectorId, constants, expectedUrl }) => {+ switch (connectorId) {+ case "adyen":+ cy.get("iframe")+ .its("0.contentDocument.body")+ .within(() => {+ cy.get('input[type="password"]').click();+ cy.get('input[type="password"]').type("password");+ cy.get("#buttonSubmit").click();+ });+ break;- cy.get('input[value="SUBMIT"], button[type="submit"]', {- timeout: TIMEOUT,- })+ case "bankofamerica":+ case "wellsfargo":+ cy.get("iframe", { timeout: constants.TIMEOUT }).should("be.visible")- .click();- });- break;+ .its("0.contentDocument.body")+ .should("not.be.empty")+ .within(() => {+ cy.get(+ 'input[type="text"], input[type="password"], input[name="challengeDataEntry"]',+ { timeout: constants.TIMEOUT }+ )+ .should("be.visible")+ .should("be.enabled")+ .click()+ .type("1234");++ cy.get('input[value="SUBMIT"], button[type="submit"]', {+ timeout: constants.TIMEOUT,+ })+ .should("be.visible")+ .click();+ });+ break;- case "cybersource":- cy.url({ timeout: TIMEOUT }).should("include", expected_url.origin);- break;+ case "cybersource":+ cy.url({ timeout: constants.TIMEOUT }).should("include", expectedUrl);+ break;++ case "checkout":+ cy.get("iframe", { timeout: constants.TIMEOUT })+ .its("0.contentDocument.body")+ .within(() => {+ cy.get('form[id="form"]', { timeout: constants.WAIT_TIME })+ .should("exist")+ .then(() => {+ cy.get('input[id="password"]').click();+ cy.get('input[id="password"]').type("Checkout1!");+ cy.get("#txtButton").click();+ });+ });+ break;- case "checkout":- cy.get("iframe", { timeout: TIMEOUT })- .its("0.contentDocument.body")- .within(() => {- cy.get('form[id="form"]', { timeout: WAIT_TIME })+ case "nmi":+ case "noon":+ case "xendit":+ cy.get("iframe", { timeout: constants.TIMEOUT })+ .its("0.contentDocument.body")+ .within(() => {+ cy.get("iframe", { timeout: constants.TIMEOUT })+ .its("0.contentDocument.body")+ .within(() => {+ cy.get('form[name="cardholderInput"]', {+ timeout: constants.TIMEOUT,+ })+ .should("exist")+ .then(() => {+ cy.get('input[name="challengeDataEntry"]')+ .click()+ .type("1234");+ cy.get('input[value="SUBMIT"]').click();+ });+ });+ });+ break;++ case "novalnet":+ cy.get("form", { timeout: constants.WAIT_TIME }).should("exist").then(() => {- cy.get('input[id="password"]').click();- cy.get('input[id="password"]').type("Checkout1!");- cy.get("#txtButton").click();+ cy.get('input[id="submit"]').click();});- });- break;+ break;++ case "stripe":+ cy.get("iframe", { timeout: constants.TIMEOUT })+ .its("0.contentDocument.body")+ .within(() => {+ cy.get("iframe")+ .its("0.contentDocument.body")+ .within(() => {+ cy.get("#test-source-authorize-3ds").click();+ });+ });+ break;++ case "trustpay":+ cy.get('form[name="challengeForm"]', {+ timeout: constants.WAIT_TIME,+ })+ .should("exist")+ .then(() => {+ cy.get("#outcomeSelect")+ .select("Approve")+ .should("have.value", "Y");+ cy.get('button[type="submit"]').click();+ });+ break;- case "nmi":- case "noon":- case "xendit":- cy.get("iframe", { timeout: TIMEOUT })- .its("0.contentDocument.body")- .within(() => {- cy.get("iframe", { timeout: TIMEOUT })+ case "worldpay":+ cy.get("iframe", { timeout: constants.WAIT_TIME }).its("0.contentDocument.body").within(() => {- cy.get('form[name="cardholderInput"]', { timeout: TIMEOUT })+ cy.get('form[name="cardholderInput"]', {+ timeout: constants.WAIT_TIME,+ }).should("exist").then(() => {cy.get('input[name="challengeDataEntry"]')@@ -350,91 +414,50 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {cy.get('input[value="SUBMIT"]').click();});});- });- break;-- case "novalnet":- cy.get("form", { timeout: WAIT_TIME })- .should("exist")- .then(() => {- cy.get('input[id="submit"]').click();- });- break;-- case "stripe":- cy.get("iframe", { timeout: TIMEOUT })- .its("0.contentDocument.body")- .within(() => {- cy.get("iframe")- .its("0.contentDocument.body")- .within(() => {- cy.get("#test-source-authorize-3ds").click();- });- });- break;-- case "trustpay":- cy.get('form[name="challengeForm"]', { timeout: WAIT_TIME })- .should("exist")- .then(() => {- cy.get("#outcomeSelect").select("Approve").should("have.value", "Y");- cy.get('button[type="submit"]').click();- });- break;+ break;- case "worldpay":- cy.get("iframe", { timeout: WAIT_TIME })- .its("0.contentDocument.body")- .within(() => {- cy.get('form[name="cardholderInput"]', { timeout: WAIT_TIME })+ case "fiuu":+ cy.get('form[id="cc_form"]', { timeout: constants.TIMEOUT }).should("exist").then(() => {- cy.get('input[name="challengeDataEntry"]').click().type("1234");- cy.get('input[value="SUBMIT"]').click();- });- });- break;-- case "fiuu":- cy.get('form[id="cc_form"]', { timeout: TIMEOUT })- .should("exist")- .then(() => {- cy.get('button.pay-btn[name="pay"]').click();- cy.get("div.otp")- .invoke("text")- .then((otpText) => {- const otp = otpText.match(/\d+/)[0];- cy.get("input#otp-input").should("not.be.disabled").type(otp);- cy.get("button.pay-btn").click();+ cy.get('button.pay-btn[name="pay"]').click();+ cy.get("div.otp")+ .invoke("text")+ .then((otpText) => {+ const otp = otpText.match(/\d+/)[0];+ cy.get("input#otp-input").should("not.be.disabled").type(otp);+ cy.get("button.pay-btn").click();+ });});- });- break;+ break;- default:- cy.wait(WAIT_TIME);- }+ default:+ cy.wait(constants.WAIT_TIME);+ }+ }+ );// Verify return URL after handling the specific connector- verifyReturnUrl(redirection_url, expected_url, true);+ verifyReturnUrl(redirectionUrl, expectedUrl, true);}function upiRedirection(- redirection_url,- expected_url,+ redirectionUrl,+ expectedUrl,connectorId,- payment_method_type+ paymentMethodType) {let verifyUrl = false;if (connectorId === "iatapay") {- switch (payment_method_type) {+ switch (paymentMethodType) {case "upi_collect":- cy.visit(redirection_url.href);- cy.wait(TIMEOUT).then(() => {+ cy.visit(redirectionUrl.href);+ cy.wait(CONSTANTS.TIMEOUT).then(() => {verifyUrl = true;});break;case "upi_intent":- cy.request(redirection_url.href).then((response) => {+ cy.request(redirectionUrl.href).then((response) => {expect(response.status).to.eq(200);expect(response.body).to.have.property("iataPaymentId");expect(response.body).to.have.property("status", "INITIATED");@@ -446,99 +469,95 @@ function upiRedirection(break;default:throw new Error(- `Unsupported payment method type: ${payment_method_type}`+ `Unsupported payment method type: ${paymentMethodType}`);}} else {- // If connectorId is not iatapay, wait for 10 seconds- cy.wait(WAIT_TIME);+ // For other connectors, nothing to do+ return;}cy.then(() => {- verifyReturnUrl(redirection_url, expected_url, verifyUrl);+ verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);});}-function verifyReturnUrl(redirection_url, expected_url, forward_flow) {- if (!forward_flow) return;-- try {- if (redirection_url.host.endsWith(expected_url.host)) {- cy.wait(WAIT_TIME / 2);-- cy.window()- .its("location")- .then((location) => {- // Check page state before taking screenshots- cy.document().then((doc) => {- // For blank page- cy.wrap(doc.body.innerText.trim()).then((text) => {- if (text === "") {- cy.wrap(text).should("eq", "");- cy.screenshot("blank-page-error");- }- });+function verifyReturnUrl(redirectionUrl, expectedUrl, forwardFlow) {+ if (!forwardFlow) return;- // For error pages- const errorPatterns = [- /4\d{2}/,- /5\d{2}/,- /error/i,- /invalid request/i,- /server error/i,- ];-- const pageText = doc.body.innerText.toLowerCase();- cy.wrap(pageText).then((text) => {- if (errorPatterns.some((pattern) => pattern.test(text))) {- cy.wrap(text).should((content) => {- expect(errorPatterns.some((pattern) => pattern.test(content)))- .to.be.true;- });- cy.screenshot(`error-page-${Date.now()}`);- }- });- });+ cy.location("host", { timeout: CONSTANTS.TIMEOUT }).should((currentHost) => {+ expect(currentHost).to.equal(expectedUrl.host);+ });- const url_params = new URLSearchParams(location.search);- const payment_status = url_params.get("status");+ cy.url().then((url) => {+ cy.origin(+ new URL(url).origin,+ {+ args: {+ redirectionUrl: redirectionUrl.origin,+ expectedUrl: expectedUrl.origin,+ constants: CONSTANTS,+ },+ },+ ({ redirectionUrl, expectedUrl, constants }) => {+ 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) => {+ // Check page state before taking screenshots+ cy.document().then((doc) => {+ const pageText = doc.body.innerText.toLowerCase();+ if (!pageText) {+ // eslint-disable-next-line cypress/assertion-before-screenshot+ cy.screenshot("blank-page-error");+ } else if (+ constants.ERROR_PATTERNS.some((pattern) =>+ pattern.test(pageText)+ )+ ) {+ // eslint-disable-next-line cypress/assertion-before-screenshot+ cy.screenshot(`error-page-${Date.now()}`);+ }+ });- if (- payment_status !== "failed" &&- payment_status !== "processing" &&- payment_status !== "requires_capture" &&- payment_status !== "succeeded"- ) {- cy.wrap(payment_status).should("exist");- cy.screenshot(`failed-payment-${payment_status}`);- throw new Error(- `Redirection failed with payment status: ${payment_status}`- );+ const urlParams = new URLSearchParams(location.search);+ const paymentStatus = urlParams.get("status");++ if (+ !constants.VALID_TERMINAL_STATUSES.includes(paymentStatus)+ ) {+ // eslint-disable-next-line cypress/assertion-before-screenshot+ cy.screenshot(`failed-payment-${paymentStatus}`);+ throw new Error(+ `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}`+ );++ // Return false to prevent the error from failing the test+ return false;+ });}- });- } else {- cy.origin(- expected_url.origin,- { args: { expected_url: expected_url.origin } },- ({ expected_url }) => {- cy.window().its("location.origin").should("eq", expected_url);-- Cypress.on("uncaught:exception", (err, runnable) => {- // Log the error details- // eslint-disable-next-line no-console- console.log(- `Error: ${err.message}\nError occurred in: ${runnable.title}\nStack trace: ${err.stack}`- );- // Return false to prevent the error from failing the test- return false;- });+ } catch (error) {+ throw new Error(`Redirection verification failed: ${error}`);}- );- }- } catch (error) {- cy.error("Redirection verification failed:", error);- throw error;- }+ }+ );+ });}async function fetchAndParseQRCode(url) {@@ -548,12 +567,17 @@ async function fetchAndParseQRCode(url) {}const blob = await response.blob();const reader = new FileReader();- return await new Promise((resolve, reject) => {++ return new Promise((resolve, reject) => {reader.onload = () => {- const base64Image = reader.result.split(",")[1]; // Remove data URI prefix+ // Use the entire data URI from reader.result+ const dataUrl = reader.result;++ // Create a new Image, assigning its src to the full data URIconst image = new Image();- image.src = base64Image;+ image.src = dataUrl;+ // Once the image loads, draw it to a canvas and let jsQR decode itimage.onload = () => {const canvas = document.createElement("canvas");const ctx = canvas.getContext("2d");@@ -574,8 +598,14 @@ async function fetchAndParseQRCode(url) {reject(new Error("Failed to decode QR code"));}};- image.onerror = reject; // Handle image loading errors++ // If the image fails to load at all, reject the promise+ image.onerror = (err) => {+ reject(new Error("Image failed to load: " + err?.message || err));+ };};++ // Read the blob as a data URL (this includes the data:image/png;base64 prefix)reader.readAsDataURL(blob);});}@@ -608,3 +638,69 @@ async function fetchAndParseImageData(url) {image.onerror = reject; // Handle image loading errors});}++function waitForRedirect(redirectionUrl) {+ const originalHost = new URL(redirectionUrl).host;++ cy.location("host", { timeout: CONSTANTS.TIMEOUT }).should((currentHost) => {+ const hostChanged = currentHost !== originalHost;+ const iframeExists = Cypress.$("iframe")+ .toArray()+ .some((iframeEl) => {+ try {+ const iframeHost = new URL(iframeEl.src).host;+ return iframeHost && iframeHost !== originalHost;+ } catch {+ return false;+ }+ });++ // The assertion will pass if either the host changed or an iframe with a foreign host exists.+ expect(+ hostChanged || iframeExists,+ "Host changed or an iframe with foreign host exist"+ ).to.be.true;+ });+}++function handleFlow(+ redirectionUrl,+ expectedUrl,+ connectorId,+ callback,+ options = {}+) {+ const originalHost = new URL(redirectionUrl.href).host;+ cy.location("host", { timeout: CONSTANTS.TIMEOUT }).then((currentHost) => {+ if (currentHost !== originalHost) {+ // Regular redirection flow - host changed, use cy.origin()+ cy.url().then((currentUrl) => {+ cy.origin(+ new URL(currentUrl).origin,+ {+ args: {+ connectorId,+ constants: CONSTANTS,+ expectedUrl: expectedUrl.origin,+ ...options, // optional params like paymentMethodType+ },+ },+ callback+ );+ });+ } else {+ // Embedded flow - host unchanged, use cy.get("iframe")+ cy.get("iframe", { timeout: CONSTANTS.TIMEOUT })+ .should("be.visible")+ .should("exist");++ // Execute callback within the iframe context+ callback({+ connectorId,+ constants: CONSTANTS,+ expectedUrl: expectedUrl.origin,+ ...options, // optional params like paymentMethodType+ });+ }+ });+}diff --git a/cypress-tests/cypress/utils/featureFlags.js b/cypress-tests/cypress/utils/featureFlags.jsindex 6d8599820f..728016ebbb 100644--- a/cypress-tests/cypress/utils/featureFlags.js+++ b/cypress-tests/cypress/utils/featureFlags.js@@ -149,29 +149,41 @@ function matchesSpecName(specName) {);}-export function determineConnectorConfig(connectorConfig) {- // Case 1: Multiple connectors configuration- if (- connectorConfig?.nextConnector &&- connectorConfig?.multipleConnectors?.status- ) {- return "connector_2";- }+export function determineConnectorConfig(config) {+ const connectorCredential = config?.CONNECTOR_CREDENTIAL;+ const multipleConnectors = config?.multipleConnectors;- // Case 2: Invalid or null configuration- if (!connectorConfig || connectorConfig.value === "null") {+ // If CONNECTOR_CREDENTIAL doesn't exist or value is null, return default+ if (!connectorCredential || connectorCredential.value === null) {return DEFAULT_CONNECTOR;}- const { specName, value } = connectorConfig;+ // Handle nextConnector cases+ if (+ Object.prototype.hasOwnProperty.call(connectorCredential, "nextConnector")+ ) {+ if (connectorCredential.nextConnector === true) {+ // Check multipleConnectors conditions if available+ if (+ multipleConnectors?.status === true &&+ multipleConnectors?.count > 1+ ) {+ return "connector_2";+ }+ return DEFAULT_CONNECTOR;+ }+ return DEFAULT_CONNECTOR;+ }- // Case 3: No spec name matching needed- if (!specName) {- return value;+ // Handle specName cases+ if (Object.prototype.hasOwnProperty.call(connectorCredential, "specName")) {+ return matchesSpecName(connectorCredential.specName)+ ? connectorCredential.value+ : DEFAULT_CONNECTOR;}- // Case 4: Match spec name and return appropriate connector- return matchesSpecName(specName) ? value : DEFAULT_CONNECTOR;+ // Return value if it's the only property+ return connectorCredential.value;}export function execConfig(configs) {@@ -179,7 +191,7 @@ export function execConfig(configs) {cy.wait(configs.DELAY.TIMEOUT);}- const connectorType = determineConnectorConfig(configs?.CONNECTOR_CREDENTIAL);+ const connectorType = determineConnectorConfig(configs);const { profileId, connectorId } = getProfileAndConnectorId(connectorType);return {diff --git a/cypress-tests/package-lock.json b/cypress-tests/package-lock.jsonindex 57aef9f3b3..abb5bd3cec 100644--- a/cypress-tests/package-lock.json+++ b/cypress-tests/package-lock.json@@ -9,10 +9,10 @@"version": "1.0.0","license": "ISC","devDependencies": {- "@eslint/js": "^9.18.0",- "cypress": "^13.17.0",+ "@eslint/js": "^9.19.0",+ "cypress": "^14.0.0","cypress-mochawesome-reporter": "^3.8.2",- "eslint": "^9.18.0",+ "eslint": "^9.19.0","eslint-config-prettier": "^10.0.1","eslint-plugin-cypress": "^4.1.0","eslint-plugin-prettier": "^5.2.3",@@ -191,9 +191,9 @@}},"node_modules/@eslint/js": {- "version": "9.18.0",- "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.18.0.tgz",- "integrity": "sha512-fK6L7rxcq6/z+AaQMtiFTkvbHkBLNlwyRxHpKawP0x3u9+NC6MQTnFW+AdpwC6gfHTW0051cokQgtTN2FqlxQA==",+ "version": "9.19.0",+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.19.0.tgz",+ "integrity": "sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ==","dev": true,"license": "MIT","engines": {@@ -1023,9 +1023,9 @@}},"node_modules/cypress": {- "version": "13.17.0",- "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.17.0.tgz",- "integrity": "sha512-5xWkaPurwkIljojFidhw8lFScyxhtiFHl/i/3zov+1Z5CmY4t9tjIdvSXfu82Y3w7wt0uR9KkucbhkVvJZLQSA==",+ "version": "14.0.0",+ "resolved": "https://registry.npmjs.org/cypress/-/cypress-14.0.0.tgz",+ "integrity": "sha512-kEGqQr23so5IpKeg/dp6GVi7RlHx1NmW66o2a2Q4wk9gRaAblLZQSiZJuDI8UMC4LlG5OJ7Q6joAiqTrfRNbTw==","dev": true,"hasInstallScript": true,"license": "MIT",@@ -1078,7 +1078,7 @@"cypress": "bin/cypress"},"engines": {- "node": "^16.0.0 || ^18.0.0 || >=20.0.0"+ "node": "^18.0.0 || ^20.0.0 || >=22.0.0"}},"node_modules/cypress-mochawesome-reporter": {@@ -1335,9 +1335,9 @@}},"node_modules/eslint": {- "version": "9.18.0",- "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.18.0.tgz",- "integrity": "sha512-+waTfRWQlSbpt3KWE+CjrPPYnbq9kfZIYUqapc0uBXyjTp8aYXZDsUH16m39Ryq3NjAVP4tjuF7KaukeqoCoaA==",+ "version": "9.19.0",+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.19.0.tgz",+ "integrity": "sha512-ug92j0LepKlbbEv6hD911THhoRHmbdXt2gX+VDABAW/Ir7D3nqKdv5Pf5vtlyY6HQMTEP2skXY43ueqTCWssEA==","dev": true,"license": "MIT","dependencies": {@@ -1346,7 +1346,7 @@"@eslint/config-array": "^0.19.0","@eslint/core": "^0.10.0","@eslint/eslintrc": "^3.2.0",- "@eslint/js": "9.18.0",+ "@eslint/js": "9.19.0","@eslint/plugin-kit": "^0.2.5","@humanfs/node": "^0.16.6","@humanwhocodes/module-importer": "^1.0.1",diff --git a/cypress-tests/package.json b/cypress-tests/package.jsonindex a2e0a961e8..b3701ce8fc 100644--- a/cypress-tests/package.json+++ b/cypress-tests/package.json@@ -20,10 +20,10 @@"author": "Hyperswitch","license": "ISC","devDependencies": {- "@eslint/js": "^9.18.0",- "cypress": "^13.17.0",+ "@eslint/js": "^9.19.0",+ "cypress": "^14.0.0","cypress-mochawesome-reporter": "^3.8.2",- "eslint": "^9.18.0",+ "eslint": "^9.19.0","eslint-config-prettier": "^10.0.1","eslint-plugin-cypress": "^4.1.0","eslint-plugin-prettier": "^5.2.3",