Skip to content

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

test(cypress): add acquirer-specific configurations coverage for business profiles (#13154)

Vasanth9766c5651b4a
diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-AcquirerConfigs.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-AcquirerConfigs.cy.js
new file mode 100644
index 0000000000..6db26194d0
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/52-AcquirerConfigs.cy.js
@@ -0,0 +1,186 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+
+let globalState;
+
+const acquirerConfigCreateVisa = {
+ acquirer_assigned_merchant_id: "M123456789",
+ merchant_name: "NewAge Retailer",
+ network: "Visa",
+ acquirer_bin: "456789",
+ acquirer_ica: "401288",
+ acquirer_fraud_rate: 0.01,
+ acquirer_country_code: "US",
+ is_default: true,
+};
+
+const acquirerConfigCreateMastercard = {
+ acquirer_assigned_merchant_id: "M555444333",
+ merchant_name: "Mastercard Retailer",
+ network: "Mastercard",
+ acquirer_bin: "555555",
+ acquirer_country_code: "US",
+ is_default: false,
+};
+
+const acquirerConfigUpdate = {
+ network: "Visa",
+ acquirer_assigned_merchant_id: "M987654321",
+ merchant_name: "Updated Retailer",
+ acquirer_bin: "987654",
+ acquirer_ica: "501288",
+ acquirer_fraud_rate: 0.02,
+ acquirer_country_code: "US",
+ is_default: true,
+};
+
+const acquirerConfigErrorNonExistentProfile = {
+ profile_id: "pro_nonexistent_12345",
+ acquirer_assigned_merchant_id: "M999999999",
+ merchant_name: "Invalid Profile",
+ network: "Visa",
+ acquirer_bin: "999999",
+};
+
+const acquirerConfigErrorUpdateNonExistentId = {
+ network: "Visa",
+ acquirer_bin: "111111",
+};
+
+const acquirerConfigErrorNoNetwork = {
+ acquirer_bin: "222222",
+};
+
+describe("Acquirer-specific configurations", () => {
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ after("cleanup business profile", () => {
+ cy.deleteBusinessProfileTest(globalState, "acquirerConfigProfile");
+ });
+
+ context(
+ "Create, Update, and Verify Visa Acquirer Config (is_default=true)",
+ () => {
+ it("Create Business Profile", () => {
+ cy.createBusinessProfileTest(
+ fixtures.businessProfile.bpCreate,
+ globalState,
+ "acquirerConfigProfile"
+ );
+ });
+
+ it("Create Acquirer Config (Visa, is_default=true)", () => {
+ const body = { ...acquirerConfigCreateVisa };
+ cy.createAcquirerConfigTest(
+ body,
+ globalState,
+ 200,
+ "acquirerConfigProfile"
+ );
+ });
+
+ it("Update Acquirer Config", () => {
+ const body = { ...acquirerConfigUpdate };
+ body.acquirer_bin = Cypress._.random(100000, 999999).toString();
+ globalState.set("visaAcquirerBin", body.acquirer_bin);
+ cy.updateAcquirerConfigTest(
+ body,
+ globalState,
+ 200,
+ "acquirerConfigProfile"
+ );
+ });
+
+ it("Retrieve Business Profile — Verify acquirer_config_bucket populated", () => {
+ cy.verifyBusinessProfileAcquirerConfigTest(
+ globalState,
+ "acquirerConfigProfile"
+ );
+ });
+ }
+ );
+
+ context("Error Cases — Update (requires existing Visa acquirer)", () => {
+ beforeEach(function () {
+ if (!globalState.get("profileAcquirerId")) {
+ this.skip();
+ }
+ });
+
+ it("Update with non-existent profile_acquirer_id → 404 HE_02", () => {
+ const body = {
+ ...acquirerConfigErrorUpdateNonExistentId,
+ };
+ cy.updateAcquirerConfigTest(
+ body,
+ globalState,
+ 404,
+ "acquirerConfigProfile",
+ "pro_acq_nonexistent_12345"
+ );
+ });
+
+ it("Update without network field → 422 IR_06", () => {
+ const body = {
+ ...acquirerConfigErrorNoNetwork,
+ };
+ cy.updateAcquirerConfigTest(
+ body,
+ globalState,
+ 422,
+ "acquirerConfigProfile"
+ );
+ });
+ });
+
+ context(
+ "Create Second Acquirer Config (Mastercard, is_default=false)",
+ () => {
+ beforeEach(function () {
+ if (
+ !globalState.get("acquirerConfigProfileId") ||
+ !globalState.get("profileAcquirerId")
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Acquirer Config (Mastercard)", () => {
+ globalState.set("visaAcquirerId", globalState.get("profileAcquirerId"));
+ const body = { ...acquirerConfigCreateMastercard };
+ cy.createAcquirerConfigTest(
+ body,
+ globalState,
+ 200,
+ "acquirerConfigProfile",
+ "mastercardAcquirerId"
+ );
+ });
+
+ it("Retrieve Business Profile — Verify both acquirer configs", () => {
+ cy.verifyBusinessProfileAcquirerConfigTest(
+ globalState,
+ "acquirerConfigProfile",
+ "verifyMultipleAcquirerConfigs"
+ );
+ });
+ }
+ );
+
+ context("Error Cases — Create (independent)", () => {
+ it("Create with non-existent profile_id → 404 HE_02", () => {
+ const body = {
+ ...acquirerConfigErrorNonExistentProfile,
+ };
+ cy.createAcquirerConfigTest(body, globalState, 404);
+ });
+ });
+});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/55-DynamicFields.cy.js b/cypress-tests/cypress/e2e/spec/Payment/55-DynamicFields.cy.js
index 3291eb1a64..5227bd921a 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/55-DynamicFields.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/55-DynamicFields.cy.js
@@ -9,10 +9,20 @@ describe("Dynamic Fields Verification", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
+ globalState.set("originalProfileId", globalState.get("profileId"));
+ globalState.set(
+ "originalMerchantConnectorId",
+ globalState.get("merchantConnectorId")
+ );
});
});
- after("flush global state and cleanup", () => {
+ after("flush global state", () => {
+ globalState.set("profileId", globalState.get("originalProfileId"));
+ globalState.set(
+ "merchantConnectorId",
+ globalState.get("originalMerchantConnectorId")
+ );
cy.task("setGlobalState", globalState.data);
});
@@ -168,10 +178,10 @@ describe("Dynamic Fields Verification", () => {
]["PmListResponse"]["pmListDynamicFieldWithEmail"];
cy.paymentMethodListTestWithRequiredFields(data, globalState);
});
+ });
- it("Delete Business Profile", () => {
- cy.deleteBusinessProfileTest(globalState);
- });
+ it("Delete Business Profile", () => {
+ cy.deleteBusinessProfileTest(globalState);
});
});
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 70e38c790c..db72de936b 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -11250,6 +11250,245 @@ Cypress.Commands.add("retrieveNonExistentPayoutTest", (globalState) => {
});
});
+/**
+ * Creates an acquirer configuration for a business profile.
+ *
+ * POST /profile_acquirer
+ *
+ * @param {Object} requestBody - Acquirer config fields (profile_id is set from globalState on success)
+ * @param {Object} globalState - Global state instance
+ * @param {number} expectedStatus - Expected HTTP status (default 200)
+ * @param {string} profilePrefix - globalState key prefix for profileId (default "profile")
+ * @param {string} stateKey - globalState key for storing profile_acquirer_id (default "profileAcquirerId")
+ */
+Cypress.Commands.add(
+ "createAcquirerConfigTest",
+ (
+ requestBody,
+ globalState,
+ expectedStatus = 200,
+ profilePrefix = "profile",
+ stateKey = "profileAcquirerId"
+ ) => {
+ const apiKey = globalState.get("apiKey");
+ const baseUrl = globalState.get("baseUrl");
+
+ if (expectedStatus === 200 && !requestBody.profile_id) {
+ requestBody.profile_id = globalState.get(`${profilePrefix}Id`);
+ }
+
+ cy.request({
+ method: "POST",
+ url: `${baseUrl}/profile_acquirer`,
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ "api-key": apiKey,
+ },
+ body: requestBody,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.status).to.equal(expectedStatus);
+
+ if (expectedStatus === 200) {
+ globalState.set(stateKey, response.body.profile_acquirer_id);
+ expect(response.body).to.have.property("profile_acquirer_id");
+ expect(response.body.profile_id).to.equal(
+ globalState.get(`${profilePrefix}Id`)
+ );
+ expect(response.body.network).to.equal(requestBody.network);
+ expect(response.body.acquirer_assigned_merchant_id).to.equal(
+ requestBody.acquirer_assigned_merchant_id
+ );
+ expect(response.body.merchant_name).to.equal(
+ requestBody.merchant_name
+ );
+ expect(response.body.acquirer_bin).to.equal(requestBody.acquirer_bin);
+ if (requestBody.acquirer_ica !== undefined) {
+ expect(response.body.acquirer_ica).to.equal(
+ requestBody.acquirer_ica
+ );
+ }
+ if (requestBody.acquirer_fraud_rate !== undefined) {
+ expect(response.body.acquirer_fraud_rate).to.equal(
+ requestBody.acquirer_fraud_rate
+ );
+ }
+ expect(response.body.acquirer_country_code).to.be.oneOf([
+ requestBody.acquirer_country_code,
+ "840",
+ ]);
+ if (requestBody.is_default !== undefined) {
+ expect(response.body.is_default).to.equal(requestBody.is_default);
+ }
+ } else {
+ expect(response.body.error).to.exist;
+ if (expectedStatus === 404) {
+ expect(response.body.error.code).to.equal("HE_02");
+ } else if (expectedStatus === 422) {
+ expect(response.body.error.code).to.equal("IR_06");
+ }
+ }
+ });
+ });
+ }
+);
+
+/**
+ * Updates an existing acquirer configuration.
+ *
+ * POST /profile_acquirer/{profile_id}/{profile_acquirer_id}
+ *
+ * @param {Object} requestBody - Fields to update (must include `network` unless only changing is_default)
+ * @param {Object} globalState - Global state instance
+ * @param {number} expectedStatus - Expected HTTP status (default 200)
+ * @param {string} profilePrefix - globalState key prefix for profileId (default "profile")
+ * @param {string|null} profileAcquirerIdOverride - Override for profileAcquirerId (for error cases)
+ */
+Cypress.Commands.add(
+ "updateAcquirerConfigTest",
+ (
+ requestBody,
+ globalState,
+ expectedStatus = 200,
+ profilePrefix = "profile",
+ profileAcquirerIdOverride = null
+ ) => {
+ const apiKey = globalState.get("apiKey");
+ const baseUrl = globalState.get("baseUrl");
+ const profileId = globalState.get(`${profilePrefix}Id`);
+ const profileAcquirerId =
+ profileAcquirerIdOverride || globalState.get("profileAcquirerId");
+
+ cy.request({
+ method: "POST",
+ url: `${baseUrl}/profile_acquirer/${profileId}/${profileAcquirerId}`,
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ "api-key": apiKey,
+ },
+ body: requestBody,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.status).to.equal(expectedStatus);
+
+ if (expectedStatus === 200) {
+ expect(response.body.profile_acquirer_id).to.equal(profileAcquirerId);
+ expect(response.body.profile_id).to.equal(profileId);
+ expect(response.body.network).to.equal(requestBody.network);
+ expect(response.body.acquirer_assigned_merchant_id).to.equal(
+ requestBody.acquirer_assigned_merchant_id
+ );
+ expect(response.body.merchant_name).to.equal(
+ requestBody.merchant_name
+ );
+ expect(response.body.acquirer_bin).to.equal(requestBody.acquirer_bin);
+ if (requestBody.acquirer_ica !== undefined) {
+ expect(response.body.acquirer_ica).to.equal(
+ requestBody.acquirer_ica
+ );
+ }
+ if (requestBody.acquirer_fraud_rate !== undefined) {
+ expect(response.body.acquirer_fraud_rate).to.equal(
+ requestBody.acquirer_fraud_rate
+ );
+ }
+ expect(response.body.acquirer_country_code).to.be.oneOf([
+ requestBody.acquirer_country_code,
+ "840",
+ ]);
+ if (requestBody.is_default !== undefined) {
+ expect(response.body.is_default).to.equal(requestBody.is_default);
+ }
+ } else {
+ expect(response.body.error).to.exist;
+ if (expectedStatus === 404) {
+ expect(response.body.error.code).to.equal("HE_02");
+ } else if (expectedStatus === 422) {
+ expect(response.body.error.code).to.equal("IR_06");
+ }
+ }
+ });
+ });
+ }
+);
+
+Cypress.Commands.add(
+ "verifyBusinessProfileAcquirerConfigTest",
+ (globalState, profilePrefix = "profile", verificationType = null) => {
+ const apiKey = globalState.get("apiKey");
+ const baseUrl = globalState.get("baseUrl");
+ const merchantId = globalState.get("merchantId");
+ const profileId = globalState.get(`${profilePrefix}Id`);
+
+ return cy
+ .request({
+ method: "GET",
+ url: `${baseUrl}/account/${merchantId}/business_profile/${profileId}`,
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ "api-key": apiKey,
+ },
+ failOnStatusCode: false,
+ })
+ .then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+ expect(response.status).to.equal(200);
+
+ if (verificationType === "verifyMultipleAcquirerConfigs") {
+ expect(response.body.acquirer_configs).to.be.an("array");
+ expect(response.body.acquirer_configs.length).to.be.at.least(2);
+ expect(response.body.acquirer_config_bucket).to.not.be.null;
+ expect(response.body.acquirer_config_bucket.configs).to.have.property(
+ globalState.get("visaAcquirerId")
+ );
+ expect(response.body.acquirer_config_bucket.configs).to.have.property(
+ globalState.get("mastercardAcquirerId")
+ );
+
+ const networks = response.body.acquirer_configs.map(
+ (config) => config.network
+ );
+ expect(networks).to.include("Visa");
+ expect(networks).to.include("Mastercard");
+ return;
+ }
+
+ expect(response.body.acquirer_configs).to.be.an("array");
+ expect(response.body.acquirer_configs.length).to.be.greaterThan(0);
+ expect(response.body.acquirer_config_bucket).to.not.be.null;
+ expect(response.body.acquirer_config_bucket).to.have.property(
+ "default_acquirer_config"
+ );
+ expect(response.body.acquirer_config_bucket).to.have.property(
+ "configs"
+ );
+ expect(
+ response.body.acquirer_config_bucket.default_acquirer_config
+ ).to.equal(globalState.get("profileAcquirerId"));
+
+ const configs =
+ response.body.acquirer_config_bucket.configs[
+ globalState.get("profileAcquirerId")
+ ];
+ expect(configs).to.be.an("array");
+ expect(configs[0].network).to.equal("Visa");
+ expect(configs[0].acquirer_bin).to.equal(
+ globalState.get("visaAcquirerBin")
+ );
+ expect(configs[0].acquirer_country_code).to.be.oneOf(["US", "840"]);
+ });
+ }
+);
+
// ============================================
// Superposition Config Commands
// ============================================
diff --git a/cypress-tests/package-lock.json b/cypress-tests/package-lock.json
index ef2ef21872..b3050b8931 100644
--- a/cypress-tests/package-lock.json
+++ b/cypress-tests/package-lock.json
@@ -19,14 +19,14 @@
"@types/node": "^24.2.1",
"cypress": "^14.5.4",
"cypress-mochawesome-reporter": "^4.0.2",
- "eslint": "^9.32.0",
+ "eslint": "^9.39.5",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-cypress": "^5.1.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.5.4",
"globals": "^16.3.0",
"jsqr": "^1.4.0",
- "prettier": "^3.6.2",
+ "prettier": "^3.9.6",
"ts-node": "^10.9.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.39.1"
@@ -183,9 +183,9 @@
}
},
"node_modules/@eslint/eslintrc": {
- "version": "3.3.5",
- "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.5.tgz",
- "integrity": "sha512-4IlJx0X0qftVsN5E+/vGujTRIFtwuLbNsVUe7TO6zYPDR1O6nFwvwhIKEKSrl6dZchmYBITazxKoUYOjdtjlRg==",
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.6.tgz",
+ "integrity": "sha512-l2Ul9PrHsPCKcEY/ac7VgFj9D80C7S68sOKc618SyHDPK36s1XcFebXY0iTzUVn4Yq+YbwvSnDmCz9yxjX+QrA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -195,7 +195,7 @@
"globals": "^14.0.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
- "js-yaml": "^4.1.1",
+ "js-yaml": "^4.3.0",
"minimatch": "^3.1.5",
"strip-json-comments": "^3.1.1"
},
@@ -220,9 +220,9 @@
}
},
"node_modules/@eslint/js": {
- "version": "9.39.4",
- "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.4.tgz",
- "integrity": "sha512-nE7DEIchvtiFTwBw4Lfbu59PG+kCofhjsKaCWzxTpt4lfRjRMqG6uMBzKXuEcyXhOHoUp9riAm7/aWYGhXZ9cw==",
+ "version": "9.39.5",
+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.5.tgz",
+ "integrity": "sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2483,9 +2483,9 @@
}
},
"node_modules/eslint": {
- "version": "9.39.4",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.4.tgz",
- "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==",
+ "version": "9.39.5",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.5.tgz",
+ "integrity": "sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -2494,8 +2494,8 @@
"@eslint/config-array": "^0.21.2",
"@eslint/config-helpers": "^0.4.2",
"@eslint/core": "^0.17.0",
- "@eslint/eslintrc": "^3.3.5",
- "@eslint/js": "9.39.4",
+ "@eslint/eslintrc": "^3.3.6",
+ "@eslint/js": "9.39.5",
"@eslint/plugin-kit": "^0.4.1",
"@humanfs/node": "^0.16.6",
"@humanwhocodes/module-importer": "^1.0.1",
@@ -4338,10 +4338,20 @@
"license": "MIT"
},
"node_modules/js-yaml": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
- "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz",
+ "integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==",
"dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/puzrin"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/nodeca"
+ }
+ ],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -5495,9 +5505,9 @@
}
},
"node_modules/prettier": {
- "version": "3.8.3",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz",
- "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==",
+ "version": "3.9.6",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz",
+ "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==",
"dev": true,
"license": "MIT",
"bin": {
diff --git a/cypress-tests/package.json b/cypress-tests/package.json
index 4c66f233fd..b72d58d5a0 100644
--- a/cypress-tests/package.json
+++ b/cypress-tests/package.json
@@ -40,14 +40,14 @@
"@types/node": "^24.2.1",
"cypress": "^14.5.4",
"cypress-mochawesome-reporter": "^4.0.2",
- "eslint": "^9.32.0",
+ "eslint": "^9.39.5",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-cypress": "^5.1.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.5.4",
"globals": "^16.3.0",
"jsqr": "^1.4.0",
- "prettier": "^3.6.2",
+ "prettier": "^3.9.6",
"ts-node": "^10.9.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.39.1"