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
feat(platform): platform payment cypress tests (#11509)
Ankit Kumar Guptadf2f0962cbaa
diff --git a/cypress-tests/cypress/e2e/spec/Platform/00001-PlatformSetup.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00001-PlatformSetup.cy.jsindex 797ad98577..9faea3085a 100644--- a/cypress-tests/cypress/e2e/spec/Platform/00001-PlatformSetup.cy.js+++ b/cypress-tests/cypress/e2e/spec/Platform/00001-PlatformSetup.cy.js@@ -26,6 +26,10 @@ describe("Platform Setup & Connected Merchant Onboarding", () => {});cy.then(() => {globalState.set("platformMerchantId", globalState.get("merchantId"));+ globalState.set(+ "platformPublishableKey",+ globalState.get("publishableKey")+ );});});@@ -34,7 +38,15 @@ describe("Platform Setup & Connected Merchant Onboarding", () => {});it("create-api-key-for-platform-merchant", () => {+ const savedMerchantId = globalState.get("merchantId");+ globalState.set("merchantId", globalState.get("platformMerchantId"));+cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState);++ cy.then(() => {+ globalState.set("platformApiKey", globalState.get("apiKey"));+ globalState.set("merchantId", savedMerchantId);+ });});});@@ -52,6 +64,7 @@ describe("Platform Setup & Connected Merchant Onboarding", () => {expectedMerchantAccountType: "connected",merchantIdStateKey: "connectedMerchantId1",profileIdStateKey: "profileIdCm1",+ publishableKeyStateKey: "publishableKeyCm1",});});@@ -87,6 +100,7 @@ describe("Platform Setup & Connected Merchant Onboarding", () => {expectedMerchantAccountType: "connected",merchantIdStateKey: "connectedMerchantId2",profileIdStateKey: "profileIdCm2",+ publishableKeyStateKey: "publishableKeyCm2",});cy.then(() => {diff --git a/cypress-tests/cypress/e2e/spec/Platform/00005-PaymentFlows.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00005-PaymentFlows.cy.jsindex 711b93c978..97f7f81547 100644--- a/cypress-tests/cypress/e2e/spec/Platform/00005-PaymentFlows.cy.js+++ b/cypress-tests/cypress/e2e/spec/Platform/00005-PaymentFlows.cy.js@@ -17,36 +17,40 @@ describe("Platform Payment Flows", () => {context("Platform Acts On Behalf Of Connected Merchants", () => {it("platform-creates-payment-for-cm1-using-header", () => {- const paymentRequestBody = {- ...fixtures.createConfirmPaymentBody,- profile_id: globalState.get("profileIdCm1"),- customer_id: globalState.get("customerIdCm1Created"),- };+ globalState.set("customerId", globalState.get("customerIdCm1Created"));+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set("merchantConnectorId", globalState.get("connectorIdCm1"));- cy.createPaymentWithHeaderCall(- paymentRequestBody,- globalState.get("apiKey"),- globalState.get("connectedMerchantId1"),+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",globalState,- 200,- "platformPaymentIdCm1"+ globalState.get("connectedMerchantId1"));});it("platform-creates-payment-for-cm2-using-header", () => {- const paymentRequestBody = {- ...fixtures.createConfirmPaymentBody,- profile_id: globalState.get("profileIdCm2"),- customer_id: globalState.get("customerIdCm1Created"),- };+ globalState.set("customerId", globalState.get("customerIdCm1Created"));+ globalState.set("profileId", globalState.get("profileIdCm2"));+ globalState.set("merchantConnectorId", globalState.get("connectorIdCm2"));- cy.createPaymentWithHeaderCall(- paymentRequestBody,- globalState.get("apiKey"),- globalState.get("connectedMerchantId2"),+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",globalState,- 200,- "platformPaymentIdCm2"+ globalState.get("connectedMerchantId2"));});});diff --git a/cypress-tests/cypress/e2e/spec/Platform/00006-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00006-NoThreeDSAutoCapture.cy.jsnew file mode 100644index 0000000000..32b1977137--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00006-NoThreeDSAutoCapture.cy.js@@ -0,0 +1,190 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card NoThreeDS payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Platform acts on behalf of Connected Merchant 1 - NoThreeDS", () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set("merchantConnectorId", globalState.get("connectorIdCm1"));+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment -> Retrieve Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set("publishableKey", globalState.get("publishableKeyCm1"));+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });+ });+ });+ });++ context("Connected Merchant 2 makes own payment - NoThreeDS", () => {+ before(() => {+ globalState.set("apiKey", globalState.get("apiKeyCm2"));+ globalState.set("publishableKey", globalState.get("publishableKeyCm2"));+ globalState.set("merchantConnectorId", globalState.get("connectorIdCm2"));+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment -> Retrieve Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ 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", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });+ });+ });+ });+});diff --git a/cypress-tests/cypress/e2e/spec/Platform/00007-ThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00007-ThreeDSAutoCapture.cy.jsnew file mode 100644index 0000000000..ceb55ce725--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00007-ThreeDSAutoCapture.cy.js@@ -0,0 +1,174 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card ThreeDS payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Platform acts on behalf of Connected Merchant 1 - ThreeDS", () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set("merchantConnectorId", globalState.get("connectorIdCm1"));+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment -> Handle Redirection", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set("publishableKey", globalState.get("publishableKeyCm1"));+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ cy.handleRedirection(globalState, expected_redirection);+ });+ });+ });++ context("Connected Merchant 2 makes own payment - ThreeDS", () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment -> Handle Redirection", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ 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", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ cy.handleRedirection(globalState, expected_redirection);+ });+ });+ });+});diff --git a/cypress-tests/cypress/e2e/spec/Platform/00008-NoThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00008-NoThreeDSManualCapture.cy.jsnew file mode 100644index 0000000000..b26ec6810b--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00008-NoThreeDSManualCapture.cy.js@@ -0,0 +1,275 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card NoThreeDS Manual Capture payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Platform acts on behalf of Connected Merchant 1 - NoThreeDS Manual Full Capture",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(+ fixtures.captureBody,+ captureData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data: captureData,+ });+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - NoThreeDS Manual Full Capture",+ () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ 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 Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({ globalState, data: captureData });+ });+ });+ }+ );+});diff --git a/cypress-tests/cypress/e2e/spec/Platform/00009-ThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00009-ThreeDSManualCapture.cy.jsnew file mode 100644index 0000000000..a5fe4fd6c0--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00009-ThreeDSManualCapture.cy.js@@ -0,0 +1,293 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card ThreeDS Manual Capture payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Platform acts on behalf of Connected Merchant 1 - ThreeDS Manual Full Capture",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "manual",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ cy.handleRedirection(globalState, expected_redirection);+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["3DSManualCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(+ fixtures.captureBody,+ captureData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data: captureData,+ });+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - ThreeDS Manual Full Capture",+ () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "three_ds",+ "manual",+ 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 Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ cy.handleRedirection(globalState, expected_redirection);+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["3DSManualCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({ globalState, data: captureData });+ });+ });+ }+ );+});diff --git a/cypress-tests/cypress/e2e/spec/Platform/00010-VoidPayment.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00010-VoidPayment.cy.jsnew file mode 100644index 0000000000..9617352771--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00010-VoidPayment.cy.js@@ -0,0 +1,379 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card Void Payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Platform acts on behalf of Connected Merchant 1 - Void Payment in Requires_capture state",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Void Payment without Capture", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Void Payment without Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Void Payment without Capture");+ return;+ }+ const voidData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["VoidAfterConfirm"];++ cy.voidCallTest(+ fixtures.voidBody,+ voidData,+ globalState,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - Void Payment in Requires_capture state",+ () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Void Payment without Capture", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ 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 Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Void Payment without Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Void Payment without Capture");+ return;+ }+ const voidData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["VoidAfterConfirm"];++ cy.voidCallTest(fixtures.voidBody, voidData, globalState);+ });+ });+ }+ );++ context(+ "Platform acts on behalf of Connected Merchant 1 - Void Payment in Requires_payment_method state",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set("merchantConnectorId", globalState.get("connectorId"));+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Void Payment without Confirmation", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Void Payment without Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Void Payment without Confirmation"+ );+ return;+ }+ const voidData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["Void"];++ cy.voidCallTest(+ fixtures.voidBody,+ voidData,+ globalState,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - Void Payment in Requires_payment_method state",+ () => {+ it("Create Payment Intent -> Payment Methods Call -> Void Payment without Confirmation", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ 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("Void Payment without Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Void Payment without Confirmation"+ );+ return;+ }+ const voidData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["Void"];++ cy.voidCallTest(fixtures.voidBody, voidData, globalState);+ });+ });+ }+ );+});diff --git a/cypress-tests/cypress/e2e/spec/Platform/00011-SyncPayment.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00011-SyncPayment.cy.jsnew file mode 100644index 0000000000..2b2341c3ef--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00011-SyncPayment.cy.js@@ -0,0 +1,199 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card Sync Payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Platform acts on behalf of Connected Merchant 1 - Sync Payment",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });+ });+ });+ }+ );++ context("Connected Merchant 2 makes own payment - Sync Payment", () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ 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 Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });+ });+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 308cc38b53..5b8c270b69 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -488,6 +488,7 @@ Cypress.Commands.add(expectedMerchantAccountType = null,merchantIdStateKey = "merchantId",profileIdStateKey = "profileId",+ publishableKeyStateKey = "publishableKey",} = options;const merchantId = RequestBodyUtils.generateRandomString();@@ -515,7 +516,7 @@ Cypress.Commands.add(}globalState.set(profileIdStateKey, response.body.default_profile);- globalState.set("publishableKey", response.body.publishable_key);+ globalState.set(publishableKeyStateKey, response.body.publishable_key);globalState.set("merchantDetails", response.body.merchant_details);globalState.set("organizationId", response.body.organization_id);});@@ -1784,7 +1785,8 @@ Cypress.Commands.add(data,authentication_type,capture_method,- globalState+ globalState,+ connectedMerchantId) => {const {Configs: configs = {},@@ -1813,16 +1815,22 @@ Cypress.Commands.add(createPaymentBody.customer_id = globalState.get("customerId");createPaymentBody.profile_id = profile_id;+ const headers = {+ "Content-Type": "application/json",+ Accept: "application/json",+ "api-key": globalState.get("apiKey"),+ };++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }+globalState.set("paymentAmount", createPaymentBody.amount);globalState.set("setupFutureUsage", createPaymentBody.setup_future_usage);cy.request({method: "POST",url: `${globalState.get("baseUrl")}/payments`,- headers: {- "Content-Type": "application/json",- Accept: "application/json",- "api-key": globalState.get("apiKey"),- },+ headers,failOnStatusCode: false,body: createPaymentBody,}).then((response) => {@@ -2113,7 +2121,7 @@ Cypress.Commands.add("setDefaultPaymentMethodTest", (globalState) => {Cypress.Commands.add("confirmCallTest",- (confirmBody, data, confirm, globalState) => {+ (confirmBody, data, confirm, globalState, connectedMerchantId) => {const {Configs: configs = {},Request: reqData,@@ -2150,13 +2158,19 @@ Cypress.Commands.add(confirmBody.split_payments = reqData.split_payments;}+ const headers = {+ "Content-Type": "application/json",+ "api-key": apiKey,+ };++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }+cy.request({method: "POST",url: url,- headers: {- "Content-Type": "application/json",- "api-key": apiKey,- },+ headers: headers,failOnStatusCode: false,body: confirmBody,}).then((response) => {@@ -2580,7 +2594,8 @@ Cypress.Commands.add(data,authentication_type,capture_method,- globalState+ globalState,+ connectedMerchantId) => {const {Configs: configs = {},@@ -2611,13 +2626,19 @@ Cypress.Commands.add(createConfirmPaymentBody.split_payments = reqData.split_payments;}+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }+cy.request({method: "POST",url: `${globalState.get("baseUrl")}/payments`,- headers: {- "Content-Type": "application/json",- "api-key": globalState.get("apiKey"),- },+ headers: headers,failOnStatusCode: false,body: createConfirmPaymentBody,}).then((response) => {@@ -2893,92 +2914,110 @@ Cypress.Commands.add(});-Cypress.Commands.add("captureCallTest", (requestBody, data, globalState) => {- const {- Configs: configs = {},- Request: reqData,- Response: resData,- } = data || {};+Cypress.Commands.add(+ "captureCallTest",+ (requestBody, data, globalState, connectedMerchantId) => {+ const {+ Configs: configs = {},+ Request: reqData,+ Response: resData,+ } = data || {};- const configInfo = execConfig(validateConfig(configs));- const paymentId = globalState.get("paymentID");- const profileId = globalState.get(`${configInfo.profilePrefix}Id`);+ const configInfo = execConfig(validateConfig(configs));+ const paymentId = globalState.get("paymentID");+ const profileId = globalState.get(`${configInfo.profilePrefix}Id`);- requestBody.profile_id = profileId;+ requestBody.profile_id = profileId;- for (const key in reqData) {- requestBody[key] = reqData[key];- }+ for (const key in reqData) {+ requestBody[key] = reqData[key];+ }- cy.request({- method: "POST",- url: `${globalState.get("baseUrl")}/payments/${paymentId}/capture`,- headers: {+ const headers = {"Content-Type": "application/json","api-key": globalState.get("apiKey"),- },- failOnStatusCode: false,- body: requestBody,- }).then((response) => {- logRequestId(response.headers["x-request-id"]);- storeRequestId(response.headers["x-request-id"], globalState);- cy.wrap(response).then(() => {- expect(response.headers["content-type"]).to.include("application/json");- if (response.body.capture_method !== undefined) {- expect(response.body.payment_id).to.equal(paymentId);- for (const key in resData.body) {- expect(resData.body[key]).to.equal(response.body[key]);+ };++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments/${paymentId}/capture`,+ headers,+ failOnStatusCode: false,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);+ storeRequestId(response.headers["x-request-id"], globalState);+ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (response.body.capture_method !== undefined) {+ expect(response.body.payment_id).to.equal(paymentId);+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ } else {+ defaultErrorHandler(response, resData);}- } else {- defaultErrorHandler(response, resData);- }+ });});- });-});+ }+);-Cypress.Commands.add("voidCallTest", (requestBody, data, globalState) => {- const {- Configs: configs = {},- Response: resData,- Request: reqData,- } = data || {};+Cypress.Commands.add(+ "voidCallTest",+ (requestBody, data, globalState, connectedMerchantId) => {+ const {+ Configs: configs = {},+ Response: resData,+ Request: reqData,+ } = data || {};- const configInfo = execConfig(validateConfig(configs));- const payment_id = globalState.get("paymentID");- const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);+ const configInfo = execConfig(validateConfig(configs));+ const payment_id = globalState.get("paymentID");+ const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);- requestBody.profile_id = profile_id;+ requestBody.profile_id = profile_id;- // Apply connector-specific request data (including cancellation_reason)- for (const key in reqData) {- requestBody[key] = reqData[key];- }+ // Apply connector-specific request data (including cancellation_reason)+ for (const key in reqData) {+ requestBody[key] = reqData[key];+ }- cy.request({- method: "POST",- url: `${globalState.get("baseUrl")}/payments/${payment_id}/cancel`,- headers: {+ const headers = {"Content-Type": "application/json","api-key": globalState.get("apiKey"),- },- failOnStatusCode: false,- body: requestBody,- }).then((response) => {- logRequestId(response.headers["x-request-id"]);- storeRequestId(response.headers["x-request-id"], globalState);+ };- cy.wrap(response).then(() => {- expect(response.headers["content-type"]).to.include("application/json");- if (response.status === 200) {- for (const key in resData.body) {- expect(resData.body[key]).to.equal(response.body[key]);+ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments/${payment_id}/cancel`,+ headers,+ failOnStatusCode: false,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);+ storeRequestId(response.headers["x-request-id"], globalState);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (response.status === 200) {+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ } else {+ defaultErrorHandler(response, resData);}- } else {- defaultErrorHandler(response, resData);- }+ });});- });-});+ }+);Cypress.Commands.add("retrievePaymentCallTest",@@ -2988,6 +3027,7 @@ Cypress.Commands.add(autoretries = false,attempt = 1,expectedIntentStatus,+ connectedMerchantId,}) => {const { Configs: configs = {} } = data || {};@@ -2997,13 +3037,19 @@ Cypress.Commands.add();const payment_id = globalState.get("paymentID");+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }+cy.request({method: "GET",url: `${globalState.get("baseUrl")}/payments/${payment_id}?force_sync=true&expand_attempts=true`,- headers: {- "Content-Type": "application/json",- "api-key": globalState.get("apiKey"),- },+ headers: headers,failOnStatusCode: false,}).then((response) => {logRequestId(response.headers["x-request-id"]);