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

feat(cypress-v2): introduce list apis to cypress v2 (#5973)

Pa1NarK368cebcb4971
diff --git a/cypress-tests-v2/cypress/e2e/spec/Payment/0000-CoreFlows.cy.js b/cypress-tests-v2/cypress/e2e/spec/Payment/0000-CoreFlows.cy.js
index b2cbcf4a55..6d2be0eb1b 100644
--- a/cypress-tests-v2/cypress/e2e/spec/Payment/0000-CoreFlows.cy.js
+++ b/cypress-tests-v2/cypress/e2e/spec/Payment/0000-CoreFlows.cy.js
@@ -59,6 +59,15 @@ describe("Core APIs", () => {
globalState
);
});
+ it("Second merchant account create call", () => {
+ cy.merchantAccountCreateCall(
+ fixtures.merchant_account_body.ma_create,
+ globalState
+ );
+ });
+ it("List merchant accounts call", () => {
+ cy.merchantAccountsListCall(globalState);
+ });
});
context("Business profile APIs", () => {
@@ -87,6 +96,16 @@ describe("Core APIs", () => {
globalState
);
});
+ it("Second business profile create call", () => {
+ fixtures.business_profile_body.bp_create.profile_name = "HyperSx2";
+ cy.businessProfileCreateCall(
+ fixtures.business_profile_body.bp_create,
+ globalState
+ );
+ });
+ it("List business profiles", () => {
+ cy.businessProfilesListCall(globalState);
+ });
});
context("Merchant connector account APIs", () => {
@@ -127,6 +146,9 @@ describe("Core APIs", () => {
payment_methods_enabled
);
});
+ it("[Payment] Merchant connector accounts list call", () => {
+ cy.mcaListCall(globalState, null);
+ });
});
context("API Key APIs", () => {
@@ -149,5 +171,11 @@ describe("Core APIs", () => {
it("API Key update call", () => {
cy.apiKeyUpdateCall(fixtures.api_key_body.api_key_update, globalState);
});
+ it("Second API Key create call", () => {
+ cy.apiKeyCreateCall(fixtures.api_key_body.api_key_create, globalState);
+ });
+ it("API Keys list call", () => {
+ cy.apiKeysListCall(globalState);
+ });
});
});
diff --git a/cypress-tests-v2/cypress/e2e/spec/Routing/0000-Coreflows.cy.js b/cypress-tests-v2/cypress/e2e/spec/Routing/0000-Coreflows.cy.js
index cde64e563b..2fd8d7a4d6 100644
--- a/cypress-tests-v2/cypress/e2e/spec/Routing/0000-Coreflows.cy.js
+++ b/cypress-tests-v2/cypress/e2e/spec/Routing/0000-Coreflows.cy.js
@@ -37,7 +37,7 @@ describe("Routing core APIs", () => {
});
it("List MCA call", () => {
- cy.listMcaCall(globalState);
+ cy.mcaListCall(globalState, "routing");
});
});
diff --git a/cypress-tests-v2/cypress/support/commands.js b/cypress-tests-v2/cypress/support/commands.js
index d0a90d4106..732882176d 100644
--- a/cypress-tests-v2/cypress/support/commands.js
+++ b/cypress-tests-v2/cypress/support/commands.js
@@ -167,7 +167,7 @@ Cypress.Commands.add(
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const organization_id = globalState.get("organizationId");
- const url = `${base_url}/v2/accounts`;
+ const url = `${base_url}/v2/merchant_accounts`;
const merchant_name = merchantAccountCreateBody.merchant_name
.replaceAll(" ", "")
@@ -221,7 +221,7 @@ Cypress.Commands.add("merchantAccountRetrieveCall", (globalState) => {
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const merchant_id = globalState.get("merchantId");
- const url = `${base_url}/v2/accounts/${merchant_id}`;
+ const url = `${base_url}/v2/merchant_accounts/${merchant_id}`;
cy.request({
method: "GET",
@@ -255,7 +255,7 @@ Cypress.Commands.add("merchantAccountRetrieveCall", (globalState) => {
} else {
// to be updated
throw new Error(
- `Merchant retrieve call failed with status ${response.status} and message ${response.body.message}`
+ `Merchant account retrieve call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -267,7 +267,7 @@ Cypress.Commands.add(
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const merchant_id = globalState.get("merchantId");
- const url = `${base_url}/v2/accounts/${merchant_id}`;
+ const url = `${base_url}/v2/merchant_accounts/${merchant_id}`;
const merchant_name = merchantAccountUpdateBody.merchant_name;
@@ -304,7 +304,7 @@ Cypress.Commands.add(
} else {
// to be updated
throw new Error(
- `Merchant update call failed with status ${response.status} and message ${response.body.message}`
+ `Merchant account update call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -351,7 +351,7 @@ Cypress.Commands.add(
} else {
// to be updated
throw new Error(
- `Merchant update call failed with status ${response.status} and message ${response.body.message}`
+ `Business profile create call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -392,7 +392,7 @@ Cypress.Commands.add("businessProfileRetrieveCall", (globalState) => {
} else {
// to be updated
throw new Error(
- `Merchant update call failed with status ${response.status} and message ${response.body.message}`
+ `Business profile retrieve call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -438,7 +438,7 @@ Cypress.Commands.add(
} else {
// to be updated
throw new Error(
- `Merchant update call failed with status ${response.status} and message ${response.body.message}`
+ `Business profile update call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -475,6 +475,12 @@ Cypress.Commands.add(
mcaCreateBody.connector_type = connectorType;
mcaCreateBody.payment_methods_enabled = paymentMethodsEnabled;
+ if (connectorName === undefined) {
+ throw new Error(
+ `Connector name is a mandatory field to create merchant connector account but is undefined.`
+ );
+ }
+
// readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature
// it is best to use then() to handle the response within the same block of code
cy.readFile(globalState.get("connectorAuthFilePath")).then(
@@ -521,7 +527,7 @@ Cypress.Commands.add(
} else {
// to be updated
throw new Error(
- `MCA create call failed with status ${response.status} and message ${response.body.message}`
+ `Merchant connector account create call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -569,7 +575,7 @@ Cypress.Commands.add("mcaRetrieveCall", (globalState) => {
} else {
// to be updated
throw new Error(
- `MCA create call failed with status ${response.status} and message ${response.body.message}`
+ `Merchant connector account retrieve call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -634,7 +640,7 @@ Cypress.Commands.add(
} else {
// to be updated
throw new Error(
- `MCA create call failed with status ${response.status} and message ${response.body.message}`
+ `Merchant connector account update call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -741,7 +747,7 @@ Cypress.Commands.add("apiKeyRetrieveCall", (globalState) => {
} else {
// to be updated
throw new Error(
- `API Key create call failed with status ${response.status} and message ${response.body.message}`
+ `API Key retrieve call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -797,7 +803,7 @@ Cypress.Commands.add("apiKeyUpdateCall", (apiKeyUpdateBody, globalState) => {
} else {
// to be updated
throw new Error(
- `API Key create call failed with status ${response.status} and message ${response.body.message}`
+ `API Key update call failed with status ${response.status} and message ${response.body.message}`
);
}
});
@@ -1169,12 +1175,56 @@ Cypress.Commands.add("userInfo", (globalState) => {
});
// List API calls
-Cypress.Commands.add("listMcaCall", (globalState) => {
+Cypress.Commands.add("merchantAccountsListCall", (globalState) => {
+ // Define the necessary variables and constants
+ const api_key = globalState.get("adminApiKey");
+ const base_url = globalState.get("baseUrl");
+ const organization_id = globalState.get("organizationId");
+ const url = `${base_url}/v2/organization/${organization_id}/merchant_accounts`;
+
+ cy.request({
+ method: "GET",
+ url: url,
+ headers: {
+ "api-key": api_key,
+ "Content-Type": "application/json",
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ if (response.status === 200) {
+ expect(response.body).to.be.an("array").and.to.not.be.empty;
+ for (const key in response.body) {
+ expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
+ expect(response.body[key])
+ .to.have.property("organization_id")
+ .and.to.equal(organization_id);
+ if (base_url.includes("integ") || base_url.includes("sandbox")) {
+ expect(response.body[key])
+ .to.have.property("publishable_key")
+ .and.include("pk_snd_").and.to.not.be.empty;
+ } else if (base_url.includes("localhost")) {
+ expect(response.body[key])
+ .to.have.property("publishable_key")
+ .and.include("pk_dev_").and.to.not.be.empty;
+ }
+ expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
+ }
+ } else {
+ // to be updated
+ throw new Error(
+ `API Keys list call failed with status ${response.status} and message ${response.body.message}`
+ );
+ }
+ });
+});
+Cypress.Commands.add("businessProfilesListCall", (globalState) => {
// Define the necessary variables and constants
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const merchant_id = globalState.get("merchantId");
- const url = `${base_url}/v2/account/${merchant_id}/connectors`;
+ const url = `${base_url}/v2/merchant_accounts/${merchant_id}/profiles`;
const customHeaders = {
"x-merchant-id": merchant_id,
@@ -1193,55 +1243,120 @@ Cypress.Commands.add("listMcaCall", (globalState) => {
logRequestId(response.headers["x-request-id"]);
if (response.status === 200) {
- // Control never comes here until the API endpoints are introduced
- console.log("List MCA call successful");
- globalState.set(
- "adyenMerchantConnectorId",
- response.body[2].merchant_connector_id
- );
- globalState.set(
- "bluesnapMerchantConnectorId",
- response.body[0].merchant_connector_id
- );
- globalState.set(
- "stripeMerchantConnectorId",
- response.body[1].merchant_connector_id
- );
- } else if (response.status === 404) {
- expect(response.body.error)
- .to.have.property("message")
- .and.to.equal("Unrecognized request URL");
- expect(response.body.error)
- .to.have.property("type")
- .and.to.equal("invalid_request");
-
- // hard code MCA values for now
- if (base_url.includes("integ")) {
- globalState.set("adyenMerchantConnectorId", "mca_YOGOW6CdrjudsT9Mvg7w");
- globalState.set(
- "bluesnapMerchantConnectorId",
- "mca_cdKJoouwpmkHqwVJ1bzV"
- );
- globalState.set(
- "stripeMerchantConnectorId",
- "mca_KyxoOnfLXWE1hzPSsl9H"
- );
+ expect(response.body).to.be.an("array").and.to.not.be.empty;
+ for (const key in response.body) {
+ expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
+ expect(response.body[key])
+ .to.have.property("merchant_id")
+ .and.to.equal(merchant_id);
+ expect(response.body[key]).to.have.property("payment_response_hash_key")
+ .and.to.not.be.empty;
}
} else {
// to be updated
throw new Error(
- `MCA list call failed with status ${response.status} and message ${response.body.message}`
+ `API Keys list call failed with status ${response.status} and message ${response.body.message}`
);
}
});
});
-// templates
-Cypress.Commands.add("", () => {
- cy.request({}).then((response) => {});
+Cypress.Commands.add("mcaListCall", (globalState, service_type) => {
+ // Define the necessary variables and constants
+ const api_key = globalState.get("adminApiKey");
+ const base_url = globalState.get("baseUrl");
+ const merchant_id = globalState.get("merchantId");
+ const profile_id = globalState.get("profileId");
+ const url = `${base_url}/v2/profiles/${profile_id}/connector_accounts`;
+
+ const customHeaders = {
+ "x-merchant-id": merchant_id,
+ };
+
+ cy.request({
+ method: "GET",
+ url: url,
+ headers: {
+ "api-key": api_key,
+ "Content-Type": "application/json",
+ ...customHeaders,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ if (response.status === 200) {
+ // TODO: Update List MCA such that it should handle cases for both routing as well normal calls
+ // TODO: Present implementation looks a bit hacky
+ if (service_type === "routing") {
+ if (response.body[0].connector_name === "stripe")
+ globalState.set("stripeMerchantConnectorId", response.body[0].id);
+ if (response.body[1].connector_name === "adyen")
+ globalState.set("adyenMerchantConnectorId", response.body[1].id);
+ if (response.body[2].connector_name === "bluesnap")
+ globalState.set("bluesnapMerchantConnectorId", response.body[2].id);
+ } else {
+ expect(response.body).to.be.an("array").and.to.not.be.empty;
+ for (const key in response.body) {
+ expect(response.body[key]).to.have.property("connector_name").and.to
+ .not.be.empty;
+ expect(response.body[key]).to.have.property("connector_label").and.to
+ .not.be.empty;
+ expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
+ expect(response.body[key])
+ .to.have.property("payment_methods_enabled")
+ .and.to.be.an("array").and.to.not.be.empty;
+ expect(response.body[key])
+ .to.have.property("profile_id")
+ .and.to.equal(profile_id);
+ expect(response.body[key])
+ .to.have.property("status")
+ .and.to.equal("active");
+ }
+ }
+ } else {
+ // to be updated
+ throw new Error(
+ `Merchant connector account list call failed with status ${response.status} and message ${response.body.message}`
+ );
+ }
+ });
});
-Cypress.Commands.add("", () => {
- cy.request({}).then((response) => {});
+Cypress.Commands.add("apiKeysListCall", (globalState) => {
+ // Define the necessary variables and constants
+ const api_key = globalState.get("adminApiKey");
+ const base_url = globalState.get("baseUrl");
+ const merchant_id = globalState.get("merchantId");
+ const url = `${base_url}/v2/api_keys/list`;
+
+ const customHeaders = {
+ "x-merchant-id": merchant_id,
+ };
+
+ cy.request({
+ method: "GET",
+ url: url,
+ headers: {
+ "api-key": api_key,
+ "Content-Type": "application/json",
+ ...customHeaders,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ if (response.status === 200) {
+ // This end point does not work
+ expect(response.body).to.be.an("array").and.to.not.be.empty;
+ } else {
+ // to be updated
+ throw new Error(
+ `API Keys list call failed with status ${response.status} and message ${response.body.message}`
+ );
+ }
+ });
});
+
+// templates
Cypress.Commands.add("", () => {
cy.request({}).then((response) => {});
});