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 network_transaction_id validation in CIT flows (#12002)

likhinbopanna1493503d5b4e
diff --git a/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js b/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js
index f1225e43ec..4e247fee68 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/25-ConnectorAgnosticNTID.cy.js
@@ -59,7 +59,6 @@ Flow:
describe("Connector Agnostic Tests", () => {
before(function () {
- // Changed to regular function instead of arrow function
let skip = false;
cy.task("getGlobalState")
@@ -67,7 +66,6 @@ describe("Connector Agnostic Tests", () => {
globalState = new State(state);
connector = globalState.get("connectorId");
- // Skip running test against a connector that is added in the exclude list
if (
utils.shouldExcludeConnector(
connector,
@@ -142,6 +140,7 @@ describe("Connector Agnostic Tests", () => {
]["SaveCardUseNo3DSAutoCaptureOffSession"];
cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ cy.assertNetworkTransactionId(globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
@@ -330,6 +329,7 @@ describe("Connector Agnostic Tests", () => {
]["SaveCardUseNo3DSAutoCaptureOffSession"];
cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ cy.assertNetworkTransactionId(globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
@@ -506,6 +506,7 @@ describe("Connector Agnostic Tests", () => {
]["SaveCardUseNo3DSAutoCaptureOffSession"];
cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ cy.assertNetworkTransactionId(globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
@@ -681,6 +682,7 @@ describe("Connector Agnostic Tests", () => {
]["SaveCardUseNo3DSAutoCaptureOffSession"];
cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ cy.assertNetworkTransactionId(globalState);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 8730ae43d8..216e331d01 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -2328,6 +2328,17 @@ Cypress.Commands.add(
"connectorTransactionID",
response.body.connector_transaction_id
);
+ globalState.set(
+ "networkTransactionId",
+ response.body.network_transaction_id
+ );
+ const ntid = response.body.network_transaction_id;
+ if (ntid !== undefined && ntid !== null) {
+ expect(
+ ntid,
+ "network_transaction_id should not be empty when present"
+ ).to.not.be.empty;
+ }
globalState.set("paymentIntentStatus", response.body.status);
// Compare connector with backend connector name (handles stripeconnect -> stripe mapping)
const expectedConnector = getOriginalConnectorName(
@@ -3366,6 +3377,11 @@ Cypress.Commands.add(
// Whenever, CIT Confirmations gets a payment status of `processing`, it does not yield the `payment_method_id` and hence the `paymentMethodId` in the `globalState` gets the value of `null`. And hence while confirming MIT, it yields an `error.message` of `"Json deserialize error: invalid type: null, expected a string at line 1 column 182"` which is basically because of the `null` value in `recurring_details.data` with `recurring_details.type` as `payment_method_id`. However, we get the `payment_method_id` while PSync, so we can assign it to the `globalState` here.
globalState.set("paymentMethodId", response.body.payment_method_id);
+ globalState.set(
+ "networkTransactionId",
+ response.body.network_transaction_id
+ );
+
const allowedActiveStatuses = [
"succeeded",
"requires_capture",
@@ -7051,3 +7067,19 @@ Cypress.Commands.add("blocklistToggle", (status, globalState) => {
});
});
});
+
+Cypress.Commands.add(
+ "assertNetworkTransactionId",
+ (globalState, shouldExist = true) => {
+ const ntid = globalState.get("networkTransactionId");
+ if (shouldExist) {
+ expect(ntid, "network_transaction_id").to.exist;
+ expect(ntid, "network_transaction_id").to.not.be.empty;
+ } else {
+ expect(
+ ntid === undefined || ntid === null,
+ "network_transaction_id should not exist for excluded connector"
+ ).to.be.true;
+ }
+ }
+);