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): verify mandate id to be `null` if payment id not `succeeded` (#7749)

Pa1NarK0662a0a7b186
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnosticNTID.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnosticNTID.cy.js
index 8491cb0b8c..f1225e43ec 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnosticNTID.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnosticNTID.cy.js
@@ -573,9 +573,10 @@ describe("Connector Agnostic Tests", () => {
fixtures.pmIdConfirmBody,
data,
7000,
- true,
+ true /* confirm */,
"automatic",
- globalState
+ globalState,
+ true /* connector_agnostic_mit */
);
});
@@ -747,7 +748,8 @@ describe("Connector Agnostic Tests", () => {
7000,
true,
"automatic",
- globalState
+ globalState,
+ true /* connector_agnostic_mit */
);
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 77ae6b70ba..048fe78c44 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -2382,7 +2382,7 @@ Cypress.Commands.add(
"payment_method_id"
).to.include("pm_").and.to.not.be.null;
- const activeStatuses = [
+ const allowedActiveStatuses = [
"succeeded",
"requires_capture",
"partially_captured",
@@ -2391,10 +2391,12 @@ Cypress.Commands.add(
// If capture method is manual, 'processing' status also means 'active'
// for the payment method's usability.
if (response.body.capture_method === "manual") {
- activeStatuses.push("processing");
+ allowedActiveStatuses.push("processing");
}
- const expectedStatus = activeStatuses.includes(response.body.status)
+ const expectedStatus = allowedActiveStatuses.includes(
+ response.body.status
+ )
? "active"
: "inactive";
@@ -2713,6 +2715,7 @@ Cypress.Commands.add(
expect(response.body.profile_id, "profile_id").to.not.be.null;
expect(response.body.payment_method_id, "payment_method_id").to.not.be
.null;
+
if (response.body.capture_method === "automatic") {
if (response.body.authentication_type === "three_ds") {
expect(response.body)
@@ -2776,7 +2779,15 @@ Cypress.Commands.add(
Cypress.Commands.add(
"mitUsingPMId",
- (requestBody, data, amount, confirm, capture_method, globalState) => {
+ (
+ requestBody,
+ data,
+ amount,
+ confirm,
+ capture_method,
+ globalState,
+ connector_agnostic_mit
+ ) => {
const {
Configs: configs = {},
Request: reqData,
@@ -2821,11 +2832,6 @@ Cypress.Commands.add(
if (response.status === 200) {
globalState.set("paymentID", response.body.payment_id);
- expect(
- response.body.payment_method_id,
- "payment_method_id"
- ).to.include("pm_").and.to.not.be.null;
-
if (response.body.status === "failed") {
expect(
response.body.connector_transaction_id,
@@ -2838,10 +2844,58 @@ Cypress.Commands.add(
).to.not.be.null;
}
- expect(
- response.body.payment_method_status,
- "payment_method_status"
- ).to.equal("active");
+ if (
+ response.body.payment_method_id &&
+ typeof response.body.payment_method_id === "string"
+ ) {
+ expect(
+ response.body.payment_method_id,
+ "payment_method_id"
+ ).to.include("pm_").and.to.not.be.null;
+
+ const allowedActiveStatuses = [
+ "succeeded",
+ "requires_capture",
+ "partially_captured",
+ ];
+
+ if (allowedActiveStatuses.includes(response.body.status)) {
+ expect(response.body.status, "response status").to.be.oneOf(
+ allowedActiveStatuses
+ );
+
+ expect(
+ response.body.payment_method_status,
+ "payment_method_status for active status"
+ ).to.equal("active");
+
+ if (connector_agnostic_mit) {
+ expect(
+ response.body.connector_mandate_id,
+ "connector_mandate_id for active status"
+ ).to.be.null;
+ } else {
+ expect(
+ response.body.connector_mandate_id,
+ "connector_mandate_id for active status"
+ ).to.exist.and.not.be.null;
+ }
+ } else {
+ expect(response.body.status, "response status").to.not.be.oneOf(
+ allowedActiveStatuses
+ );
+
+ expect(
+ response.body.payment_method_status,
+ "payment_method_status for inactive status"
+ ).to.equal("inactive");
+
+ expect(
+ response.body.connector_mandate_id,
+ "connector_mandate_id for inactive status"
+ ).to.be.null;
+ }
+ }
if (response.body.capture_method === "automatic") {
if (response.body.authentication_type === "three_ds") {