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

ci(cypress): add testcases for nti based mit flow (#6567)

Shankar Singh Cea81432e3eb7
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00020-MandatesUsingNTID.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00020-MandatesUsingNTID.cy.js
new file mode 100644
index 0000000000..edd46f7f83
--- /dev/null
+++ b/cypress-tests/cypress/e2e/PaymentTest/00020-MandatesUsingNTID.cy.js
@@ -0,0 +1,221 @@
+import * as fixtures from "../../fixtures/imports";
+import State from "../../utils/State";
+import getConnectorDetails, * as utils from "../PaymentUtils/Utils";
+
+let globalState;
+let connector;
+
+describe("Card - Mandates using Network Transaction Id flow test", () => {
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ connector = globalState.get("connectorId");
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context(
+ "Card - NoThreeDS Create and Confirm Automatic MIT payment flow test",
+ () => {
+ let should_continue = true;
+
+ beforeEach(function () {
+ if (!should_continue || connector !== "cybersource") {
+ this.skip();
+ }
+ });
+
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "automatic",
+ globalState
+ );
+ });
+ }
+ );
+
+ context(
+ "Card - NoThreeDS Create and Confirm Manual MIT payment flow test",
+ () => {
+ let should_continue = true;
+
+ beforeEach(function () {
+ if (!should_continue || connector !== "cybersource") {
+ this.skip();
+ }
+ });
+
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "manual",
+ globalState
+ );
+ });
+ }
+ );
+
+ context(
+ "Card - NoThreeDS Create and Confirm Automatic multiple MITs payment flow test",
+ () => {
+ let should_continue = true;
+
+ beforeEach(function () {
+ if (!should_continue || connector !== "cybersource") {
+ this.skip();
+ }
+ });
+
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "automatic",
+ globalState
+ );
+ });
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "automatic",
+ globalState
+ );
+ });
+ }
+ );
+
+ context(
+ "Card - NoThreeDS Create and Confirm Manual multiple MITs payment flow test",
+ () => {
+ let should_continue = true;
+
+ beforeEach(function () {
+ if (!should_continue || connector !== "cybersource") {
+ this.skip();
+ }
+ });
+
+ it("Confirm No 3DS MIT 1", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 6500,
+ true,
+ "manual",
+ globalState
+ );
+ });
+
+ it("mit-capture-call-test", () => {
+ let data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Capture"];
+ let req_data = data["Request"];
+ let res_data = data["Response"];
+
+ cy.captureCallTest(
+ fixtures.captureBody,
+ req_data,
+ res_data,
+ 6500,
+ globalState
+ );
+ if (should_continue)
+ should_continue = utils.should_continue_further(res_data);
+ });
+
+ it("Confirm No 3DS MIT 2", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 6500,
+ true,
+ "manual",
+ globalState
+ );
+ });
+
+ it("mit-capture-call-test", () => {
+ let data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Capture"];
+ let req_data = data["Request"];
+ let res_data = data["Response"];
+
+ cy.captureCallTest(
+ fixtures.captureBody,
+ req_data,
+ res_data,
+ 6500,
+ globalState
+ );
+ if (should_continue)
+ should_continue = utils.should_continue_further(res_data);
+ });
+ }
+ );
+
+ context(
+ "Card - ThreeDS Create and Confirm Automatic multiple MITs payment flow test",
+ () => {
+ let should_continue = true;
+
+ beforeEach(function () {
+ if (!should_continue || connector !== "cybersource") {
+ this.skip();
+ }
+ });
+
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "automatic",
+ globalState
+ );
+ });
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "automatic",
+ globalState
+ );
+ });
+ }
+ );
+
+ context(
+ "Card - ThreeDS Create and Confirm Manual multiple MITs payment flow",
+ () => {
+ let should_continue = true;
+
+ beforeEach(function () {
+ if (!should_continue || connector !== "cybersource") {
+ this.skip();
+ }
+ });
+
+ it("Confirm No 3DS MIT", () => {
+ cy.mitUsingNTID(
+ fixtures.ntidConfirmBody,
+ 7000,
+ true,
+ "automatic",
+ globalState
+ );
+ });
+ }
+ );
+});
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00020-UPI.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00021-UPI.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/PaymentTest/00020-UPI.cy.js
rename to cypress-tests/cypress/e2e/PaymentTest/00021-UPI.cy.js
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00021-Variations.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00022-Variations.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/PaymentTest/00021-Variations.cy.js
rename to cypress-tests/cypress/e2e/PaymentTest/00022-Variations.cy.js
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00023-PaymentMethods.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js
rename to cypress-tests/cypress/e2e/PaymentTest/00023-PaymentMethods.cy.js
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00023-ConnectorAgnostic.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00024-ConnectorAgnostic.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/PaymentTest/00023-ConnectorAgnostic.cy.js
rename to cypress-tests/cypress/e2e/PaymentTest/00024-ConnectorAgnostic.cy.js
diff --git a/cypress-tests/cypress/fixtures/create-ntid-mit.json b/cypress-tests/cypress/fixtures/create-ntid-mit.json
new file mode 100644
index 0000000000..93b7e95e2a
--- /dev/null
+++ b/cypress-tests/cypress/fixtures/create-ntid-mit.json
@@ -0,0 +1,49 @@
+{
+ "amount": 999,
+ "currency": "USD",
+ "confirm": true,
+ "payment_method": "card",
+ "return_url": "https://hyperswitch.io",
+ "email": "[email protected]",
+ "recurring_details": {
+ "type": "network_transaction_id_and_card_details",
+ "data": {
+ "card_number": "4242424242424242",
+ "card_exp_month": "11",
+ "card_exp_year": "2024",
+ "card_holder_name": "joseph Doe",
+ "network_transaction_id": "MCC5ZRGMI0925"
+ }
+ },
+ "off_session": true,
+ "billing": {
+ "address": {
+ "first_name": "John",
+ "last_name": "Doe",
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "city": "San Fransico",
+ "state": "California",
+ "zip": "94122",
+ "country": "US"
+ },
+ "phone": {
+ "number": "9123456789",
+ "country_code": "+91"
+ }
+ },
+ "browser_info": {
+ "ip_address": "129.0.0.1",
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
+ "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
+ "language": "en-US",
+ "color_depth": 30,
+ "screen_height": 1117,
+ "screen_width": 1728,
+ "time_zone": -330,
+ "java_enabled": true,
+ "java_script_enabled": true
+ }
+ }
+
\ No newline at end of file
diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.js
index 900e4f4ea3..49fea00491 100644
--- a/cypress-tests/cypress/fixtures/imports.js
+++ b/cypress-tests/cypress/fixtures/imports.js
@@ -24,6 +24,7 @@ import updateBusinessProfile from "./update-business-profile.json";
import updateConnectorBody from "./update-connector-body.json";
import customerUpdateBody from "./update-customer-body.json";
import voidBody from "./void-payment-body.json";
+import ntidConfirmBody from "./create-ntid-mit.json";
export {
apiKeyCreateBody,
@@ -44,6 +45,7 @@ export {
merchantCreateBody,
merchantUpdateBody,
mitConfirmBody,
+ ntidConfirmBody,
pmIdConfirmBody,
refundBody,
routingConfigBody,
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 3df6c901d9..48a62fb438 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -2087,6 +2087,81 @@ Cypress.Commands.add(
}
);
+Cypress.Commands.add(
+ "mitUsingNTID",
+ (requestBody, amount, confirm, capture_method, globalState) => {
+
+ requestBody.amount = amount;
+ requestBody.confirm = confirm;
+ requestBody.capture_method = capture_method;
+
+ if (globalState.get("connectorId") !== "cybersource") {
+ return;
+ }
+
+ const apiKey = globalState.get("apiKey");
+ const baseUrl = globalState.get("baseUrl");
+ const url = `${baseUrl}/payments`;
+
+ cy.request({
+ method: "POST",
+ url: url,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": apiKey,
+ },
+ failOnStatusCode: false,
+ body: requestBody,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ if (response.status === 200) {
+ expect(response.headers["content-type"]).to.include("application/json");
+
+ globalState.set("paymentID", response.body.payment_id);
+
+ if (response.body.capture_method === "automatic") {
+ if (response.body.authentication_type === "three_ds") {
+ expect(response.body)
+ .to.have.property("next_action")
+ .to.have.property("redirect_to_url");
+ const nextActionUrl = response.body.next_action.redirect_to_url;
+ cy.log(nextActionUrl);
+ } else if (response.body.authentication_type === "no_three_ds") {
+ expect(response.body.status).to.equal("succeeded");
+ } else {
+ throw new Error(
+ `Invalid authentication type ${response.body.authentication_type}`
+ );
+ }
+ } else if (response.body.capture_method === "manual") {
+ if (response.body.authentication_type === "three_ds") {
+ expect(response.body)
+ .to.have.property("next_action")
+ .to.have.property("redirect_to_url");
+ const nextActionUrl = response.body.next_action.redirect_to_url;
+ cy.log(nextActionUrl);
+ } else if (response.body.authentication_type === "no_three_ds") {
+ expect(response.body.status).to.equal("requires_capture");
+ } else {
+ throw new Error(
+ `Invalid authentication type ${response.body.authentication_type}`
+ );
+ }
+ } else {
+ throw new Error(
+ `Invalid capture method ${response.body.capture_method}`
+ );
+ }
+ } else {
+ throw new Error(
+ `Error Response: ${response.status}\n${response.body.error.message}\n${response.body.error.code}`
+ );
+ }
+ });
+ }
+);
+
Cypress.Commands.add("listMandateCallTest", (globalState) => {
const customerId = globalState.get("customerId");
cy.request({