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): IFRAME_REDIRECTION test coverage (#12174)
HS-QUALIBOTa2620086a188
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.jsindex 9dd217b0e9..0f7819fc5e 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js@@ -1,5 +1,9 @@import { customerAcceptance, multiUseMandateData } from "./Commons";-import { getCurrency, getCustomExchange } from "./Modifiers";+import {+ getCurrency,+ getCustomExchange,+ getIframeRedirectionConfig,+} from "./Modifiers";const successfulNo3DSCardDetails = {card_number: "4111111111111111",@@ -133,6 +137,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ }),No3DSManualCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.js b/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.jsindex 569c9ed29e..f128aa9306 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.js@@ -1,4 +1,5 @@import { customerAcceptance } from "./Commons";+import { getIframeRedirectionConfig } from "./Modifiers";const successfulNo3DSCardDetails = {card_number: "4000000000001091",@@ -91,6 +92,10 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ amount: 6544,+ }),PaymentIntentOffSession: {Configs: {TRIGGER_SKIP: true,@@ -184,6 +189,7 @@ export const connectorDetails = {},},},+No3DSManualCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Bluesnap.js b/cypress-tests/cypress/e2e/configs/Payment/Bluesnap.jsindex d2ba148a36..600f8c9cea 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Bluesnap.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Bluesnap.js@@ -1,4 +1,5 @@import { customerAcceptance } from "./Commons";+import { getIframeRedirectionConfig } from "./Modifiers";const successfulNo3DSCardDetails = {card_number: "4242424242424242",@@ -59,6 +60,10 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ }),+PaymentIntentWithShippingCost: {Request: {currency: "USD",@@ -134,6 +139,7 @@ export const connectorDetails = {},},},+SaveCardUse3DSAutoCaptureOffSession: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Braintree.js b/cypress-tests/cypress/e2e/configs/Payment/Braintree.jsindex 50b9b02637..d50801bf3f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Braintree.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Braintree.js@@ -1,4 +1,5 @@import { customerAcceptance } from "./Commons";+import { getIframeRedirectionConfig } from "./Modifiers";const successfulNo3DSCardDetails = {card_number: "4009348888881881",@@ -103,6 +104,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successful3DSCardDetails,+ }),PaymentIntentOffSession: {Request: {amount: 6000,@@ -185,6 +189,7 @@ export const connectorDetails = {},},},+No3DSManualCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Cybersource.js b/cypress-tests/cypress/e2e/configs/Payment/Cybersource.jsindex bb7e4d4a00..755d30ac0a 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Cybersource.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Cybersource.js@@ -2,7 +2,7 @@ import {connectorDetails as commonConnectorDetails,customerAcceptance,} from "./Commons";-import { getCustomExchange } from "./Modifiers";+import { getCustomExchange, getIframeRedirectionConfig } from "./Modifiers";const successfulNo3DSCardDetails = {card_number: "4242424242424242",@@ -134,6 +134,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ }),PaymentIntentOffSession: {Configs: {CONNECTOR_CREDENTIAL: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Deutschebank.js b/cypress-tests/cypress/e2e/configs/Payment/Deutschebank.jsindex 0a43f2d97a..7d326787e2 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Deutschebank.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Deutschebank.js@@ -1,4 +1,5 @@import { customerAcceptance } from "./Commons";+import { getIframeRedirectionConfig } from "./Modifiers";const successful3DSCardDetails = {card_number: "4761739090000088",@@ -41,6 +42,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successful3DSCardDetails,+ }),"3DSManualCapture": {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.jsindex db78ff7111..eac81d2116 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js@@ -110,6 +110,69 @@ export const updateDefaultStatusCode = () => {return getUnsupportedExchange().Response;};+export const getIframeRedirectionConfig = (opts = {}) => {+ const {+ cardDetails,+ currency = "USD",+ amount,+ payment_method_type,+ payment_method_data_3ds,+ configs,+ } = opts;++ const iframeRedirection = {+ Request: {+ payment_method: "card",+ payment_method_data: { card: cardDetails },+ currency,+ customer_acceptance: null,+ setup_future_usage: "on_session",+ is_iframe_redirection_enabled: true,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ setup_future_usage: "on_session",+ },+ },+ };++ if (amount !== undefined) {+ iframeRedirection.Request.amount = amount;+ }++ if (payment_method_type) {+ iframeRedirection.Request.payment_method_type = payment_method_type;+ }++ if (payment_method_data_3ds) {+ iframeRedirection.Response.body.payment_method_data =+ payment_method_data_3ds;+ }++ if (configs && Object.keys(configs).length > 0) {+ iframeRedirection.Configs = configs;+ }++ return {+ IframeRedirectionCreate: {+ Request: {+ amount: amount ?? 6000,+ currency,+ is_iframe_redirection_enabled: true,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ },+ IframeRedirection: iframeRedirection,+ };+};+// Currency map with logical groupingconst CURRENCY_MAP = {// Polish payment methodsdiff --git a/cypress-tests/cypress/e2e/configs/Payment/Nexixpay.js b/cypress-tests/cypress/e2e/configs/Payment/Nexixpay.jsindex cdbba111c5..ce6cf5a07f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Nexixpay.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Nexixpay.js@@ -1,3 +1,5 @@+import { getIframeRedirectionConfig } from "./Modifiers";+const successfulNo3DSCardDetails = {card_number: "4111111111111111",card_exp_month: "08",@@ -167,6 +169,10 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ currency: "EUR",+ }),No3DSManualCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Nmi.js b/cypress-tests/cypress/e2e/configs/Payment/Nmi.jsindex 9f5a122e26..00c82f097a 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Nmi.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Nmi.js@@ -1,3 +1,5 @@+import { getIframeRedirectionConfig } from "./Modifiers";+const successfulNo3DSCardDetails = {card_number: "4532111111111112",card_exp_month: "10",@@ -65,6 +67,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ }),PaymentIntentWithShippingCost: {Request: {currency: "USD",@@ -129,6 +134,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ }),No3DSManualCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Paypal.js b/cypress-tests/cypress/e2e/configs/Payment/Paypal.jsindex b1deb4ae86..8a1ec4b450 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Paypal.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Paypal.js@@ -1,4 +1,4 @@-import { getCustomExchange } from "./Modifiers";+import { getCustomExchange, getIframeRedirectionConfig } from "./Modifiers";import { standardBillingAddress } from "./Commons";const successfulNo3DSCardDetails = {@@ -69,6 +69,10 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ amount: 6000,+ }),PaymentIntentWithShippingCost: {Request: {currency: "USD",@@ -142,6 +146,9 @@ export const connectorDetails = {},},},+ ...getIframeRedirectionConfig({+ cardDetails: successfulThreeDSTestCardDetails,+ }),No3DSManualCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 28c2749882..d57925040c 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -466,6 +466,17 @@ export const CONNECTOR_LISTS = {// ucs connectorsUCS_CONNECTORS: ["authorizedotnet"],OVERCAPTURE: ["adyen"],+ IFRAME_REDIRECTION: [+ "adyen",+ "cybersource",+ "barclaycard",+ "paypal",+ "bluesnap",+ "braintree",+ "nmi",+ "nexixpay",+ "deutschebank",+ ],MANUAL_RETRY: ["cybersource","checkout",diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-IframeRedirection.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-IframeRedirection.cy.jsnew file mode 100644index 0000000000..835b2d4ec9--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/52-IframeRedirection.cy.js@@ -0,0 +1,235 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, {+ CONNECTOR_LISTS,+} from "../../configs/Payment/Utils";+import * as utils from "../../configs/Payment/Utils";++let globalState;++const connectorId = Cypress.env("CONNECTOR");+const describeIfSupported = CONNECTOR_LISTS.INCLUDE.IFRAME_REDIRECTION.includes(+ connectorId+)+ ? describe+ : describe.skip;++describeIfSupported("Iframe Redirection Payment Flow Tests", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Happy Path - Create Payment with Iframe Redirection Enabled", () => {+ it("Create Payment Intent with is_iframe_redirection_enabled -> Confirm Payment -> Verify Redirect Response -> Retrieve Payment", function () {+ let shouldContinue = true;++ cy.step(+ "Create Payment Intent with is_iframe_redirection_enabled",+ () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["IframeRedirectionCreate"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ }+ );++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment with is_iframe_redirection_enabled", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["IframeRedirection"];++ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Verify Redirect Response Contains Iframe URL", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Verify Redirect Response");+ return;+ }++ cy.verifyIframeRedirection(globalState, {+ expectRedirectInsidePopup: true,+ });+ });++ cy.step("Poll Payment Status to Terminal State", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Poll Payment Status");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({ globalState, data });+ });+ });+ });++ context("Edge Case - Iframe Redirection Not Explicitly Enabled", () => {+ it("Create Payment Intent without iframe flag -> Confirm Payment -> Verify redirect still inside popup", function () {+ let shouldContinue = true;++ cy.step(+ "Create Payment Intent without is_iframe_redirection_enabled",+ () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ }+ );++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment without iframe redirection flag", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const fullData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["3DSAutoCapture"];+ const data = JSON.parse(JSON.stringify(fullData));+ if (data?.Response?.body?.payment_method_data) {+ delete data.Response.body.payment_method_data;+ }++ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Verify Redirect Still Inside Popup", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Verify Redirect");+ return;+ }++ cy.verifyIframeRedirection(globalState, {+ expectRedirectInsidePopup: true,+ });+ });+ });+ });++ context("Negative Case - Iframe Redirection with No3DS Auth Type", () => {+ it("Create Payment with iframe flag but no_three_ds -> Confirm -> Verify redirect still inside popup", function () {+ let shouldContinue = true;++ cy.step("Create Payment Intent with iframe flag and no_three_ds", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["IframeRedirectionCreate"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step(+ "Confirm Payment with no_three_ds on iframe-enabled intent",+ () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }++ const fullData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];+ const data = JSON.parse(JSON.stringify(fullData));+ if (data?.Response?.body?.payment_method_data) {+ delete data.Response.body.payment_method_data;+ }++ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ }+ );++ cy.step("Verify Iframe Redirect Occurred Without 3DS", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Verify Redirect");+ return;+ }++ cy.verifyIframeRedirection(globalState, {+ expectRedirectInsidePopup: true,+ expectedStatus: "succeeded",+ });+ });+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex f2da36ab2e..e1294fa9e1 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -2788,6 +2788,20 @@ Cypress.Commands.add("nextActionUrl",response.body.next_action.ddc_data.iframe_url);+ } else if (+ response.body.next_action.type === "redirect_inside_popup"+ ) {+ expect(response.body.next_action)+ .to.have.property("type")+ .to.equal("redirect_inside_popup");+ expect(response.body.next_action).to.have.property(+ "popup_url"+ );+ globalState.set("nextActionType", "redirect_inside_popup");+ globalState.set(+ "nextActionUrl",+ response.body.next_action.popup_url+ );} else {expect(response.body).to.have.property("next_action")@@ -2843,6 +2857,20 @@ Cypress.Commands.add("nextActionUrl",response.body.next_action.ddc_data.iframe_url);+ } else if (+ response.body.next_action.type === "redirect_inside_popup"+ ) {+ expect(response.body.next_action)+ .to.have.property("type")+ .to.equal("redirect_inside_popup");+ expect(response.body.next_action).to.have.property(+ "popup_url"+ );+ globalState.set("nextActionType", "redirect_inside_popup");+ globalState.set(+ "nextActionUrl",+ response.body.next_action.popup_url+ );} else {expect(response.body.next_action).to.have.property("redirect_to_url"@@ -8356,6 +8384,26 @@ Cypress.Commands.add("updateCardIssuer", (id, body, globalState) => {});});+Cypress.Commands.add("verifyIframeRedirection", (globalState, options = {}) => {+ const {+ expectRedirectInsidePopup = true,+ expectedStatus = "requires_customer_action",+ } = options;++ expect(globalState.get("paymentIntentStatus")).to.equal(expectedStatus);++ if (expectRedirectInsidePopup) {+ expect(globalState.get("nextActionType")).to.equal("redirect_inside_popup");+ expect(globalState.get("nextActionUrl")).to.not.be.null;+ } else {+ expect(+ globalState.get("nextActionType"),+ "nextActionType should not be redirect_inside_popup"+ ).to.not.equal("redirect_inside_popup");+ expect(globalState.get("nextActionUrl"), "nextActionUrl should be null").to+ .be.null;+ }+});// ============================================// Payment Link Commands// ============================================