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 step-up auth coverage for cybersource (#12249)
HS-QUALIBOTf30db23bc0ec
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 57d7687c23..829375b36a 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -3523,4 +3523,76 @@ export const connectorDetails = {},}),},+ step_up_auth: {+ PaymentIntentOnly: getCustomExchange({+ Request: {+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ authentication_type: "three_ds",+ },+ },+ }),+ ConfirmPayment: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulThreeDSTestCardDetails,+ },+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ authentication_type: "three_ds",+ },+ },+ }),+ ThreeDSAuthentication: getCustomExchange({+ Request: {+ device_channel: "BRW",+ threeds_method_comp_ind: "Y",+ },+ Response: {+ status: 200,+ body: {},+ },+ }),+ ThreeDSAuthenticationUnconfirmed: getCustomExchange({+ Request: {+ device_channel: "BRW",+ threeds_method_comp_ind: "Y",+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_16",+ message:+ "You cannot authenticate this payment because payment_attempt.external_three_ds_authentication_attempted is false",+ },+ },+ },+ }),+ AuthorizeAfterFrictionlessAuth: getCustomExchange({+ Request: {},+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ }),+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Cybersource.js b/cypress-tests/cypress/e2e/configs/Payment/Cybersource.jsindex f2aefa3b1c..bb7e4d4a00 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Cybersource.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Cybersource.js@@ -20,6 +20,22 @@ const successfulThreeDSTestCardDetails = {card_cvc: "123",};+const visaFrictionlessCardDetails = {+ card_number: "4929251897047956",+ card_exp_month: "01",+ card_exp_year: "50",+ card_holder_name: "joseph Doe",+ card_cvc: "123",+};++const mastercardChallengeCardDetails = {+ card_number: "5306889942833340",+ card_exp_month: "01",+ card_exp_year: "50",+ card_holder_name: "joseph Doe",+ card_cvc: "123",+};+const singleUseMandateData = {customer_acceptance: customerAcceptance,mandate_type: {@@ -1224,6 +1240,145 @@ export const connectorDetails = {},}),},+ step_up_auth: {+ PaymentIntentOnly: getCustomExchange({+ Request: {+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ authentication_type: "three_ds",+ },+ },+ }),+ ConfirmPayment: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulThreeDSTestCardDetails,+ },+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ authentication_type: "three_ds",+ },+ },+ }),+ ThreeDSAuthentication: getCustomExchange({+ Request: {+ device_channel: "BRW",+ threeds_method_comp_ind: "Y",+ },+ Response: {+ status: 200,+ body: {},+ },+ }),+ ThreeDSAuthenticationUnconfirmed: getCustomExchange({+ Request: {+ device_channel: "BRW",+ threeds_method_comp_ind: "Y",+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_16",+ message:+ "You cannot authenticate this payment because payment_attempt.external_three_ds_authentication_attempted is false",+ },+ },+ },+ }),+ StepUpAuthWithMerchantCodes: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulThreeDSTestCardDetails,+ },+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ authentication_type: "three_ds",+ },+ },+ }),+ ThreeDSAuthenticationWithMerchantCodes: getCustomExchange({+ Request: {+ device_channel: "BRW",+ threeds_method_comp_ind: "Y",+ },+ Response: {+ status: 200,+ body: {},+ },+ }),+ ConfirmPaymentVisaFrictionless: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: visaFrictionlessCardDetails,+ },+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ authentication_type: "three_ds",+ },+ },+ }),+ ConfirmPaymentMastercardChallenge: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: mastercardChallengeCardDetails,+ },+ currency: "USD",+ authentication_type: "three_ds",+ request_external_three_ds_authentication: true,+ setup_future_usage: "off_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ authentication_type: "three_ds",+ },+ },+ }),+ AuthorizeAfterFrictionlessAuth: getCustomExchange({+ Request: {},+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ }),+ },pm_list: {PmListResponse: {PmListNull: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 1ca009471b..331db2cc97 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -556,6 +556,7 @@ export const CONNECTOR_LISTS = {GIFT_CARD: ["adyen"],PAY_LATER: ["klarna", "adyen", "aci", "stripe", "airwallex", "mollie"],AUTH_SERVICE_ELIGIBILITY: ["stripe", "cybersource"],+ STEP_UP_AUTH: ["cybersource"],PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],USE_BILLING_AS_PAYMENT_METHOD_BILLING: ["bankofamerica"],MIT_WITH_LIMITED_CARD_DATA: ["peachpayments"],@@ -589,10 +590,11 @@ export const CONNECTOR_LISTS = {// Helper functionsexport const shouldExcludeConnector = (connectorId, list) => {- return list.includes(connectorId);+ return Array.isArray(list) && list.includes(connectorId);};export const shouldIncludeConnector = (connectorId, list) => {+ if (!Array.isArray(list)) return true;return !list.includes(connectorId);};diff --git a/cypress-tests/cypress/e2e/spec/Payment/47-StepUpAuth.cy.js b/cypress-tests/cypress/e2e/spec/Payment/47-StepUpAuth.cy.jsnew file mode 100644index 0000000000..f7610fecd7--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/47-StepUpAuth.cy.js@@ -0,0 +1,558 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, {+ CONNECTOR_LISTS,+ shouldIncludeConnector,+} from "../../configs/Payment/Utils";+import * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Step-Up Auth payment flow test", () => {+ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);++ const baseUrl = globalState.get("baseUrl") || "";+ if (baseUrl.includes("localhost")) {+ skip = true;+ return;+ }++ if (+ shouldIncludeConnector(+ globalState.get("connectorId"),+ CONNECTOR_LISTS.INCLUDE.STEP_UP_AUTH+ )+ ) {+ skip = true;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });+ });++ after("flush global state", () => {+ if (globalState) {+ cy.task("setGlobalState", globalState.data);+ }+ });++ context(+ "Step-Up Auth setup - create auth processor and update profile",+ () => {+ let shouldContinue = true;++ before(function () {+ if (!globalState.get("profileId")) {+ shouldContinue = false;+ }+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ afterEach("flush global state", () => {+ if (!globalState.get("authProcessorConnectorId")) {+ shouldContinue = false;+ }+ cy.task("setGlobalState", globalState.data);+ });++ it("create authentication processor connector", () => {+ const createConnectorBody = { ...fixtures.createConnectorBody };+ createConnectorBody.connector_name = "netcetera";++ cy.createAuthenticationProcessorConnectorTest(+ createConnectorBody,+ globalState+ );+ });++ it("update business profile with auth connector", () => {+ const bpUpdateAuthConnector = {+ authentication_connector_details: {+ authentication_connectors: ["netcetera"],+ three_ds_requestor_url: "https://example.com",+ },+ };+ cy.UpdateBusinessProfileTest(+ bpUpdateAuthConnector,+ false,+ false,+ false,+ false,+ false,+ globalState+ );+ });+ }+ );++ context(+ "Step-Up Auth happy path - create, confirm, authenticate and retrieve",+ () => {+ let shouldContinue = true;++ before(function () {+ if (!globalState.get("authProcessorConnectorId")) {+ shouldContinue = false;+ }+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ it("create payment intent with three_ds", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["PaymentIntentOnly"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("confirm payment with three_ds card", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: confirm payment with three_ds card"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ConfirmPayment"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("call 3ds authentication endpoint", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: call 3ds authentication endpoint");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ThreeDSAuthentication"];++ cy.threeDSAuthenticationCallTest(+ fixtures.threeDSAuthenticationBody,+ data,+ globalState+ );+ });++ it("retrieve payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: retrieve payment");+ return;+ }+ cy.retrievePaymentCallTest({ globalState });+ });+ }+ );++ context("Step-Up Auth negative - 3ds auth without confirmed payment", () => {+ let shouldContinue = true;++ before(function () {+ if (!globalState.get("authProcessorConnectorId")) {+ shouldContinue = false;+ }+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ it("create payment intent with three_ds only", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["PaymentIntentOnly"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("call 3ds authentication - should fail with IR_04", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: call 3ds authentication - should fail with IR_04"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ThreeDSAuthenticationUnconfirmed"];++ cy.threeDSAuthenticationCallTest(+ fixtures.threeDSAuthenticationBody,+ data,+ globalState+ );+ });+ });++ context("Step-Up Auth with merchant codes from business profile", () => {+ let shouldContinue = true;++ before(function () {+ if (!globalState.get("authProcessorConnectorId")) {+ shouldContinue = false;+ }++ if (shouldContinue) {+ const bpUpdateMerchantCodes = {+ merchant_country_code: "840",+ merchant_category_code: "5411",+ };+ cy.UpdateBusinessProfileTest(+ bpUpdateMerchantCodes,+ false,+ false,+ false,+ false,+ false,+ globalState+ );+ }+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ it("create payment intent with three_ds", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["PaymentIntentOnly"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("confirm payment with three_ds card", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: confirm payment with three_ds card");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["StepUpAuthWithMerchantCodes"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("call 3ds authentication endpoint", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: call 3ds authentication endpoint");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ThreeDSAuthenticationWithMerchantCodes"];++ cy.threeDSAuthenticationCallTest(+ fixtures.threeDSAuthenticationBody,+ data,+ globalState+ );+ });++ it("retrieve payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: retrieve payment");+ return;+ }+ cy.retrievePaymentCallTest({ globalState });+ });+ });++ context(+ "Step-Up Auth Visa frictionless - create, confirm, authenticate and retrieve",+ () => {+ let shouldContinue = true;++ before(function () {+ if (!globalState.get("authProcessorConnectorId")) {+ shouldContinue = false;+ }+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ it("create payment intent with three_ds for visa frictionless", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["PaymentIntentOnly"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("confirm payment with visa frictionless card", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: confirm payment with visa frictionless card"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ConfirmPaymentVisaFrictionless"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("call 3ds authentication endpoint for visa frictionless", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: call 3ds authentication endpoint for visa frictionless"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ThreeDSAuthentication"];++ cy.threeDSAuthenticationCallTest(+ fixtures.threeDSAuthenticationBody,+ data,+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("authorize payment after visa frictionless authentication", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: authorize payment after visa frictionless authentication"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["AuthorizeAfterFrictionlessAuth"];++ cy.authorizeViaThreeDsAuthorizeUrlTest(data, globalState);+ });++ it("retrieve payment for visa frictionless", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: retrieve payment for visa frictionless"+ );+ return;+ }+ cy.retrievePaymentCallTest({ globalState });+ });+ }+ );++ context(+ "Step-Up Auth Mastercard challenge - create, confirm, authenticate and retrieve",+ () => {+ let shouldContinue = true;++ before(function () {+ if (!globalState.get("authProcessorConnectorId")) {+ shouldContinue = false;+ }+ });++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ it("create payment intent with three_ds for mastercard challenge", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["PaymentIntentOnly"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("confirm payment with mastercard challenge card", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: confirm payment with mastercard challenge card"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ConfirmPaymentMastercardChallenge"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ it("call 3ds authentication endpoint for mastercard challenge", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: call 3ds authentication endpoint for mastercard challenge"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "step_up_auth"+ ]["ThreeDSAuthentication"];++ cy.threeDSAuthenticationCallTest(+ fixtures.threeDSAuthenticationBody,+ data,+ globalState+ );+ });++ it("retrieve payment for mastercard challenge", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: retrieve payment for mastercard challenge"+ );+ return;+ }+ cy.retrievePaymentCallTest({ globalState });+ });+ }+ );+});diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.jsindex 61d3d815da..9e0ef19894 100644--- a/cypress-tests/cypress/fixtures/imports.js+++ b/cypress-tests/cypress/fixtures/imports.js@@ -30,6 +30,7 @@ import disputeEvidenceBody from "./dispute-evidence-body.json";import cardLimitedDataMITBody from "./create-card-limited-data-mit.json";import eligibilityCheckBody from "./eligibility-check-body.json";import extendAuthBody from "./extend-auth-body.json";+import threeDSAuthenticationBody from "./three-ds-authentication-body.json";import * as IncomingWebhookBody from "./webhooks/import";import customerCreate from "./modularPmService/modularPmServiceCustomerCreate.json";import paymentMethodCreate from "./modularPmService/modular-pm-service-pm-create.json";@@ -57,6 +58,7 @@ export {disputeEvidenceBody,eligibilityCheckBody,extendAuthBody,+ threeDSAuthenticationBody,gsmBody,listRefundCall,merchantCreateBody,diff --git a/cypress-tests/cypress/fixtures/three-ds-authentication-body.json b/cypress-tests/cypress/fixtures/three-ds-authentication-body.jsonnew file mode 100644index 0000000000..a38418964a--- /dev/null+++ b/cypress-tests/cypress/fixtures/three-ds-authentication-body.json@@ -0,0 +1,5 @@+{+ "device_channel": "BRW",+ "threeds_method_comp_ind": "Y",+ "client_secret": ""+}diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex e8109d83a9..356e1d8d9e 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -820,7 +820,6 @@ Cypress.Commands.add(always_collect_billing_details_from_wallet_connector;updateBusinessProfileBody.always_collect_shipping_details_from_wallet_connector =always_collect_shipping_details_from_wallet_connector;-if (typeof use_billing_as_payment_method_billing !== "undefined") {updateBusinessProfileBody.use_billing_as_payment_method_billing =use_billing_as_payment_method_billing;@@ -865,6 +864,30 @@ Cypress.Commands.add("useBillingAsPaymentMethodBilling",response.body.use_billing_as_payment_method_billing);+ if (response.body.authentication_connector_details) {+ expect(+ response.body.authentication_connector_details+ ).to.have.property("authentication_connectors");+ globalState.set(+ "authConnectors",+ response.body.authentication_connector_details+ .authentication_connectors+ );+ }+ if (updateBusinessProfileBody.merchant_country_code) {+ expect(response.body.merchant_country_code).to.equal(+ updateBusinessProfileBody.merchant_country_code+ );+ }+ if (updateBusinessProfileBody.merchant_category_code) {+ expect(response.body.merchant_category_code).to.equal(+ updateBusinessProfileBody.merchant_category_code+ );+ }+ } else {+ throw new Error(+ `Business Profile Update Failed: ${response.body.error?.message || response.status}`+ );}});});@@ -1380,6 +1403,217 @@ Cypress.Commands.add(});+Cypress.Commands.add(+ "createAuthenticationProcessorConnectorTest",+ (+ createConnectorBody,+ globalState,+ profilePrefix = "profile",+ mcaPrefix = "authProcessorConnector",+ expectedStatus = 200+ ) => {+ const apiKey = globalState.get("apiKey");+ const baseUrl = globalState.get("baseUrl");+ const merchantId = globalState.get("merchantId");+ const profileId = globalState.get(`${profilePrefix}Id`);+ const url = `${baseUrl}/account/${merchantId}/connectors`;++ if (!profileId) {+ throw new Error(+ `createAuthenticationProcessorConnectorTest: profile_id is not available in globalState (key: ${profilePrefix}Id). Ensure the AccountCreate prereq has completed successfully.`+ );+ }++ createConnectorBody.connector_type = "authentication_processor";+ createConnectorBody.profile_id = profileId;++ cy.readFile(globalState.get("connectorAuthFilePath")).then(+ (jsonContent) => {+ const { authDetails } = getValueByKey(+ JSON.stringify(jsonContent),+ createConnectorBody.connector_name+ );++ if (authDetails && authDetails.connector_account_details) {+ createConnectorBody.connector_account_details =+ authDetails.connector_account_details;+ }++ if (authDetails && authDetails.metadata) {+ createConnectorBody.metadata = {+ ...createConnectorBody.metadata,+ ...authDetails.metadata,+ };+ }++ cy.request({+ method: "POST",+ url,+ headers: {+ Accept: "application/json",+ "Content-Type": "application/json",+ "api-key": apiKey,+ },+ body: createConnectorBody,+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (expectedStatus === 200) {+ if (response.status === 200) {+ expect(response.body.connector_name).to.equal(+ createConnectorBody.connector_name+ );+ expect(response.body.connector_type).to.equal(+ "authentication_processor"+ );+ expect(response.body).to.have.property("merchant_connector_id")+ .and.to.not.be.empty;+ globalState.set(+ `${mcaPrefix}Id`,+ response.body.merchant_connector_id+ );+ } else {+ cy.task(+ "cli_log",+ "response status -> " + JSON.stringify(response.status)+ );+ throw new Error(+ `Authentication Processor Connector Create Call Failed ${response.body.error.message}`+ );+ }+ } else {+ expect(response.status).to.equal(expectedStatus);+ }+ });+ });+ }+ );+ }+);++Cypress.Commands.add(+ "threeDSAuthenticationCallTest",+ (requestBody, data, globalState) => {+ const { Request: reqData, Response: resData } = data || {};+ const paymentId = globalState.get("paymentID");+ const publishableKey = globalState.get("publishableKey");++ const body = { ...requestBody };+ for (const key in reqData) {+ body[key] = reqData[key];+ }+ body.client_secret = globalState.get("clientSecret");++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments/${paymentId}/3ds/authentication`,+ headers: {+ "Content-Type": "application/json",+ "api-key": publishableKey,+ },+ body: body,+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ expect(response.headers["content-type"]).to.include(+ "application/json"+ );+ if (response.body.three_ds_data) {+ globalState.set("threeDsData", response.body.three_ds_data);+ }+ for (const key in resData.body) {+ if (+ typeof resData.body[key] === "object" &&+ resData.body[key] !== null+ ) {+ expect(+ response.body[key],+ `Expected ${key} to deep equal`+ ).to.deep.eq(resData.body[key]);+ } else {+ expect(resData.body[key]).to.equal(+ response.body[key],+ `Expected ${resData.body[key]} but got ${response.body[key]}`+ );+ }+ }+ } else {+ defaultErrorHandler(response, resData);+ }+ });+ });+ }+);++Cypress.Commands.add(+ "authorizeViaThreeDsAuthorizeUrlTest",+ (data, globalState) => {+ const { Response: resData } = data || {};+ const threeDsData = globalState.get("threeDsData");+ const authorizeUrl = threeDsData?.three_ds_authorize_url;++ if (!authorizeUrl) {+ throw new Error(+ "three_ds_authorize_url not found in globalState. Ensure the confirm call returned next_action.three_ds_data."+ );+ }++ cy.request({+ method: "POST",+ url: authorizeUrl,+ headers: {+ "Content-Type": "application/x-www-form-urlencoded",+ },+ body: {},+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ if (resData && resData.body && Object.keys(resData.body).length > 0) {+ const paymentId = globalState.get("paymentID");+ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/payments/${paymentId}?force_sync=true`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((retrieveResponse) => {+ logRequestId(retrieveResponse.headers["x-request-id"]);+ for (const key in resData.body) {+ if (+ typeof resData.body[key] === "object" &&+ resData.body[key] !== null+ ) {+ expect(+ retrieveResponse.body[key],+ `Expected ${key} to deep equal`+ ).to.deep.eq(resData.body[key]);+ } else {+ expect(resData.body[key]).to.equal(+ retrieveResponse.body[key],+ `Expected ${resData.body[key]} but got ${retrieveResponse.body[key]}`+ );+ }+ }+ });+ }+ } else {+ defaultErrorHandler(response, resData);+ }+ });+ });+ }+);+Cypress.Commands.add("createPayoutConnectorCallTest",(connectorType, createConnectorBody, globalState) => {@@ -3082,6 +3316,11 @@ Cypress.Commands.add("nextActionUrl",response.body.next_action.ddc_data.iframe_url);+ } else if (response.body.next_action.three_ds_data) {+ globalState.set(+ "threeDsData",+ response.body.next_action.three_ds_data+ );} else {expect(response.body.next_action).to.have.property("redirect_to_url"@@ -3119,6 +3358,11 @@ Cypress.Commands.add("nextActionUrl",response.body.next_action.ddc_data.iframe_url);+ } else if (response.body.next_action.three_ds_data) {+ globalState.set(+ "threeDsData",+ response.body.next_action.three_ds_data+ );} else {expect(response.body.next_action).to.have.property("redirect_to_url"