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): Nullify positive cases for MIT payments (#5434)

likhinbopanna8e7de9068428
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index ccf0ceedde..7236cf7875 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -1170,32 +1170,45 @@ Cypress.Commands.add(
}).then((response) => {
logRequestId(response.headers["x-request-id"]);
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 {
- defaultErrorHandler(response, res_data);
- }
- } 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(response.body);
- cy.log(nextActionUrl);
- } else if (response.body.authentication_type === "no_three_ds") {
- expect(response.body.status).to.equal("requires_capture");
+ if (response.status === 200) {
+ 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 {
- defaultErrorHandler(response, res_data);
+ 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}`
+ );
}
});
}
@@ -1221,33 +1234,45 @@ Cypress.Commands.add(
}).then((response) => {
logRequestId(response.headers["x-request-id"]);
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(response.body);
- cy.log(nextActionUrl);
- } else if (response.body.authentication_type === "no_three_ds") {
- expect(response.body.status).to.equal("succeeded");
- } else {
- defaultErrorHandler(response, res_data);
- }
- } 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(response.body);
- cy.log(nextActionUrl);
- } else if (response.body.authentication_type === "no_three_ds") {
- expect(response.body.status).to.equal("requires_capture");
+ if (response.status === 200) {
+ 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 {
- defaultErrorHandler(response, res_data);
+ 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}`
+ );
}
});
}