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
ci(cypress): add Truelayer and Trustly UCS connector support (#14035)
Vasanth4c41905c7d01
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 5050de369f..df28e0ac6b 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -331,6 +331,17 @@ export const payment_methods_enabled = [recurring_enabled: true,installment_payment_enabled: true,},+ {+ payment_method_type: "open_banking",+ payment_experience: null,+ card_networks: null,+ accepted_currencies: null,+ accepted_countries: null,+ minimum_amount: 1,+ maximum_amount: 68607706,+ recurring_enabled: true,+ installment_payment_enabled: true,+ },{payment_method_type: "online_banking_fpx",payment_experience: null,@@ -353,6 +364,17 @@ export const payment_methods_enabled = [recurring_enabled: true,installment_payment_enabled: true,},+ {+ payment_method_type: "trustly",+ payment_experience: null,+ card_networks: null,+ accepted_currencies: null,+ accepted_countries: null,+ minimum_amount: 1,+ maximum_amount: 68607706,+ recurring_enabled: true,+ installment_payment_enabled: true,+ },{payment_method_type: "interac",payment_experience: null,diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.jsindex d10a01df2d..ad2f292ecf 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js@@ -193,6 +193,7 @@ const CURRENCY_MAP = {Przelewy24: "EUR",Sofort: "EUR",Trustly: "EUR",+ Truelayer: "GBP",BancontactCard: "EUR",OpenBankingUk: "GBP", // Great British Pound payment methodOnlineBankingFpx: "MYR", // Malaysian payment methodsdiff --git a/cypress-tests/cypress/e2e/configs/Payment/Truelayer.js b/cypress-tests/cypress/e2e/configs/Payment/Truelayer.jsnew file mode 100644index 0000000000..f461d2f6e1--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payment/Truelayer.js@@ -0,0 +1,70 @@+import { getCustomExchange } from "./Modifiers";++const billingAddressGB = {+ address: {+ line1: "1 Principal Place",+ city: "London",+ zip: "EC2A 2FA",+ country: "GB",+ first_name: "John",+ last_name: "Doe",+ },+ email: "[email protected]",+ phone: {+ number: "7123456789",+ country_code: "+44",+ },+};++export const connectorDetails = {+ bank_redirect_pm: {+ // Required supported-method config for the Truelayer confirm flow. The CI+ // selection runs only this bank redirect flow for Truelayer.+ Truelayer: getCustomExchange({+ Request: {+ payment_method: "bank_redirect",+ payment_method_type: "open_banking",+ payment_method_data: {+ bank_redirect: {+ open_banking: {},+ },+ },+ currency: "GBP", // Truelayer requires GBP for UK open banking payments.+ billing: billingAddressGB,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ payment_method_type: "open_banking",+ connector: "truelayer",+ },+ },+ Configs: {+ skipPaymentMethodStatusAssertion: true,+ },+ }),+ TruelayerNoBilling: getCustomExchange({+ Request: {+ payment_method: "bank_redirect",+ payment_method_type: "open_banking",+ payment_method_data: {+ bank_redirect: {+ open_banking: {},+ },+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ // UCS maps missing top-level billing to the shared IR_04 error.+ message: "Missing required param: billing",+ code: "IR_04",+ },+ },+ },+ }),+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Trustly.js b/cypress-tests/cypress/e2e/configs/Payment/Trustly.jsnew file mode 100644index 0000000000..8c94a18aa6--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payment/Trustly.js@@ -0,0 +1,50 @@+import { getCustomExchange } from "./Modifiers";++const billingAddressSE = {+ address: {+ line1: "1 Main St",+ city: "Stockholm",+ zip: "11122",+ country: "SE",+ first_name: "John",+ last_name: "Doe",+ },+ email: "[email protected]",+ phone: {+ number: "9123456789",+ country_code: "+46",+ },+};++export const connectorDetails = {+ bank_redirect_pm: {+ // Required supported-method config for the Trustly confirm flow. The CI+ // selection runs only this bank redirect flow for Trustly.+ Trustly: getCustomExchange({+ Request: {+ payment_method: "bank_redirect",+ payment_method_type: "trustly",+ payment_method_data: {+ bank_redirect: {+ trustly: {+ country: "SE",+ },+ },+ },+ currency: "EUR", // Trustly requires EUR for Swedish bank redirect payments.+ billing: billingAddressSE,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ payment_method_type: "trustly",+ connector: "trustly",+ },+ },+ Configs: {+ skipPaymentMethodStatusAssertion: true,+ },+ }),+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 3ca4546d81..a3b0698b82 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -85,8 +85,10 @@ import { connectorDetails as staxConnectorDetails } from "./Stax.js";import { connectorDetails as stripeConnectorDetails } from "./Stripe.js";import { connectorDetails as stripeconnectConnectorDetails } from "./StripeConnect.js";import { connectorDetails as tesouroConnectorDetails } from "./Tesouro.js";+import { connectorDetails as truelayerConnectorDetails } from "./Truelayer.js";import { connectorDetails as trustpayConnectorDetails } from "./Trustpay.js";import { connectorDetails as trustpaymentsConnectorDetails } from "./TrustPayments.js";+import { connectorDetails as trustlyConnectorDetails } from "./Trustly.js";import { connectorDetails as tsysConnectorDetails } from "./Tsys.js";import { connectorDetails as tsysTransitConnectorDetails } from "./TsysTransit.js";import { connectorDetails as voltConnectorDetails } from "./Volt.js";@@ -177,9 +179,11 @@ const connectorDetails = {stax: staxConnectorDetails,stripe: stripeConnectorDetails,stripeconnect: stripeconnectConnectorDetails,+ truelayer: truelayerConnectorDetails,trustpay: trustpayConnectorDetails,tesouro: tesouroConnectorDetails,trustpayments: trustpaymentsConnectorDetails,+ trustly: trustlyConnectorDetails,tsys: tsysConnectorDetails,tsys_transit: tsysTransitConnectorDetails,volt: voltConnectorDetails,@@ -612,6 +616,8 @@ export const CONNECTOR_LISTS = {"fiservcommercehub","givepayments","ilixium",+ "truelayer",+ "trustly",],OVERCAPTURE: ["adyen"],IFRAME_REDIRECTION: [diff --git a/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.js b/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.jsindex ebc545bd1b..8620bd5788 100644--- a/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/18-BankRedirect.cy.js@@ -494,6 +494,93 @@ describe("Bank Redirect tests", () => {});});+ context("Truelayer Create and Confirm flow test", () => {+ before(function () {+ if (globalState.get("connectorId") !== "truelayer") {+ this.skip();+ }+ });++ it("Create Payment Intent -> List Merchant Payment Methods -> Confirm Payment -> Handle Bank Redirect Redirection -> Retrieve Payment", () => {+ let shouldContinue = true;++ cy.step("Setup UCS rollout config", () => {+ cy.createRolloutConfig(+ globalState,+ "bank_redirect_open_banking_Authorize"+ );+ });++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "bank_redirect_pm"+ ]["PaymentIntent"]("Truelayer");+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("List Merchant Payment Methods", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "bank_redirect_pm"+ ]["Truelayer"];+ cy.confirmBankRedirectCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );+ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Bank Redirect Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Bank Redirect Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ const payment_method_type = globalState.get("paymentMethodType");+ cy.handleBankRedirectRedirection(+ globalState,+ payment_method_type,+ expected_redirection+ );+ });++ cy.step("Retrieve Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "bank_redirect_pm"+ ]["Truelayer"];+ cy.retrievePaymentCallTest({ globalState, data: confirmData });+ });+ });+ });+context("OnlineBankingFpx Create and Confirm flow test", () => {it("Create Payment Intent -> List Merchant Payment Methods -> Confirm Payment -> Handle Bank Redirect Redirection -> Retrieve Payment", () => {let shouldContinue = true;@@ -646,6 +733,11 @@ describe("Bank Redirect tests", () => {it("Create Payment Intent -> List Merchant Payment Methods -> Confirm Payment -> Handle Bank Redirect Redirection", () => {let shouldContinue = true;+ cy.step("Setup UCS rollout config", () => {+ // Trustly is UCS-only; this enables the Trustly authorize flow in primary mode.+ cy.createRolloutConfig(globalState, "bank_redirect_trustly_Authorize");+ });+cy.step("Create Payment Intent", () => {const data = getConnectorDetails(globalState.get("connectorId"))["bank_redirect_pm"diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex f4a7193519..c88737259f 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -71,6 +71,18 @@ function getOriginalConnectorId(globalState) {);}+function getConnectorIdForRedirect(globalState) {+ const connectorId = getOriginalConnectorId(globalState);++ // Trustly auth/config entries can be variant-specific, but UCS rollout keys+ // are stored under the base connector name.+ if (typeof connectorId === "string" && connectorId.startsWith("trustly")) {+ return "trustly";+ }++ return connectorId;+}+// True for test-only connector IDs (stripeconnect, payloadconnect, ...)// that alias a real backend connector under a different merchant-connector// -account configuration -- see getOriginalConnectorName.@@ -161,7 +173,7 @@ function createIndividualRolloutConfig(const merchantId = globalState.get("merchantId");const adminApiKey = globalState.get("adminApiKey");const baseUrl = globalState.get("baseUrl");- const connector = globalState.get("connectorId");+ const connector = getConnectorIdForRedirect(globalState);const httpUrl = globalState.get("proxyHttp");const httpsUrl = globalState.get("proxyHttps");@@ -169,7 +181,6 @@ function createIndividualRolloutConfig(// Set rollout_percent to 1.0 to ensure flows go throughconst rolloutPercent = 1.0;const key = `ucs_rollout_config_${merchantId}_${connector}_${methodFlow}`;-// UCS-only connectors (no working classic direct-integration fallback)// must route "primary" so the classic connector is never invoked; every// other connector keeps mirroring to UCS via "shadow" for comparison.@@ -192,68 +203,165 @@ function createIndividualRolloutConfig("api-key": adminApiKey,};- const requestBody = {- key: key,- value: value,+ const url = `${baseUrl}/configs/`;++ // Keep non-retryable config failures visible while preserving the Cypress chain.+ const handleConfigCreateFailure = (response) => {+ const errorMsg = response.body?.error?.message || "Unknown error";+ return cy+ .task(+ "cli_log",+ `FAIL: ${configType} config creation failed: ${merchantId}_${connector}_${methodFlow}`+ )+ .then(() => {+ return cy.task("cli_log", ` Status: ${response.status}`).then(() => {+ return cy.task("cli_log", ` Error: ${errorMsg}`).then(() => {+ return cy.wrap({+ success: false,+ flow: methodFlow,+ error: errorMsg,+ });+ });+ });+ });};- const url = `${baseUrl}/configs/`;+ // setConfigs only logs the response; this helper returns the result object+ // consumed by createUcsConfigs' success/failure aggregation.+ const makeRequest = (method, requestUrl, body, operationType) => {+ return cy+ .request({+ method: method,+ url: requestUrl,+ headers: headers,+ body: body,+ failOnStatusCode: false,+ })+ .then((response) => {+ if (response.status === 200) {+ expect(response.body).to.have.property("key").to.equal(key);+ expect(response.body).to.have.property("value").to.equal(value);+ return cy+ .task(+ "cli_log",+ `PASS: ${configType} config ${operationType} successfully: ${merchantId}_${connector}_${methodFlow}`+ )+ .then(() => {+ return cy.wrap({ success: true, flow: methodFlow });+ });+ }+ return response;+ });+ };- return cy- .request({- method: "POST",- url: url,- headers: headers,- body: requestBody,- failOnStatusCode: false,- })- .then((response) => {+ const createConfig = () => {+ const requestBody = {+ key: key,+ value: value,+ };++ return makeRequest("POST", url, requestBody, "created").then((response) => {if (response.status === 200) {- expect(response.body).to.have.property("key").to.equal(key);- expect(response.body).to.have.property("value").to.equal(value);- return cy- .task(- "cli_log",- `PASS: ${configType} config created successfully: ${merchantId}_${connector}_${methodFlow}`- )- .then(() => {- return cy.wrap({ success: true, flow: methodFlow });- });- } else {- const errorMsg = response.body?.error?.message || "Unknown error";+ return cy.wrap({ success: true, flow: methodFlow });+ }++ if (+ response.body?.error?.code === "HE_01" ||+ response.body?.error?.message?.includes("already exists")+ ) {+ return updateConfig();+ }++ return handleConfigCreateFailure(response);+ });+ };++ const updateConfig = () => {+ return makeRequest("POST", `${url}${key}`, { value }, "updated").then(+ (updateResponse) => {+ if (updateResponse.status === 200) {+ return cy.wrap({ success: true, flow: methodFlow });+ }++ const updateErrorMsg =+ updateResponse.body?.error?.message || "Unknown error";++ if (+ updateResponse.status === 404 ||+ updateResponse.body?.error?.code === "HE_02" ||+ updateErrorMsg.includes("not found") ||+ updateErrorMsg.includes("does not exist")+ ) {+ return cy+ .task(+ "cli_log",+ `INFO: ${configType} config does not exist, creating: ${merchantId}_${connector}_${methodFlow}`+ )+ .then(() => createConfig());+ }+return cy.task("cli_log",- `FAIL: ${configType} config creation failed: ${merchantId}_${connector}_${methodFlow}`+ `FAIL: ${configType} config update failed: ${merchantId}_${connector}_${methodFlow}`).then(() => {return cy- .task("cli_log", ` Status: ${response.status}`)+ .task("cli_log", ` Status: ${updateResponse.status}`).then(() => {- return cy.task("cli_log", ` Error: ${errorMsg}`).then(() => {- return cy.wrap({- success: false,- flow: methodFlow,- error: errorMsg,+ return cy+ .task("cli_log", ` Error: ${updateErrorMsg}`)+ .then(() => {+ return cy.wrap({+ success: false,+ flow: methodFlow,+ error: updateErrorMsg,+ });});- });});});}+ );+ };++ return cy+ .task(+ "cli_log",+ `INFO: Upserting ${configType} config: ${merchantId}_${connector}_${methodFlow}`+ )+ .then(() => {+ return updateConfig();});}-function parseMethodFlows(methodFlowInput) {+function normalizeMethodFlow(methodFlow, connector) {+ let normalizedFlow = methodFlow.trim();++ if (connector && normalizedFlow.startsWith(`${connector}_`)) {+ normalizedFlow = normalizedFlow.slice(connector.length + 1);+ }++ return normalizedFlow.replace(+ /^bank_redirect_openbanking_/,+ "bank_redirect_open_banking_"+ );+}++function parseMethodFlows(methodFlowInput, connector) {if (!methodFlowInput) {throw new Error("methodFlow input is required");}- return methodFlowInput.includes(",")+ const methodFlows = methodFlowInput.includes(",")? methodFlowInput.split(",").map((flow) => flow.trim()).filter((flow) => flow.length > 0): [methodFlowInput.trim()];++ return [+ ...new Set(methodFlows.map((flow) => normalizeMethodFlow(flow, connector))),+ ];}function createUcsConfigs(globalState, flow, type) {@@ -269,7 +377,7 @@ function createUcsConfigs(globalState, flow, type) {const httpUrl = globalState.get("proxyHttp");const httpsUrl = globalState.get("proxyHttps");- const connector = globalState.get("connectorId");+ const connector = getConnectorIdForRedirect(globalState);const methodFlowInput = flow || globalState.get("methodFlow");if (!httpUrl || !httpsUrl) {@@ -297,7 +405,7 @@ function createUcsConfigs(globalState, flow, type) {);}- const methodFlows = parseMethodFlows(methodFlowInput);+ const methodFlows = parseMethodFlows(methodFlowInput, connector);return cy.task(@@ -412,6 +520,37 @@ function storeRequestId(xRequestId, globalState) {}}+function sanitizeValidationServiceUrl(url) {+ if (!url || typeof url !== "string") {+ return null;+ }++ const markdownLinkMatch = url.match(/^\[(https?:\/\/[^\]]+)\]/);+ const normalizedUrl = (markdownLinkMatch ? markdownLinkMatch[1] : url).trim();+ return normalizedUrl.replace(/\/+$/, "");+}++function getValidationServiceUrl(globalState) {+ const validationServiceUrl = sanitizeValidationServiceUrl(+ globalState.get("validationServiceUrl") ||+ Cypress.env("VALIDATION_SERVICE_URL")+ );++ if (!validationServiceUrl) {+ return null;+ }++ if (validationServiceUrl.includes(".svc.cluster.local")) {+ throw new Error(+ `CYPRESS_VALIDATION_SERVICE_URL is not reachable from Cypress: ${validationServiceUrl}. Use a local port-forward or an externally reachable validation service URL.`+ );+ }++ globalState.set("validationServiceUrl", validationServiceUrl);++ return validationServiceUrl;+}+// Helper function for validating diff check inputfunction validateDiffCheckInput(globalState) {if (!globalState || !globalState.get("ucsEnabled")) {@@ -434,7 +573,16 @@ function validateDiffCheckInput(globalState) {return { isValid: false, reason: "No request IDs" };}- return { isValid: true, requestIds: storedRequestIds };+ const validationServiceUrl = getValidationServiceUrl(globalState);+ if (!validationServiceUrl) {+ cy.task(+ "cli_log",+ "No CYPRESS_VALIDATION_SERVICE_URL found. Skipping diff check validation."+ );+ return { isValid: false, reason: "Missing validationServiceUrl" };+ }++ return { isValid: true, requestIds: storedRequestIds, validationServiceUrl };}// Helper function for filtering matching validation results@@ -3170,7 +3318,13 @@ Cypress.Commands.add(const apiKey = globalState.get("publishableKey");const baseUrl = globalState.get("baseUrl");- const configInfo = execConfig(validateConfig(configs));+ const validatedConfigs = validateConfig(configs);+ if (validatedConfigs?.TRIGGER_SKIP) {+ cy.task("cli_log", "TRIGGER_SKIP enabled, skipping confirmCallTest");+ return;+ }++ const configInfo = execConfig(validatedConfigs);const merchantConnectorId = globalState.get(`${configInfo.merchantConnectorPrefix}Id`);@@ -3582,24 +3736,39 @@ Cypress.Commands.add(} = data || {};const validatedConfigs = validateConfig(configs);- if (validatedConfigs?.TRIGGER_SKIP) {- cy.task(- "cli_log",- "TRIGGER_SKIP enabled, skipping confirmBankRedirectCallTest"- );- return;- }-const configInfo = execConfig(validatedConfigs);const connectorId = globalState.get("connectorId");const paymentIntentId = globalState.get("paymentID");const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);const customer_id = globalState.get("customerId");+ globalState.set("nextActionUrl", null);const body = JSON.parse(JSON.stringify(confirmBody));for (const key in reqData) {body[key] = reqData[key];}++ const connectorConfigId = getConnectorIdForRedirect(globalState);+ const ignoreTriggerSkip =+ connectorConfigId === "trustly" &&+ body.payment_method === "bank_redirect" &&+ body.payment_method_type === "trustly";++ if (validatedConfigs?.TRIGGER_SKIP && ignoreTriggerSkip) {+ cy.task(+ "cli_log",+ "Ignoring TRIGGER_SKIP for native Trustly bank redirect flow"+ );+ }++ if (validatedConfigs?.TRIGGER_SKIP && !ignoreTriggerSkip) {+ cy.task(+ "cli_log",+ "TRIGGER_SKIP enabled, skipping confirmBankRedirectCallTest"+ );+ return;+ }+body.client_secret = globalState.get("clientSecret");body.confirm = confirm;body.profile_id = profile_id;@@ -3742,7 +3911,16 @@ Cypress.Commands.add(Response: resData,} = data || {};- const configInfo = execConfig(validateConfig(configs));+ const validatedConfigs = validateConfig(configs);+ if (validatedConfigs?.TRIGGER_SKIP) {+ cy.task(+ "cli_log",+ "TRIGGER_SKIP enabled, skipping confirmPayLaterCallTest"+ );+ return;+ }++ const configInfo = execConfig(validatedConfigs);const paymentIntentId = globalState.get("paymentID");const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);const customer_id = globalState.get("customerId");@@ -3819,7 +3997,16 @@ Cypress.Commands.add(Response: resData,} = data || {};- const configInfo = execConfig(validateConfig(configs));+ const validatedConfigs = validateConfig(configs);+ if (validatedConfigs?.TRIGGER_SKIP) {+ cy.task(+ "cli_log",+ "TRIGGER_SKIP enabled, skipping createConfirmPaymentTest"+ );+ return;+ }++ const configInfo = execConfig(validatedConfigs);const paymentIntentID = globalState.get("paymentID");const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);const customer_id = globalState.get("customerId");@@ -4038,7 +4225,16 @@ Cypress.Commands.add(Response: resData,} = data || {};- const configInfo = execConfig(validateConfig(configs));+ const validatedConfigs = validateConfig(configs);+ if (validatedConfigs?.TRIGGER_SKIP) {+ cy.task(+ "cli_log",+ "TRIGGER_SKIP enabled, skipping createConfirmPaymentTest"+ );+ return;+ }++ const configInfo = execConfig(validatedConfigs);const merchant_connector_id = globalState.get(`${configInfo.merchantConnectorPrefix}Id`);@@ -6081,7 +6277,7 @@ Cypress.Commands.add(Cypress.Commands.add("handleBankRedirectRedirection",(globalState, paymentMethodType, expectedRedirection) => {- const connectorId = globalState.get("connectorId");+ const connectorId = getConnectorIdForRedirect(globalState);const nextActionUrl = globalState.get("nextActionUrl");// explicitly restricting `sofort` payment method by adyen from running as it stops other tests from running@@ -6111,6 +6307,11 @@ Cypress.Commands.add(return;}+ cy.task(+ "cli_log",+ `handleBankRedirectRedirection: connector=${connectorId}, paymentMethodType=${paymentMethodType}, nextActionUrl=${nextActionUrl}`+ );+// Some connectors (e.g. adyen sepa_bank_debit) complete the payment// synchronously without a next_action redirect URL.if (!nextActionUrl) {@@ -7928,19 +8129,13 @@ Cypress.Commands.add("setupConfigs", (globalState, key, value) => {});// UCS Configuration Commands-Cypress.Commands.add("setupUCSConfigs", (globalState, connector) => {+Cypress.Commands.add("setupUCSConfigs", (globalState) => {cy.setupConfigs(globalState, "ucs_enabled", "true");- const merchantId = globalState.get("merchantId");- const rolloutConfigs = [- `ucs_rollout_config_${merchantId}_${connector}_card_Authorize`,- `ucs_rollout_config_${merchantId}_${connector}_card_SetupMandate`,- `ucs_rollout_config_${merchantId}_${connector}_card_PSync`,- ];-- rolloutConfigs.forEach((key) => {- cy.setConfigs(globalState, key, "1.0", "CREATE");- });+ cy.createRolloutConfig(+ globalState,+ "card_Authorize,card_SetupMandate,card_PSync"+ );});Cypress.Commands.add("cleanupUCSConfigs", (globalState, connector) => {@@ -8226,7 +8421,7 @@ Cypress.Commands.add("diffCheckResult", (globalState) => {);// Phase 2: Fetch Validation Results- const validationServiceUrl = globalState.get("validationServiceUrl");+ const validationServiceUrl = validation.validationServiceUrl;if (!validationServiceUrl) {cy.task(diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 8978649a57..d324477fd2 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -1565,6 +1565,300 @@ function bankRedirectRedirection(return;}+ if (connectorId === "trustly" && paymentMethodType === "trustly") {+ cy.visit(redirectionUrl.href, {+ failOnStatusCode: false,+ timeout: CONSTANTS.TIMEOUT,+ });+ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).should("exist");++ cy.log("Handling Trustly sandbox bank redirect");+ const clickableSelector =+ 'button, a, [role="button"], [role="option"], label, li, [data-testid], [class*="bank"], [class*="Bank"]';+ const bankSearchSelector =+ 'input[type="search"], input[type="text"], input[role="combobox"], input[placeholder*="Search"], input[placeholder*="search"], input[placeholder*="bank"], input[placeholder*="Bank"], input[name*="search"], input[name*="bank"], input[id*="search"], input[id*="bank"], input[aria-label*="search"], input[aria-label*="bank"]';+ const clickFirstVisibleByText = (pattern, logMessage) => {+ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).then(($body) => {+ const element = $body+ .find(clickableSelector)+ .filter((_, el) =>+ pattern.test(+ el.innerText || el.value || el.getAttribute("aria-label") || ""+ )+ )+ .filter(":visible")+ .first();++ if (element.length > 0) {+ cy.log(logMessage);+ cy.wrap(element).scrollIntoView().click({ force: true });+ }+ });+ };+ const clickTextOrClosestClickable = (+ selector,+ pattern,+ logMessage,+ closestSelector = clickableSelector+ ) => {+ cy.contains(selector, pattern, { timeout: CONSTANTS.TIMEOUT })+ .should("be.visible")+ .then(($el) => {+ const clickable = $el.closest(closestSelector);+ const target = clickable.length > 0 ? clickable : $el;++ cy.log(logMessage);+ cy.wrap(target)+ .scrollIntoView()+ .trigger("mouseover", { force: true })+ .trigger("mousedown", { force: true })+ .trigger("mouseup", { force: true })+ .click({ force: true });+ });+ };+ const clickVisibleAction = (pattern, logMessage) => {+ cy.contains(+ 'button, a, [role="button"], input[type="submit"], input[type="button"]',+ pattern,+ { timeout: CONSTANTS.TIMEOUT }+ )+ .should("be.visible")+ .and(($el) => {+ expect($el).not.to.have.attr("disabled");+ expect($el).not.to.have.attr("aria-disabled", "true");+ })+ .then(($el) => {+ cy.log(logMessage);+ cy.wrap($el)+ .scrollIntoView()+ .trigger("mouseover", { force: true })+ .trigger("mousedown", { force: true })+ .trigger("mouseup", { force: true })+ .click({ force: true });+ });+ };+ const selectNordeaBank = () => {+ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).then(($body) => {+ const bankSearch = $body+ .find(bankSearchSelector)+ .filter(":visible")+ .first();++ if (bankSearch.length > 0) {+ cy.wrap(bankSearch)+ .scrollIntoView()+ .click({ force: true })+ .clear({ force: true })+ .type("Nordea", { force: true });+ }+ });+ clickTextOrClosestClickable(+ 'button, a, [role="button"], [role="option"], [role="listitem"], li, label, div, span',+ /nordea/i,+ "Selecting Nordea bank",+ 'button, a, [role="button"], [role="option"], [role="listitem"], li, label, [data-testid], [class*="bank"], [class*="Bank"]'+ );+ };++ selectNordeaBank();+ clickVisibleAction(/continue|next|proceed/i, "Continuing after bank");++ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).then(($body) => {+ const usernameInput = $body+ .find(+ 'input[name*="user"], input[id*="user"], input[autocomplete="username"], input[type="text"]'+ )+ .filter(":visible")+ .first();++ if (usernameInput.length > 0) {+ cy.wrap(usernameInput)+ .clear({ force: true })+ .type(`happy_path_${Date.now()}`, { force: true });+ }++ const passwordInput = $body+ .find(+ 'input[type="password"], input[name*="password"], input[id*="password"]'+ )+ .filter(":visible")+ .first();++ if (passwordInput.length > 0) {+ cy.wrap(passwordInput)+ .clear({ force: true })+ .type("password123", { force: true });+ }+ });++ clickVisibleAction(+ /continue|next|login|log in|sign in|submit/i,+ "Submitting Trustly login step"+ );++ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).then(($body) => {+ const codeInput = $body+ .find(+ 'input[type="tel"], input[inputmode="numeric"], input[name*="code"], input[id*="code"], input[name*="otp"], input[id*="otp"], input[name*="tan"], input[id*="tan"], input[type="text"]'+ )+ .filter(":visible")+ .first();++ if (codeInput.length > 0) {+ cy.wrap(codeInput)+ .clear({ force: true })+ .type("1212121212", { force: true });+ }+ });++ clickFirstVisibleByText(+ /continue|next|submit|confirm|approve|authorize/i,+ "Submitting Trustly verification code"+ );++ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).then(($body) => {+ const accountButton = $body+ .find('button, a, [role="button"], input[type="radio"]')+ .filter((_, el) =>+ /checking|savings|account|continue|confirm|approve|pay|authorize/i.test(+ el.innerText || el.value || el.getAttribute("aria-label") || ""+ )+ )+ .filter(":visible")+ .first();++ if (accountButton.length > 0) {+ cy.wrap(accountButton).click({ force: true });+ }+ });++ cy.wait(30000);+ verifyUrl = false;+ cy.then(() => {+ verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);+ });+ return;+ }++ if (connectorId === "truelayer" && paymentMethodType === "open_banking") {+ cy.visit(redirectionUrl.href, {+ failOnStatusCode: false,+ timeout: CONSTANTS.TIMEOUT,+ });+ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).should("exist");+ cy.url({ timeout: CONSTANTS.TIMEOUT }).should(+ "include",+ "truelayer-sandbox.com"+ );++ const actionSelector =+ 'button, a, [role="button"], input[type="submit"], input[type="button"]';+ const clickAction = (pattern, logMessage) => {+ cy.contains(actionSelector, pattern, { timeout: CONSTANTS.TIMEOUT })+ .should("be.visible")+ .then(($el) => {+ cy.log(logMessage);+ cy.wrap($el).scrollIntoView().click({ force: true });+ });+ };+ const clickActionIfPresent = (pattern, logMessage) => {+ cy.get("body", { timeout: CONSTANTS.TIMEOUT }).then(($body) => {+ const action = $body+ .find(actionSelector)+ .filter((_, el) =>+ pattern.test(+ el.innerText || el.value || el.getAttribute("aria-label") || ""+ )+ )+ .filter(":visible")+ .first();++ if (action.length > 0) {+ cy.log(logMessage);+ cy.wrap(action).scrollIntoView().click({ force: true });+ }+ });+ };+ const editableInputSelector =+ 'input:not([type="hidden"]):not([type="radio"]):not([type="checkbox"]):not([type="submit"]):not([type="button"]):not([disabled])';+ const fillTrueLayerMockCredentials = () => {+ cy.get(editableInputSelector, { timeout: CONSTANTS.TIMEOUT })+ .filter(":visible")+ .should("have.length.at.least", 2)+ .then(($inputs) => {+ const usernameInput = $inputs.eq(0);+ const pinInputs = $inputs+ .filter(+ 'input[type="password"], input[inputmode="numeric"], input[type="tel"], input[name*="pin"], input[id*="pin"]'+ )+ .not(usernameInput);+ const fallbackPinInputs = $inputs.not(usernameInput);+ const pinTargets =+ pinInputs.length > 0 ? pinInputs : fallbackPinInputs;++ cy.log("Entering TrueLayer mock username");+ cy.wrap(usernameInput)+ .scrollIntoView()+ .clear({ force: true })+ .type("test_executed", { force: true });++ cy.log("Entering TrueLayer mock PIN");+ if (pinTargets.length >= 3) {+ ["2", "3", "4"].forEach((digit, index) => {+ cy.wrap(pinTargets.eq(index))+ .scrollIntoView()+ .clear({ force: true })+ .type(digit, { force: true });+ });+ } else {+ cy.wrap(pinTargets.eq(0))+ .scrollIntoView()+ .clear({ force: true })+ .type("234", { force: true });+ }+ });+ };++ clickAction(/go to bank/i, "Opening TrueLayer bank page");+ clickAction(+ /open mock uk payments\s*-\s*redirect flow on this device/i,+ "Opening TrueLayer mock UK payments redirect flow"+ );++ fillTrueLayerMockCredentials();+ clickAction(+ /continue|submit|confirm|authorize/i,+ "Submitting TrueLayer mock flow"+ );+ clickAction(/continue/i, "Continuing after TrueLayer mock submit");+ cy.contains("body", /select account and confirm payment/i, {+ timeout: CONSTANTS.TIMEOUT,+ }).should("be.visible");+ clickAction(+ /continue|confirm|authorize/i,+ "Continuing after TrueLayer account selection"+ );+ cy.contains(+ "body",+ /confirming your payment|in progress|processing your transaction/i,+ {+ timeout: 120000,+ }+ ).should("be.visible");+ cy.url({ timeout: 120000 }).should("include", "truelayer-sandbox.com");+ cy.wait(15000);+ clickActionIfPresent(+ /return to testhyperswitch|return/i,+ "Returning from TrueLayer mock flow"+ );++ verifyUrl = false;+ cy.then(() => {+ verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);+ });+ return;+ }+cy.visit(redirectionUrl.href);waitForRedirect(redirectionUrl.href); // Wait for the first redirectdiff --git a/cypress-tests/cypress/utils/State.js b/cypress-tests/cypress/utils/State.jsindex b056e1e7b3..53854d3048 100644--- a/cypress-tests/cypress/utils/State.js+++ b/cypress-tests/cypress/utils/State.js@@ -1,31 +1,79 @@class State {data = {};constructor(data) {- this.data = data;- this.data["connectorId"] = Cypress.env("CONNECTOR");+ // Initialize data with passed-in state values (enables state inheritance between test contexts)+ this.data = data || {};+ this.data["connectorId"] = this.getEnvOrState("CONNECTOR", "connectorId");// Keep original connector when connectorId gets changed (e.g., stripeconnect -> stripe); optional and defaults to connectorId if not explicitly set.- this.data["originalConnectorId"] = Cypress.env("CONNECTOR");- this.data["baseUrl"] = Cypress.env("BASEURL");- this.data["pmServiceUrl"] = Cypress.env("PM_SERVICE_URL");- this.data["adminApiKey"] = Cypress.env("ADMINAPIKEY");- this.data["email"] = Cypress.env("HS_EMAIL");- this.data["password"] = Cypress.env("HS_PASSWORD");- this.data["connectorAuthFilePath"] = Cypress.env(- "CONNECTOR_AUTH_FILE_PATH"- );- this.data["ucsEnabled"] = Cypress.env("UCS_ENABLED");- this.data["proxyHttp"] = Cypress.env("PROXY_HTTP");- this.data["proxyHttps"] = Cypress.env("PROXY_HTTPS");- this.data["methodFlow"] = Cypress.env("METHOD_FLOW");- this.data["validationServiceUrl"] = Cypress.env("VALIDATION_SERVICE_URL");+ this.data["originalConnectorId"] = this.getEnvOrState(+ "CONNECTOR",+ "originalConnectorId"+ );+ this.data["baseUrl"] = this.getUrlEnvOrState("BASEURL", "baseUrl");+ this.data["pmServiceUrl"] = this.getUrlEnvOrState(+ "PM_SERVICE_URL",+ "pmServiceUrl"+ );this.data["kvEnabled"] = Cypress.env("KV_ENABLED");- this.data["superpositionBaseUrl"] = Cypress.env("SUPERPOSITION_BASE_URL");- this.data["superpositionSecret"] = Cypress.env("SUPERPOSITION_SECRET");- this.data["superpositionApiKey"] = Cypress.env("SUPERPOSITION_API_KEY");- this.data["superpositionOrgId"] = Cypress.env("SUPERPOSITION_ORG_ID");- this.data["superpositionWorkspaceId"] = Cypress.env(- "SUPERPOSITION_WORKSPACE_ID"+ this.data["adminApiKey"] = this.getEnvOrState("ADMINAPIKEY", "adminApiKey");+ this.data["email"] = this.getEnvOrState("HS_EMAIL", "email");+ this.data["password"] = this.getEnvOrState("HS_PASSWORD", "password");+ this.data["connectorAuthFilePath"] = this.getEnvOrState(+ "CONNECTOR_AUTH_FILE_PATH",+ "connectorAuthFilePath"+ );+ this.data["ucsEnabled"] = this.getEnvOrState("UCS_ENABLED", "ucsEnabled");+ this.data["proxyHttp"] = this.getUrlEnvOrState("PROXY_HTTP", "proxyHttp");+ this.data["proxyHttps"] = this.getUrlEnvOrState(+ "PROXY_HTTPS",+ "proxyHttps"+ );+ this.data["methodFlow"] = this.getEnvOrState("METHOD_FLOW", "methodFlow");+ this.data["validationServiceUrl"] = this.getUrlEnvOrState(+ "VALIDATION_SERVICE_URL",+ "validationServiceUrl"+ );+ this.data["superpositionBaseUrl"] = this.getUrlEnvOrState(+ "SUPERPOSITION_BASE_URL",+ "superpositionBaseUrl"+ );+ this.data["superpositionSecret"] = this.getEnvOrState(+ "SUPERPOSITION_SECRET",+ "superpositionSecret"+ );+ this.data["superpositionApiKey"] = this.getEnvOrState(+ "SUPERPOSITION_API_KEY",+ "superpositionApiKey"+ );+ this.data["superpositionOrgId"] = this.getEnvOrState(+ "SUPERPOSITION_ORG_ID",+ "superpositionOrgId");+ this.data["superpositionWorkspaceId"] = this.getEnvOrState(+ "SUPERPOSITION_WORKSPACE_ID",+ "superpositionWorkspaceId"+ );+ }++ getEnvOrState(envKey, stateKey = envKey) {+ const envValue = Cypress.env(envKey);+ return envValue === undefined || envValue === null || envValue === ""+ ? this.data[stateKey]+ : envValue;+ }++ getUrlEnvOrState(envKey, stateKey) {+ return State.sanitizeUrl(this.getEnvOrState(envKey, stateKey));+ }++ static sanitizeUrl(url) {+ if (!url || typeof url !== "string") {+ return url;+ }++ const markdownLinkMatch = url.match(/^\[(https?:\/\/[^\]]+)\]/);+ const normalizedUrl = markdownLinkMatch ? markdownLinkMatch[1] : url;+ return normalizedUrl.trim().replace(/\/+$/, "");}set(key, val) {diff --git a/cypress-tests/cypress/utils/specSelection/config.js b/cypress-tests/cypress/utils/specSelection/config.jsindex af94b215cb..7c0fabc25b 100644--- a/cypress-tests/cypress/utils/specSelection/config.js+++ b/cypress-tests/cypress/utils/specSelection/config.js@@ -60,6 +60,8 @@ export const CONNECTOR_PAYMENT_METHODS = Object.freeze({paystack: ["bank_redirect"],plaid: ["open_banking"],prophetpay: ["card_redirect"],+ truelayer: ["bank_redirect"],+ trustly: ["bank_redirect"],volt: ["bank_redirect"],tsys_transit: ["card"],});