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 Payment Link coverage to core flows (#12023)
HS-QUALIBOT8b2871bfa3d1
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 0720fee7d4..7dc144cf65 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -3624,6 +3624,132 @@ export const connectorDetails = {},}),},+ payment_link_pm: {+ PaymentLinkBasic: getCustomExchange({+ Request: {+ currency: "USD",+ amount: 6000,+ description: "Test Payment Link",+ email: "[email protected]",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ }),++ PaymentLinkWithTheme: getCustomExchange({+ Request: {+ currency: "USD",+ amount: 7000,+ description: "Test with custom theme",+ email: "[email protected]",+ payment_link_config: {+ theme: "#FF6B35",+ },+ },+ Response: {+ status: 200,+ },+ }),+ PaymentLinkWithLogo: getCustomExchange({+ Request: {+ currency: "EUR",+ amount: 8000,+ description: "Test with merchant logo",+ email: "[email protected]",+ payment_link_config: {+ logo: "https://example.com/logo.png",+ seller_name: "Test Merchant Inc",+ },+ },+ Response: {+ status: 200,+ },+ }),+ PaymentLinkWithSdkLayout: getCustomExchange({+ Request: {+ currency: "GBP",+ amount: 5500,+ description: "Test with accordion layout",+ email: "[email protected]",+ payment_link_config: {+ sdk_layout: "accordion",+ display_sdk_only: false,+ },+ },+ Response: {+ status: 200,+ },+ }),+ PaymentLinkCardPayment: getCustomExchange({+ Request: {+ currency: "USD",+ amount: 6000,+ description: "Test Payment Link Card Payment",+ email: "[email protected]",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ CardData: {+ card_number: "4242424242424242",+ card_exp_month: "12",+ card_exp_year: "35",+ card_cvc: "123",+ },+ }),+ PaymentLink3DSCard: getCustomExchange({+ Request: {+ currency: "USD",+ amount: 6000,+ description: "Test Payment Link 3DS Card",+ email: "[email protected]",+ authentication_type: "three_ds",+ },+ CardData: {+ card_number: "4000002500003155",+ card_exp_month: "12",+ card_exp_year: "35",+ card_cvc: "123",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_capture",+ },+ },+ }),+ PaymentLinkTabsLayout: getCustomExchange({+ Request: {+ currency: "EUR",+ amount: 6500,+ description: "Test with tabs layout",+ email: "[email protected]",+ payment_link_config: {+ sdk_layout: "tabs",+ display_sdk_only: false,+ },+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ CardData: {+ card_number: "4242424242424242",+ card_exp_month: "12",+ card_exp_year: "35",+ card_cvc: "123",+ },+ }),+ },relay_pm: {RefundRelay: {Request: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 54214e4020..d79aa85cd0 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -561,6 +561,7 @@ export const CONNECTOR_LISTS = {PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],USE_BILLING_AS_PAYMENT_METHOD_BILLING: ["bankofamerica"],MIT_WITH_LIMITED_CARD_DATA: ["peachpayments"],+ PAYMENT_LINK_CARD: ["stripe"],ORDER_DETAILS: ["stripe","cybersource",diff --git a/cypress-tests/cypress/e2e/spec/Payment/48-PaymentLink.cy.js b/cypress-tests/cypress/e2e/spec/Payment/48-PaymentLink.cy.jsnew file mode 100644index 0000000000..d652c8b109--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/48-PaymentLink.cy.js@@ -0,0 +1,230 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, {+ CONNECTOR_LISTS,+ shouldIncludeConnector,+} from "../../configs/Payment/Utils";++let globalState;+let connector;++describe("Payment Link", () => {+ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ connector = globalState.get("connectorId");++ if (+ shouldIncludeConnector(+ connector,+ CONNECTOR_LISTS.INCLUDE.PAYMENT_LINK_CARD+ )+ ) {+ skip = true;+ return;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ beforeEach(function () {+ if (+ Cypress.browser.isHeadless &&+ (this.currentTest.title.startsWith("Visit payment page") ||+ this.currentTest.title.startsWith("Retrieve Payment after"))+ ) {+ cy.log(+ "Skipping payment link UI test in headless mode — SDK requires headed browser"+ );+ this.skip();+ }+ });++ context("Payment Link - Basic creation and retrieval", () => {+ it("Create Payment Intent with Payment Link", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkBasic"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Initiate Payment Link (Customer-Facing)", () => {+ cy.initiatePaymentLinkTest({}, globalState);+ });++ it("Retrieve Payment Link (Merchant API)", () => {+ cy.retrievePaymentLinkTest({}, globalState);+ });++ it("List Payment Links", () => {+ cy.listPaymentLinksTest({}, globalState);+ });+ });++ context("Payment Link - Create and Pay with Card", () => {+ it("Create Payment Intent with Payment Link", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkBasic"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Visit payment page and confirm with card (UI)", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkCardPayment"];+ cy.handlePaymentLinkCardRedirection(globalState, data.CardData);+ });++ it("Retrieve Payment after card payment", () => {+ cy.retrievePaymentCallTest({+ globalState,+ data: {+ Configs: {+ skipConnectorIdAssertion: true,+ skipBillingAssertion: true,+ },+ },+ });+ });+ });++ context("Payment Link - Configuration Variations", () => {+ it("Create Payment Link with custom theme color", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkWithTheme"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ cy.retrievePaymentLinkTest({}, globalState);+ cy.initiatePaymentLinkTest({}, globalState);+ });++ it("Create Payment Link with merchant logo", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkWithLogo"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ cy.retrievePaymentLinkTest({}, globalState);+ cy.initiatePaymentLinkTest({}, globalState);+ });++ it("Create Payment Link with accordion SDK layout", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkWithSdkLayout"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ cy.retrievePaymentLinkTest({}, globalState);+ cy.initiatePaymentLinkTest({}, globalState);+ });++ it("Create Payment Link with tabs SDK layout", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkTabsLayout"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ cy.retrievePaymentLinkTest({}, globalState);+ cy.initiatePaymentLinkTest({}, globalState);+ });++ it("Visit payment page with tabs layout and confirm with card", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLinkTabsLayout"];+ cy.handlePaymentLinkCardRedirection(globalState, data.CardData);+ });+ });++ context("Payment Link - 3DS Card Flow", () => {+ it("Create Payment Intent with Payment Link for 3DS card", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLink3DSCard"];+ cy.createPaymentIntentWithPaymentLinkTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );+ });++ it("Visit payment page and confirm with 3DS card", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "payment_link_pm"+ ]["PaymentLink3DSCard"];+ cy.handlePaymentLinkCardRedirection(globalState, data.CardData);+ });++ it("Retrieve Payment after 3DS card payment", () => {+ cy.retrievePaymentCallTest({+ globalState,+ data: {+ Configs: {+ skipConnectorIdAssertion: true,+ skipBillingAssertion: true,+ },+ },+ });+ });+ });++ context("Payment Link - Edge Cases", () => {+ it("Create Payment Intent without Payment Link - should not have payment_link in response", () => {+ cy.createPaymentWithoutPaymentLinkTest(+ fixtures.createPaymentBody,+ globalState+ );+ });++ it("Retrieve non-existent Payment Link - should return 404", () => {+ cy.retrieveNonExistentPaymentLinkTest(globalState);+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 042743c1f8..c5944d5291 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -3725,7 +3725,9 @@ Cypress.Commands.add(globalState.get("paymentAmount"));expect(response.body.profile_id, "profile_id").to.not.be.null;- expect(response.body.billing, "billing_address").to.not.be.null;+ if (!configs.skipBillingAssertion) {+ expect(response.body.billing, "billing_address").to.not.be.null;+ }expect(response.body.customer, "customer").to.not.be.empty;if (expectedIntentStatus) {@@ -3750,10 +3752,12 @@ Cypress.Commands.add(.not.be.empty;expect(response.body.payment_method, "payment_method").to.not.be.null;- expect(- response.body.merchant_connector_id,- "connector_id"- ).to.equal(merchant_connector_id);+ if (!configs.skipConnectorIdAssertion) {+ expect(+ response.body.merchant_connector_id,+ "connector_id"+ ).to.equal(merchant_connector_id);+ }}if (@@ -4808,6 +4812,38 @@ Cypress.Commands.add(});+Cypress.Commands.add(+ "handlePaymentLinkCardRedirection",+ (globalState, cardData, expectedOutcome = "success") => {+ const paymentLinkUrl = globalState.get("paymentLinkUrl");++ if (!paymentLinkUrl) {+ cy.task("cli_log", "Skipping: No payment link URL available");+ return;+ }++ if (RequestBodyUtils.isCI()) {+ cy.task(+ "cli_log",+ "Skipping card UI interaction in CI - payment link SDK iframe automation not supported in headless mode"+ );+ return;+ }++ const connectorId = globalState.get("connectorId") || "stripe";+ const redirectionUrl = new URL(paymentLinkUrl);+ const expectedUrl = new URL("https://example.com/return");++ handleRedirection(+ "payment_link_card",+ { redirectionUrl, expectedUrl },+ connectorId,+ null,+ { cardData, expectedOutcome }+ );+ }+);+Cypress.Commands.add("confirmRealTimePaymentCallTest",(confirmBody, data, confirm, globalState) => {@@ -8260,6 +8296,85 @@ Cypress.Commands.add("updateCardIssuer", (id, body, globalState) => {});});+// ============================================+// Payment Link Commands+// ============================================++Cypress.Commands.add(+ "createPaymentIntentWithPaymentLinkTest",+ (+ createPaymentBody,+ data,+ authentication_type,+ capture_method,+ globalState+ ) => {+ const { Request: reqData = {}, Response: resData = {} } = data || {};++ const profile_id =+ globalState.get("profileId") || globalState.get("defaultProfileId");++ const requestBody = {+ ...createPaymentBody,+ ...reqData,+ authentication_type: authentication_type || "no_three_ds",+ capture_method: capture_method || "automatic",+ customer_id: globalState.get("customerId"),+ profile_id: profile_id,+ payment_link: true,+ return_url: reqData.return_url || "https://example.com/return",+ };++ globalState.set("paymentAmount", requestBody.amount);++ const headers = {+ "Content-Type": "application/json",+ Accept: "application/json",+ "api-key": globalState.get("apiKey"),+ };++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments`,+ headers,+ 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 (resData.status === 200 || response.status === 200) {+ expect(response.status).to.equal(200);+ expect(response.body).to.have.property("payment_id");+ expect(response.body).to.have.property("client_secret");+ expect(response.body).to.have.property("payment_link");+ expect(response.body.payment_link).to.have.property("link");+ expect(response.body.payment_link).to.have.property(+ "payment_link_id"+ );++ globalState.set("paymentID", response.body.payment_id);+ globalState.set("clientSecret", response.body.client_secret);+ globalState.set(+ "paymentLinkId",+ response.body.payment_link.payment_link_id+ );+ globalState.set("paymentLinkUrl", response.body.payment_link.link);++ cy.task(+ "cli_log",+ `Payment Link created: ${response.body.payment_link.payment_link_id}`+ );+ } else {+ defaultErrorHandler(response, resData);+ }+ });+ });+ }+);+// ============================================// OIDC Authentication Commands// ============================================@@ -8443,6 +8558,177 @@ Cypress.Commands.add(});+Cypress.Commands.add("initiatePaymentLinkTest", (data, globalState) => {+ const paymentLinkUrl = globalState.get("paymentLinkUrl");++ if (!paymentLinkUrl) {+ cy.task("cli_log", "Skipping: No payment link URL available");+ return;+ }++ const runningInCI = RequestBodyUtils.isCI();++ if (runningInCI) {+ cy.request({+ method: "GET",+ url: paymentLinkUrl,+ failOnStatusCode: false,+ followRedirect: true,+ timeout: 30000,+ }).then((response) => {+ const contentType = response.headers["content-type"] || "";+ const isHtml = contentType.includes("text/html");++ if (response.status === 200 && isHtml) {+ const bodyText = typeof response.body === "string" ? response.body : "";+ const hasHyperLoader =+ bodyText.includes("HyperLoader") ||+ bodyText.includes("hyperloader-sdk");++ if (hasHyperLoader) {+ cy.task(+ "cli_log",+ "Payment Link page validated (CI): contains HyperLoader SDK"+ );+ } else {+ cy.task(+ "cli_log",+ `Payment Link page validated (CI): status=${response.status}, body length=${bodyText.length}`+ );+ }++ expect(response.status).to.equal(200);+ expect(isHtml).to.be.true;+ } else {+ cy.task(+ "cli_log",+ `Payment Link non-HTML or error response (CI): status=${response.status}, content-type=${contentType}`+ );+ expect(response.status).to.equal(200);+ }+ });+ } else {+ cy.visit(paymentLinkUrl, { failOnStatusCode: false });++ cy.get("body", { timeout: 30000 }).then(($body) => {+ const bodyText = $body.text() || "";+ const hasHyperLoader =+ bodyText.includes("HyperLoader") ||+ $body.find("#hyperloader-sdk").length > 0;++ if (hasHyperLoader) {+ cy.task("cli_log", "Payment Link page loaded with HyperLoader SDK");+ } else {+ cy.task(+ "cli_log",+ `Payment Link page loaded (body length: ${bodyText.length})`+ );+ }+ });+ }+});++Cypress.Commands.add("retrievePaymentLinkTest", (data, globalState) => {+ const paymentLinkId = globalState.get("paymentLinkId");+ const apiKey = globalState.get("apiKey");+ const baseUrl = globalState.get("baseUrl");++ if (!paymentLinkId) {+ cy.task("cli_log", "Skipping: No payment link ID available");+ return;+ }++ cy.request({+ method: "GET",+ url: `${baseUrl}/payment_link/${paymentLinkId}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": apiKey,+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.status).to.equal(200);+ expect(response.headers["content-type"]).to.include("application/json");+ expect(response.body).to.have.property("payment_link_id", paymentLinkId);+ expect(response.body).to.have.property("link_to_pay");+ expect(response.body).to.have.property("status");++ cy.task("cli_log", `Payment Link retrieved: ${response.body.status}`);+ });+ });+});++Cypress.Commands.add("listPaymentLinksTest", (data, globalState) => {+ const apiKey = globalState.get("apiKey");+ const baseUrl = globalState.get("baseUrl");++ cy.request({+ method: "POST",+ url: `${baseUrl}/payment_link/list`,+ headers: {+ "Content-Type": "application/json",+ "api-key": apiKey,+ },+ body: {+ limit: 10,+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.status).to.equal(200);+ expect(response.headers["content-type"]).to.include("application/json");+ expect(response.body).to.be.an("array");++ cy.task("cli_log", `Listed ${response.body.length} payment links`);+ });+ });+});++Cypress.Commands.add(+ "createPaymentWithoutPaymentLinkTest",+ (createPaymentBody, globalState) => {+ const profile_id =+ globalState.get("profileId") || globalState.get("defaultProfileId");++ const requestBody = {+ ...createPaymentBody,+ currency: "USD",+ amount: 6000,+ description: "Test without Payment Link",+ email: "[email protected]",+ authentication_type: "no_three_ds",+ capture_method: "automatic",+ customer_id: globalState.get("customerId"),+ profile_id: profile_id,+ };++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments`,+ 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.status).to.equal(200);+ expect(response.body).to.have.property("payment_id");+ expect(response.body.payment_link).to.be.null;+ });+ });+ }+);+Cypress.Commands.add("retrieveRelayCallTest",(data, globalState, forceSync = false, relayIdOverride = null) => {@@ -8481,3 +8767,21 @@ Cypress.Commands.add(});});++Cypress.Commands.add("retrieveNonExistentPaymentLinkTest", (globalState) => {+ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/payment_link/non_existent_link_12345`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.status).to.equal(404);+ });+ });+});diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 1880b26e15..9e93d34660 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -96,6 +96,15 @@ export function handleRedirection(paymentMethodType);break;+ case "payment_link_card":+ paymentLinkCardRedirection(+ urls.redirectionUrl,+ urls.expectedUrl,+ resolvedConnectorId,+ paymentMethodType,+ handlerMetadata+ );+ break;default:throw new Error(`Unknown redirection type: ${redirectionType}`);}@@ -2101,6 +2110,187 @@ function waitForRedirect(redirectionUrl) {});}+function paymentLinkCardRedirection(+ 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 payment link card redirection - no valid redirect URL provided"+ );+ return;+ }++ cy.visit(redirectionUrl.href, { failOnStatusCode: false });++ 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");++ 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+ );++ 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((_, 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("#unified-checkout iframe").then(($iframes) => {+ cy.task("cli_log", `Found ${$iframes.length} iframes in unified-checkout`);++ $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 payment page").to.be.true;+ });+ cy.task("cli_log", "Payment page shows error indicator as expected");+ } else {+ cy.contains(/succeeded|success|payment 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("payment 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", "Payment page shows success indicator");+ } else if (hasError) {+ cy.task("cli_log", "Payment page shows error indicator");+ } else {+ cy.task(+ "cli_log",+ "Payment page status unclear after submission - checking URL"+ );+ cy.url().then((url) => {+ cy.task("cli_log", `Current URL after payment submission: ${url}`);+ });+ }+ });+ }+}+function handleFlow(redirectionUrl,expectedUrl,