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
test(cypress): add payout link coverage for wise (#12428)
HS-QUALIBOT95cce2d6b836
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Commons.js b/cypress-tests/cypress/e2e/configs/Payout/Commons.jsindex 0606aa5482..210bd73d45 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Commons.js@@ -202,4 +202,106 @@ export const connectorDetails = {},}),},+ payout_link_pm: {+ PayoutLinkBase: getCustomExchange({+ Request: {+ payout_link: true,+ currency: "USD",+ amount: 100,+ description: "Test Payout Link",+ payout_link_config: {+ test_mode: true,+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payout_method_data",+ },+ },+ }),+ PayoutLinkBankTransfer: getCustomExchange({+ Request: {+ payout_link: true,+ currency: "EUR",+ amount: 100,+ description: "Test Payout Link Bank Transfer",+ payout_link_config: {+ test_mode: true,+ enabled_payment_methods: [+ {+ payment_method: "bank_transfer",+ payment_method_types: ["sepa_bank_transfer"],+ },+ ],+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payout_method_data",+ payout_type: "bank",+ },+ },+ }),+ PayoutLinkValidationError: getCustomExchange({+ Request: {+ payout_link: true,+ currency: "USD",+ amount: 100,+ description: "Test missing customer_id",+ customer_id: null,+ payout_link_config: {+ test_mode: true,+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_04",+ message:+ "Missing required param: customer or customer_id when payout_link is true",+ },+ },+ },+ }),+ PayoutLinkConfirmConflict: getCustomExchange({+ Request: {+ payout_link: true,+ confirm: true,+ currency: "USD",+ amount: 100,+ description: "Test confirm + payout_link conflict",+ payout_link_config: {+ test_mode: true,+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "cannot confirm a payout while creating a payout link",+ code: "IR_06",+ },+ },+ },+ }),+ PayoutLinkWithoutLink: getCustomExchange({+ Request: {+ payout_link: false,+ currency: "USD",+ amount: 100,+ description: "Test without payout link",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payout_method_data",+ },+ },+ }),+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.jsindex e35b9ba734..9a7610d09b 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js@@ -91,6 +91,7 @@ export function getValueByKey(jsonObject, key) {export const CONNECTOR_LISTS = {INCLUDE: {ENTITY_TYPE: ["wise"],+ PAYOUT_LINK: ["wise"],},};diff --git a/cypress-tests/cypress/e2e/configs/Payout/Wise.js b/cypress-tests/cypress/e2e/configs/Payout/Wise.jsindex 242b5d605d..4781166df4 100644--- a/cypress-tests/cypress/e2e/configs/Payout/Wise.js+++ b/cypress-tests/cypress/e2e/configs/Payout/Wise.js@@ -415,4 +415,119 @@ export const connectorDetails = {},},},+ payout_link_pm: {+ PayoutLinkBase: {+ Request: {+ payout_link: true,+ currency: "EUR",+ payout_type: "bank",+ payout_link_config: {+ test_mode: true,+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payout_method_data",+ payout_link: {+ payout_link_id: ".*",+ link: ".*",+ },+ },+ },+ },+ PayoutLinkBankTransfer: {+ Request: {+ payout_link: true,+ currency: "EUR",+ amount: 100,+ description: "Test Payout Link Bank Transfer",+ payout_link_config: {+ test_mode: true,+ enabled_payment_methods: [+ {+ payment_method: "bank_transfer",+ payment_method_types: ["sepa_bank_transfer"],+ },+ ],+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payout_method_data",+ payout_link: {+ payout_link_id: ".*",+ link: ".*",+ },+ },+ },+ // BankData holds the test bank credentials (IBAN, BIC) required by the+ // handlePayoutLinkBankRedirection command to simulate a user filling+ // the SEPA bank transfer form on the hosted payout link page.+ // It is placed outside Request/Response because it is neither sent in+ // the API payload nor asserted in the API response.+ BankData: {+ iban: "NL46TEST0136169112",+ bic: "ABNANL2A",+ bank_name: "Test Bank",+ bank_country_code: "NL",+ bank_city: "Amsterdam",+ },+ },+ PayoutLinkValidationError: {+ Request: {+ payout_link: true,+ currency: "EUR",+ amount: 100,+ customer_id: null,+ payout_link_config: {+ test_mode: true,+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_04",+ message:+ "Missing required param: customer or customer_id when payout_link is true",+ },+ },+ },+ },+ PayoutLinkConfirmConflict: {+ Request: {+ payout_link: true,+ currency: "EUR",+ amount: 100,+ confirm: true,+ payout_link_config: {+ test_mode: true,+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "cannot confirm a payout while creating a payout link",+ code: "IR_06",+ },+ },+ },+ },+ PayoutLinkWithoutLink: {+ Request: {+ payout_link: false,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payout_method_data",+ },+ },+ },+ },};diff --git a/cypress-tests/cypress/e2e/spec/Payout/00007-EntityType.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00008-EntityType.cy.jssimilarity index 100%rename from cypress-tests/cypress/e2e/spec/Payout/00007-EntityType.cy.jsrename to cypress-tests/cypress/e2e/spec/Payout/00008-EntityType.cy.jsdiff --git a/cypress-tests/cypress/e2e/spec/Payout/00008-PayoutLinkCreate.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00008-PayoutLinkCreate.cy.jsnew file mode 100644index 0000000000..2189b2ed19--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payout/00008-PayoutLinkCreate.cy.js@@ -0,0 +1,336 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import * as utils from "../../configs/Payout/Utils";++const bpWithPayoutLink = {+ payout_link_config: {+ domain_name: "checkout.example.com",+ allowed_domains: ["*.example.com", "trusted-site.com"],+ ui_config: {+ logo: "https://example.com/logo.png",+ merchant_name: "Test Merchant",+ theme: "#4285F4",+ },+ form_layout: "tabs",+ payout_test_mode: true,+ },+};++let globalState;++describe("Payout Link", () => {+ let shouldContinue = true;++ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);++ if (!globalState.get("payoutsExecution")) {+ shouldContinue = false;+ }++ if (+ !utils.CONNECTOR_LISTS.INCLUDE.PAYOUT_LINK.includes(+ globalState.get("connectorId")+ )+ ) {+ shouldContinue = false;+ }+ })+ .then(() => {+ if (!shouldContinue) {+ this.skip();+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ after("reset business profile payout_link_config", () => {+ cy.resetBusinessProfilePayoutLinkConfig(globalState);+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ context("Payout Link - Basic creation and retrieval", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-with-link-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ data,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-link-test", () => {+ cy.retrievePayoutCallTest(globalState);+ });++ it("list-payout-links-test", () => {+ cy.listPayoutsTest(globalState);+ });++ it("retrieve-payout-call-test", () => {+ cy.retrievePayoutCallTest(globalState);+ });+ });++ context("Payout Link - Create without link", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-without-link-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkWithoutLink"];+ cy.createConfirmPayoutTest(+ fixtures.createPayoutBody,+ data,+ false,+ false,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });+ });++ context("Payout Link - Validation errors", () => {+ it("missing-customer-id-error-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkValidationError"];+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ data,+ globalState+ );+ });++ it("confirm-and-payout-link-conflict-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkConfirmConflict"];+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ data,+ globalState+ );+ });++ it("retrieve-non-existent-payout-link-test", () => {+ cy.retrieveNonExistentPayoutTest(globalState);+ });+ });++ context("Payout Link - Configuration variations", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-link-with-theme-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ const reqData = {+ ...data.Request,+ description: "Test with custom theme",+ payout_link_config: {+ ...data.Request.payout_link_config,+ theme: "#FF6B35",+ },+ };+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ { ...data, Request: reqData },+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("create-payout-link-with-logo-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ const reqData = {+ ...data.Request,+ currency: "EUR",+ description: "Test with merchant logo",+ payout_link_config: {+ ...data.Request.payout_link_config,+ logo: "https://example.com/logo.png",+ merchant_name: "Test Merchant Inc",+ },+ };+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ { ...data, Request: reqData },+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("create-payout-link-with-journey-layout-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ const reqData = {+ ...data.Request,+ currency: "GBP",+ description: "Test with journey layout",+ payout_link_config: {+ ...data.Request.payout_link_config,+ form_layout: "journey",+ },+ };+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ { ...data, Request: reqData },+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("create-payout-link-with-tabs-layout-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ const reqData = {+ ...data.Request,+ currency: "EUR",+ description: "Test with tabs layout",+ payout_link_config: {+ ...data.Request.payout_link_config,+ form_layout: "tabs",+ },+ };+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ { ...data, Request: reqData },+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("create-payout-link-with-custom-id-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ const reqData = {+ ...data.Request,+ description: "Test custom payout link id",+ payout_link_config: {+ ...data.Request.payout_link_config,+ payout_link_id: `custom_payout_link_${Date.now()}`,+ },+ };+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ { ...data, Request: reqData },+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });+ });++ context("Payout Link - Bank transfer form submission", () => {+ let shouldContinue = true;++ before("reset business profile payout_link_config", () => {+ cy.resetBusinessProfilePayoutLinkConfig(globalState);+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("create-payout-link-for-bank-transfer-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBankTransfer"];+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ data,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("Visit payout page and submit bank details", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBankTransfer"];+ cy.handlePayoutLinkBankRedirection(globalState, data.BankData, "success");+ });++ it("retrieve-payout-after-bank-submission-test", function () {+ cy.retrievePayoutCallTest(globalState);+ });+ });++ context("Payout Link - Profile-level configuration", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("update-business-profile-with-payout-link-config-test", () => {+ cy.UpdateBusinessProfileTest(+ bpWithPayoutLink,+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ globalState+ );+ });++ it("create-payout-link-using-profile-config-test", () => {+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[+ "payout_link_pm"+ ]["PayoutLinkBase"];+ cy.createPayoutWithLinkTest(+ fixtures.createPayoutLinkBody,+ data,+ globalState+ );+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);+ });++ it("retrieve-payout-link-profile-config-test", () => {+ cy.retrievePayoutCallTest(globalState);+ });+ });+});diff --git a/cypress-tests/cypress/fixtures/create-payout-link-body.json b/cypress-tests/cypress/fixtures/create-payout-link-body.jsonnew file mode 100644index 0000000000..1cb5c07633--- /dev/null+++ b/cypress-tests/cypress/fixtures/create-payout-link-body.json@@ -0,0 +1,34 @@+{+ "amount": 100,+ "currency": "USD",+ "email": "[email protected]",+ "name": "John Doe",+ "phone": "999999999",+ "phone_country_code": "+65",+ "description": "Payout link test request",+ "billing": {+ "address": {+ "line1": "1467",+ "line2": "Harrison Street",+ "line3": "Harrison Street",+ "city": "San Francisco",+ "state": "NY",+ "zip": "94122",+ "country": "US",+ "first_name": "John",+ "last_name": "Doe"+ },+ "phone": {+ "number": "9123456789",+ "country_code": "+91"+ }+ },+ "entity_type": "Individual",+ "recurring": false,+ "metadata": {+ "ref": "123"+ },+ "payout_link": true,+ "confirm": false,+ "auto_fulfill": false+}diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.jsindex 559935033b..e14229d2e8 100644--- a/cypress-tests/cypress/fixtures/imports.js+++ b/cypress-tests/cypress/fixtures/imports.js@@ -9,6 +9,7 @@ import customerCreateBody from "./create-customer-body.json";import citConfirmBody from "./create-mandate-cit.json";import mitConfirmBody from "./create-mandate-mit.json";import createPaymentBody from "./create-payment-body.json";+import createPayoutLinkBody from "./create-payout-link-body.json";import createPayoutBody from "./create-payout-confirm-body.json";import payoutRoutingConfigBody from "./payout-routing-config-body.json";import pmIdConfirmBody from "./create-pm-id-mit.json";@@ -55,6 +56,7 @@ export {createConnectorBody,createPaymentBody,createPayoutBody,+ createPayoutLinkBody,customerCreateBody,customerUpdateBody,disputeEvidenceBody,diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex c486f92a61..6a19be2fd7 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -10341,3 +10341,193 @@ Cypress.Commands.add(});});++// ============================================+// Payout Link Commands+// ============================================++/**+ * Creates a payout with payout_link enabled.+ * Separate from createConfirmPayoutTest because:+ * 1. It validates payout_link object in the response (link, payout_link_id)+ * 2. It sets profile_id instead of confirm/auto_fulfill flags+ * 3. It handles special customer_id null deletion for validation error tests+ */+Cypress.Commands.add(+ "createPayoutWithLinkTest",+ (createPayoutBody, data, globalState) => {+ const { Request: reqData = {}, Response: resData = {} } = data || {};++ const profileId =+ globalState.get("profileId") || globalState.get("defaultProfileId");++ const requestBody = {+ ...createPayoutBody,+ ...reqData,+ profile_id: profileId,+ };++ // Use the real customer ID from global state unless the test config+ // explicitly sets customer_id (e.g. null for validation error tests).+ if (!("customer_id" in reqData)) {+ requestBody.customer_id = globalState.get("customerId");+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payouts/create`,+ headers: {+ "Content-Type": "application/json",+ Accept: "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");++ if (response.status === 200) {+ expect(response.status).to.equal(200);+ expect(response.body).to.have.property("payout_id");+ expect(response.body).to.have.property("payout_link");+ expect(response.body.payout_link).to.have.property("link");+ expect(response.body.payout_link).to.have.property("payout_link_id");++ if (resData.body) {+ for (const key in resData.body) {+ if (key === "payout_link") {+ // payout_link is already validated above; skip deep-equal+ // because config uses regex patterns (e.g. ".*") which+ // deep.equal cannot match against dynamic IDs/URLs.+ continue;+ }+ expect(response.body[key]).to.deep.equal(resData.body[key]);+ }+ }++ globalState.set("payoutID", response.body.payout_id);+ globalState.set(+ "payoutLinkId",+ response.body.payout_link.payout_link_id+ );+ globalState.set("payoutLinkUrl", response.body.payout_link.link);+ globalState.set("payoutAmount", requestBody.amount);++ cy.task(+ "cli_log",+ `Payout Link created: ${response.body.payout_link.payout_link_id}`+ );+ } else {+ defaultErrorHandler(response, resData);+ }+ });+ });+ }+);++Cypress.Commands.add("initiatePayoutLinkTest", (data, globalState) => {+ const payoutLinkUrl = globalState.get("payoutLinkUrl");++ if (!payoutLinkUrl) {+ cy.task("cli_log", "Skipping: No payout link URL available");+ return;+ }++ const redirectionUrl = new URL(payoutLinkUrl);+ handleRedirection("payout_link_init", { redirectionUrl }, null, null, {});+});++Cypress.Commands.add(+ "handlePayoutLinkBankRedirection",+ (globalState, bankData, expectedOutcome = "success") => {+ const payoutLinkUrl = globalState.get("payoutLinkUrl");++ if (!payoutLinkUrl) {+ cy.task("cli_log", "Skipping: No payout link URL available");+ return;+ }++ const connectorId = globalState.get("connectorId") || "stripe";+ const redirectionUrl = new URL(payoutLinkUrl);+ const expectedUrl = new URL("https://example.com/return");++ handleRedirection(+ "payout_link",+ { redirectionUrl, expectedUrl },+ connectorId,+ null,+ { bankData, expectedOutcome, payoutLinkType: "bank" }+ );+ }+);++/**+ * Resets the business profile's payout_link_config to null.+ * Used in before/after hooks to ensure a clean state between test contexts.+ *+ * @param {Object} globalState - The global state object+ */+Cypress.Commands.add("resetBusinessProfilePayoutLinkConfig", (globalState) => {+ const profileId =+ globalState.get("profileId") || globalState.get("defaultProfileId");+ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/account/${globalState.get("merchantId")}/business_profile/${profileId}`,+ headers: {+ Accept: "application/json",+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ body: {+ payout_link_config: null,+ },+ failOnStatusCode: false,+ }).then((response) => {+ expect(response.status).to.equal(200);+ });+});++/**+ * Lists payouts and validates the response structure.+ *+ * @param {Object} globalState - The global state object+ */+Cypress.Commands.add("listPayoutsTest", (globalState) => {+ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/payouts/list?limit=10`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);+ expect(response.status).to.equal(200);+ expect(response.body).to.have.property("data");+ expect(response.body.data).to.be.an("array");+ });+});++/**+ * Retrieves a non-existent payout and verifies a 404 response.+ *+ * @param {Object} globalState - The global state object+ */+Cypress.Commands.add("retrieveNonExistentPayoutTest", (globalState) => {+ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/payouts/non_existent_payout_12345`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);+ expect(response.status).to.equal(404);+ });+});diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 0b180537d0..36effa53c7 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -133,6 +133,18 @@ export function handleRedirection(handlerMetadata);break;+ case "payout_link":+ payoutLinkRedirection(+ urls.redirectionUrl,+ urls.expectedUrl,+ resolvedConnectorId,+ paymentMethodType,+ handlerMetadata+ );+ break;+ case "payout_link_init":+ payoutLinkInitRedirection(urls.redirectionUrl);+ break;default:throw new Error(`Unknown redirection type: ${redirectionType}`);}@@ -3278,16 +3290,16 @@ function paymentLinkCardRedirection(cy.get("body", { timeout: 30000 }).should("exist");- cy.get("#sdk-spinner", { timeout: 60000 }).should("have.class", "hidden");- cy.task("cli_log", "Payment Link SDK initialized successfully");+ // Wait for SDK form elements directly — skip #sdk-spinner check which times out+ // on bank-transfer payout link pages where the form loads without a loading spinner+ cy.get("#unified-checkout, #payment-form", { timeout: 60000 })+ .should("exist")+ .and("be.visible");- cy.get("#unified-checkout", { timeout: 30000 }).should("be.visible");- cy.get("#payment-form", { timeout: 30000 }).should("exist");-- cy.get("#unified-checkout iframe", { timeout: 30000 }).should(- "have.length.at.least",- 1- );+ cy.get("#unified-checkout iframe, #payment-form iframe", {+ timeout: 30000,+ }).should("have.length.at.least", 1);+ cy.task("cli_log", "Payout Link bank form iframe ready");function fillCardInputInIframe(iframe, index) {cy.wrap(iframe)@@ -3302,7 +3314,7 @@ function paymentLinkCardRedirection(return;}- inputs.each((_, input) => {+ inputs.each((_idx, input) => {const $input = Cypress.$(input);const placeholder = ($input.attr("placeholder") || "").toLowerCase();const ariaLabel = ($input.attr("aria-label") || "").toLowerCase();@@ -3423,6 +3435,371 @@ function paymentLinkCardRedirection(}}+/**+ * Handles the initial visit to a payout link page.+ * Visits the payout link URL, waits for the SDK to load, and verifies+ * that the #payout-link container has rendered content and the SDK+ * iframe is present.+ *+ * @param {URL} redirectionUrl - The payout link URL to visit+ * @param {Object} handlerMetadata - Optional metadata (unused but kept for consistency)+ */+function payoutLinkInitRedirection(redirectionUrl) {+ if (!redirectionUrl || !redirectionUrl.href) {+ cy.log("Skipping payout link init - no valid redirect URL provided");+ return;+ }++ cy.visit(redirectionUrl.href, { failOnStatusCode: false });++ cy.get("body", { timeout: 30000 }).should("exist");++ // Payout link pages use #payout-link as the SDK mount container, not+ // #unified-checkout or #payment-form. There is no #sdk-spinner element on+ // these pages — waiting for it causes a 60-second timeout that makes the+ // page appear blank. Instead, wait for the SDK to render content inside+ // #payout-link and for the iframe to appear.+ cy.get("#payout-link", { timeout: 60000 }).should("not.be.empty");+ cy.task("cli_log", "Payout Link SDK initialized");++ cy.get("#payout-link iframe", { timeout: 30000 }).should(+ "have.length.at.least",+ 1+ );+}++function payoutLinkRedirection(+ redirectionUrl,+ expectedUrl,+ connectorId,+ paymentMethodType,+ handlerMetadata+) {+ if (handlerMetadata?.payoutLinkType === "card") {+ return payoutLinkCardRedirection(+ redirectionUrl,+ expectedUrl,+ connectorId,+ paymentMethodType,+ handlerMetadata+ );+ }++ const expectedOutcome = handlerMetadata?.expectedOutcome || "success";+ const bankData = handlerMetadata?.bankData || {};+ const IBAN = bankData.iban || "NL46TEST0136169112";+ const BIC = bankData.bic || "ABNANL2A";++ cy.on("uncaught:exception", () => false);++ if (!redirectionUrl || !redirectionUrl.href) {+ cy.log(+ "Skipping payout link bank redirection - no valid redirect URL provided"+ );+ return;+ }++ cy.visit(redirectionUrl.href, { failOnStatusCode: false });+ cy.get("body", { timeout: 30000 }).should("exist");++ // Payout link pages use #payout-link as the SDK mount container.+ // Wait for the SDK to render content and for the iframe to appear.+ cy.get("#payout-link", { timeout: 60000 }).should("not.be.empty");+ cy.task("cli_log", "Payout Link SDK initialized");++ cy.get("#payout-link iframe", { timeout: 30000 }).should(+ "have.length.at.least",+ 1+ );+ cy.task(+ "cli_log",+ "Payout link page loaded — looking for SEPA IBAN and BIC inputs"+ );++ // Helper: get a fresh reference to the iframe body each time.+ // Re-fetching handles iframe re-renders between actions (e.g. after+ // clicking Save the SDK may transition to a confirmation view).+ function getIframeBody() {+ return cy+ .get("#payout-link iframe")+ .first()+ .its("0.contentDocument.body")+ .should("not.be.empty");+ }++ // Fill IBAN input inside the iframe.+ // .find().should("exist") retries until the element appears and FAILS+ // if it never does — no silent skipping like the old approach.+ /* eslint-disable cypress/no-force */+ getIframeBody().then((iframeBody) => {+ cy.wrap(iframeBody)+ .find('input[id="sepa.iban"]')+ .should("exist")+ .and("be.visible")+ .clear({ force: true })+ .type(IBAN, { delay: 30, force: true });+ cy.task("cli_log", "IBAN filled");+ });++ // Fill BIC input inside the iframe+ getIframeBody().then((iframeBody) => {+ cy.wrap(iframeBody)+ .find('input[id="sepa.bic"]')+ .should("exist")+ .and("be.visible")+ .clear({ force: true })+ .type(BIC, { delay: 30, force: true });+ cy.task("cli_log", "BIC filled");+ });++ // Click Save button inside the iframe.+ // .contains("button", "Save") retries until the button appears and+ // FAILS if it never does — no silent skipping.+ getIframeBody().then((iframeBody) => {+ cy.wrap(iframeBody)+ .contains("button", "Save")+ .should("be.visible")+ .click({ force: true });+ cy.task("cli_log", "Save button clicked (first submission)");+ });++ // Brief wait for the SDK to process Save and transition to the+ // confirmation step where the Submit button appears.+ /* eslint-disable cypress/no-unnecessary-waiting */+ cy.wait(2000);+ /* eslint-enable cypress/no-unnecessary-waiting */++ // Click Submit button inside the iframe.+ // .contains("button", "Submit") retries until the button appears.+ getIframeBody().then((iframeBody) => {+ cy.wrap(iframeBody)+ .contains("button", "Submit")+ .should("be.visible")+ .click({ force: true });+ cy.task("cli_log", "Submit button clicked (second submission)");+ });+ /* eslint-enable cypress/no-force */++ // Assert on the result+ if (expectedOutcome === "error") {+ cy.get("body", { timeout: 30000 }).should(($body) => {+ const bodyText = $body.text().toLowerCase();+ const hasError =+ (bodyText.includes("error") && bodyText.includes("bank")) ||+ bodyText.includes("declined") ||+ bodyText.includes("invalid") ||+ bodyText.includes("failed") ||+ $body.find('[class*="error"]').length > 0;+ expect(hasError, "Expected error indicator on payout page").to.be.true;+ });+ cy.task("cli_log", "Payout page shows error indicator as expected");+ } else {+ // After successful submission, the page must show a specific+ // success/processing indicator. We check both the iframe content+ // and the main page text using a retry-able .should() callback+ // so Cypress waits for the indicator to appear (up to 30s).+ //+ // Only specific phrases are checked — NOT generic "success" which+ // can appear on the page without actual form submission.+ getIframeBody().should((iframeBody) => {+ const iframeText = (iframeBody.innerText || "").toLowerCase();+ const mainText = (Cypress.$("body").text() || "").toLowerCase();+ const allText = iframeText + " " + mainText;+ const hasPayoutProcessing = allText.includes("payout processing");+ const hasRequiresFulfillment = allText.includes("requires_fulfillment");+ const hasPayoutSuccessful = allText.includes("payout successful");+ expect(+ hasPayoutProcessing || hasRequiresFulfillment || hasPayoutSuccessful,+ `Expected "payout processing", "requires_fulfillment", or "payout successful" after payout confirm. Page text: ${allText.substring(0, 400)}`+ ).to.be.true;+ });+ cy.task("cli_log", "Payout submission success/processing indicator found");+ }+}++function payoutLinkCardRedirection(+ redirectionUrl,+ expectedUrl,+ connectorId,+ paymentMethodType,+ handlerMetadata+) {+ const cardData = handlerMetadata?.cardData || {};+ const expectedOutcome = handlerMetadata?.expectedOutcome || "success";+ const {+ card_number = "4242424242424242",+ card_exp_month = "12",+ card_exp_year = "35",+ card_cvc = "123",+ } = cardData;++ if (!redirectionUrl || !redirectionUrl.href) {+ cy.log(+ "Skipping payout link card redirection - no valid redirect URL provided"+ );+ return;+ }++ cy.visit(redirectionUrl.href, { failOnStatusCode: false });++ cy.get("body", { timeout: 30000 }).should("exist");++ // Payout link pages use #payout-link as the SDK mount container, not+ // #unified-checkout or #payment-form. There is no #sdk-spinner element on+ // these pages — waiting for it causes a 60-second timeout that makes the+ // page appear blank. Instead, wait for the SDK to render content inside+ // #payout-link and for the iframe to appear.+ cy.get("#payout-link", { timeout: 60000 }).should("not.be.empty");+ cy.task("cli_log", "Payout Link SDK initialized successfully");++ cy.get("#payout-link iframe", { timeout: 30000 }).should(+ "have.length.at.least",+ 1+ );++ function fillCardInputInIframe(iframe, index) {+ cy.wrap(iframe)+ .its("0.contentDocument.body")+ .should("not.be.empty")+ .then((body) => {+ const $body = Cypress.$(body);+ const inputs = $body.find("input");++ if (inputs.length === 0) {+ cy.task("cli_log", `Iframe ${index}: no inputs found, skipping`);+ return;+ }++ inputs.each((_idx, input) => {+ const $input = Cypress.$(input);+ const placeholder = ($input.attr("placeholder") || "").toLowerCase();+ const ariaLabel = ($input.attr("aria-label") || "").toLowerCase();+ const name = ($input.attr("name") || "").toLowerCase();+ const autocomplete = (+ $input.attr("autocomplete") || ""+ ).toLowerCase();++ if (+ placeholder.includes("card") ||+ placeholder.includes("number") ||+ ariaLabel.includes("card") ||+ ariaLabel.includes("number") ||+ name.includes("cardnumber") ||+ name.includes("card_number") ||+ autocomplete.includes("cc-number")+ ) {+ /* eslint-disable cypress/no-force */+ cy.wrap(input)+ .focus()+ .clear({ force: true })+ .type(card_number, { delay: 30, force: true });+ /* eslint-enable cypress/no-force */+ cy.task("cli_log", `Filled card number in iframe ${index}`);+ } else if (+ placeholder.includes("expir") ||+ placeholder.includes("mm") ||+ placeholder.includes("yy") ||+ ariaLabel.includes("expir") ||+ name.includes("exp") ||+ autocomplete.includes("cc-exp")+ ) {+ /* eslint-disable cypress/no-force */+ cy.wrap(input)+ .focus()+ .clear({ force: true })+ .type(`${card_exp_month}${card_exp_year.slice(-2)}`, {+ delay: 30,+ force: true,+ });+ /* eslint-enable cypress/no-force */+ cy.task("cli_log", `Filled expiry in iframe ${index}`);+ } else if (+ placeholder.includes("cvc") ||+ placeholder.includes("cvv") ||+ placeholder.includes("security") ||+ ariaLabel.includes("cvc") ||+ ariaLabel.includes("cvv") ||+ name.includes("cvc") ||+ name.includes("cvv") ||+ autocomplete.includes("cc-csc")+ ) {+ /* eslint-disable cypress/no-force */+ cy.wrap(input)+ .focus()+ .clear({ force: true })+ .type(card_cvc, { delay: 30, force: true });+ /* eslint-enable cypress/no-force */+ cy.task("cli_log", `Filled CVC in iframe ${index}`);+ }+ });+ });+ }++ cy.get("#payout-link iframe").then(($iframes) => {+ cy.task("cli_log", `Found ${$iframes.length} iframes in payout-link`);++ $iframes.each((index, iframe) => {+ fillCardInputInIframe(iframe, index);+ });+ });++ /* eslint-disable cypress/no-force */+ cy.get("#submit", { timeout: 30000 })+ .should("be.visible")+ .and("not.have.class", "hidden")+ .click({ force: true });+ /* eslint-enable cypress/no-force */+ cy.task("cli_log", "Clicked submit button");++ if (expectedOutcome === "error") {+ cy.get("body", { timeout: 30000 }).should(($body) => {+ const bodyText = $body.text().toLowerCase();+ const hasError =+ (bodyText.includes("error") && bodyText.includes("card")) ||+ bodyText.includes("declined") ||+ bodyText.includes("invalid") ||+ bodyText.includes("expired") ||+ bodyText.includes("failed") ||+ $body.find('[class*="error"]').length > 0;+ expect(hasError, "Expected error indicator on payout page").to.be.true;+ });+ cy.task("cli_log", "Payout page shows error indicator as expected");+ } else {+ cy.contains(/succeeded|success|payout successful|thank you/i, {+ timeout: 30000,+ }).should("exist");++ cy.get("body").then(($body) => {+ const bodyText = $body.text().toLowerCase();+ const hasSuccess =+ bodyText.includes("succeeded") ||+ bodyText.includes("success") ||+ bodyText.includes("payout successful") ||+ bodyText.includes("thank you") ||+ $body.find('[class*="success"]').length > 0;+ const hasError =+ (bodyText.includes("error") && bodyText.includes("card")) ||+ bodyText.includes("declined") ||+ bodyText.includes("invalid") ||+ $body.find('[class*="error"]').length > 0;++ if (hasSuccess) {+ cy.task("cli_log", "Payout page shows success indicator");+ } else if (hasError) {+ cy.task("cli_log", "Payout page shows error indicator");+ } else {+ cy.task(+ "cli_log",+ "Payout page status unclear after submission - checking URL"+ );+ cy.url().then((url) => {+ cy.task("cli_log", `Current URL after payout submission: ${url}`);+ });+ }+ });+ }+}+function handleFlow(redirectionUrl,expectedUrl,