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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(cypress): nullify false positives (#5303)
Pa1NarK96edf52ca639
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.jsindex 8513f596f4..1e2e7e0f3c 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js@@ -96,7 +96,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.jsindex 79ea91e1ed..544a0adec9 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js@@ -94,7 +94,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js b/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.jsindex 6cfc84de43..7a7e156b07 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js@@ -62,7 +62,7 @@ export const connectorDetails = {status: 200,trigger_skip: true,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.jsindex 79ea91e1ed..544a0adec9 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js@@ -94,7 +94,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.jsindex 70eea459dc..a5440c4ec8 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js@@ -14,40 +14,6 @@ const successfulThreeDSTestCardDetails = {card_cvc: "999",};-const singleUseMandateData = {- customer_acceptance: {- acceptance_type: "offline",- accepted_at: "1963-05-03T04:07:52.723Z",- online: {- ip_address: "125.0.0.1",- user_agent: "amet irure esse",- },- },- mandate_type: {- single_use: {- amount: 8000,- currency: "USD",- },- },-};--const multiUseMandateData = {- customer_acceptance: {- acceptance_type: "offline",- accepted_at: "1963-05-03T04:07:52.723Z",- online: {- ip_address: "125.0.0.1",- user_agent: "amet irure esse",- },- },- mandate_type: {- multi_use: {- amount: 8000,- currency: "USD",- },- },-};-export const connectorDetails = {card_pm: {PaymentIntent: {@@ -78,7 +44,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "processing",+ status: "requires_customer_action",},},},@@ -94,7 +60,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "processing",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.jsindex 14e69feb3f..256606c29c 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js@@ -64,7 +64,7 @@ export const connectorDetails = {status: 200,trigger_skip: true,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.jsindex c2f8b171dd..f2cf89df24 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js@@ -96,7 +96,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.jsindex 651bc7d06b..dae0b3a5de 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js@@ -63,7 +63,7 @@ export const connectorDetails = {Response: {status: 200,body: {- status: "succeeded",+ status: "requires_customer_action",},},},diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex af7600890b..5aa98a6e4a 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -121,6 +121,10 @@ Cypress.Commands.add("cli_log","response status -> " + JSON.stringify(response.status));++ throw new Error(+ `Connector Create Call Failed ${response.body.error.message}`+ );}});}@@ -174,6 +178,10 @@ Cypress.Commands.add("cli_log","response status -> " + JSON.stringify(response.status));++ throw new Error(+ `Connector Create Call Failed ${response.body.error.message}`+ );}});}@@ -237,6 +245,10 @@ Cypress.Commands.add("cli_log","response status -> " + JSON.stringify(response.status));++ throw new Error(+ `Connector Create Call Failed ${response.body.error.message}`+ );}});}@@ -442,7 +454,7 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {expect(response.body).to.have.property("payment_method_id");expect(response.body).to.have.property("client_secret");globalState.set("paymentMethodId", response.body.payment_method_id);@@ -474,7 +486,7 @@ Cypress.Commands.add(}).then((response) => {logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("paymentID", paymentIntentID);if (response.body.capture_method === "automatic") {if (response.body.authentication_type === "three_ds") {@@ -485,12 +497,17 @@ Cypress.Commands.add("nextActionUrl",response.body.next_action.redirect_to_url);+ for (const key in res_data.body) {+ expect(res_data.body[key]).to.equal(response.body[key]);+ }} else if (response.body.authentication_type === "no_three_ds") {for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type ${response.body.authentication_type}`+ );}} else if (response.body.capture_method === "manual") {if (response.body.authentication_type === "three_ds") {@@ -506,8 +523,14 @@ Cypress.Commands.add(expect(res_data.body[key]).to.equal(response.body[key]);}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type ${response.body.authentication_type}`+ );}+ } else {+ throw new Error(+ `Invalid capture method ${response.body.capture_method}`+ );}} else {defaultErrorHandler(response, res_data);@@ -538,7 +561,7 @@ Cypress.Commands.add(body: confirmBody,}).then((response) => {logRequestId(response.headers["x-request-id"]);- if (res_data.status === 200) {+ if (response.status === 200) {expect(response.headers["content-type"]).to.include("application/json");globalState.set("paymentID", paymentIntentId);globalState.set("paymentMethodType", confirmBody.payment_method_type);@@ -574,7 +597,9 @@ Cypress.Commands.add();}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid capture method ${response.body.capture_method}`+ );}break;case "no_three_ds":@@ -590,11 +615,15 @@ Cypress.Commands.add(response.body.next_action.redirect_to_url);} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid capture method ${response.body.capture_method}`+ );}break;default:- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type ${response.body.authentication_type}`+ );}} else {defaultErrorHandler(response, res_data);@@ -626,7 +655,7 @@ Cypress.Commands.add(}).then((response) => {logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("paymentID", paymentIntentID);if (response.body.capture_method === "automatic" ||@@ -653,7 +682,9 @@ Cypress.Commands.add(break;}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid capture method ${response.body.capture_method}`+ );}} else {defaultErrorHandler(response, res_data);@@ -685,7 +716,7 @@ Cypress.Commands.add(}).then((response) => {logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {if (response.body.capture_method === "automatic" ||response.body.capture_method === "manual"@@ -708,7 +739,9 @@ Cypress.Commands.add();}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid capture method ${response.body.capture_method}`+ );}} else {defaultErrorHandler(response, res_data);@@ -745,7 +778,7 @@ Cypress.Commands.add(}).then((response) => {logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {if (response.body.capture_method === "automatic") {expect(response.body).to.have.property("status");globalState.set("paymentAmount", createConfirmPaymentBody.amount);@@ -763,7 +796,9 @@ Cypress.Commands.add(expect(res_data.body[key]).to.equal(response.body[key]);}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type: ${response.body.authentication_type}`+ );}} else if (response.body.capture_method === "manual") {expect(response.body).to.have.property("status");@@ -782,7 +817,9 @@ Cypress.Commands.add(expect(res_data.body[key]).to.equal(response.body[key]);}} else {- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type: ${response.body.authentication_type}`+ );}}} else {@@ -813,7 +850,7 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("paymentID", paymentIntentID);if (response.body.capture_method === "automatic") {if (response.body.authentication_type === "three_ds") {@@ -830,7 +867,9 @@ Cypress.Commands.add();} else {// Handle other authentication types as needed- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type: ${response.body.authentication_type}`+ );}} else if (response.body.capture_method === "manual") {if (response.body.authentication_type === "three_ds") {@@ -846,8 +885,15 @@ Cypress.Commands.add();} else {// Handle other authentication types as needed- defaultErrorHandler(response, res_data);+ throw new Error(+ `Invalid authentication type: ${response.body.authentication_type}`+ );}+ } else {+ // Handle other capture methods as needed+ throw new Error(+ `Invalid capture method: ${response.body.capture_method}`+ );}} else {defaultErrorHandler(response, res_data);@@ -903,7 +949,7 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}@@ -953,7 +999,7 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("refundId", response.body.refund_id);for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);@@ -1022,10 +1068,9 @@ Cypress.Commands.add(}).then((response) => {logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("paymentID", response.body.payment_id);- globalState.set("paymentID", response.body.payment_id);if (requestBody.mandate_data === null) {expect(response.body).to.have.property("payment_method_id");globalState.set("paymentMethodId", response.body.payment_method_id);@@ -1033,6 +1078,7 @@ Cypress.Commands.add(expect(response.body).to.have.property("mandate_id");globalState.set("mandateId", response.body.mandate_id);}+if (response.body.capture_method === "automatic") {expect(response.body).to.have.property("mandate_id");if (response.body.authentication_type === "three_ds") {@@ -1044,28 +1090,46 @@ Cypress.Commands.add("nextActionUrl",response.body.next_action.redirect_to_url);- cy.log(response.body);cy.log(nextActionUrl);+ for (const key in res_data.body) {+ expect(res_data.body[key]).to.equal(response.body[key]);+ }} else if (response.body.authentication_type === "no_three_ds") {for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}- }- for (const key in res_data.body) {- expect(res_data.body[key]).to.equal(response.body[key]);+ } 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");+ expect(response.body)+ .to.have.property("next_action")+ .to.have.property("redirect_to_url");const nextActionUrl = response.body.next_action.redirect_to_url;globalState.set("nextActionUrl",response.body.next_action.redirect_to_url);+ cy.log(nextActionUrl);+ for (const key in res_data.body) {+ expect(res_data.body[key]).to.equal(response.body[key]);+ }+ } else if (response.body.authentication_type === "no_three_ds") {+ for (const key in res_data.body) {+ expect(res_data.body[key]).to.equal(response.body[key]);+ }+ } else {+ throw new Error(+ `Invalid authentication type ${response.body.authentication_type}`+ );}- for (const key in res_data.body) {- expect(res_data.body[key]).to.equal(response.body[key]);- }+ } else {+ throw new Error(+ `Invalid capture method ${response.body.capture_method}`+ );}} else {defaultErrorHandler(response, res_data);@@ -1102,7 +1166,6 @@ Cypress.Commands.add(.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");@@ -1360,17 +1423,14 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("payoutAmount", createConfirmPayoutBody.amount);globalState.set("payoutID", response.body.payout_id);for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}@@ -1407,17 +1467,14 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {globalState.set("payoutAmount", createConfirmPayoutBody.amount);globalState.set("payoutID", response.body.payout_id);for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}@@ -1441,15 +1498,12 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}@@ -1474,15 +1528,12 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}@@ -1525,7 +1576,7 @@ Cypress.Commands.add("createJWTToken", (req_data, res_data, globalState) => {logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {expect(response.body).to.have.property("token");//set jwt_tokenglobalState.set("jwtToken", response.body.token);@@ -1543,10 +1594,7 @@ Cypress.Commands.add("createJWTToken", (req_data, res_data, globalState) => {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});});@@ -1596,17 +1644,14 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {expect(response.body).to.have.property("id");globalState.set("routingConfigId", response.body.id);for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}@@ -1629,16 +1674,13 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {expect(response.body.id).to.equal(routing_config_id);for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}@@ -1661,16 +1703,13 @@ Cypress.Commands.add(logRequestId(response.headers["x-request-id"]);expect(response.headers["content-type"]).to.include("application/json");- if (res_data.status === 200) {+ if (response.status === 200) {expect(response.body.id).to.equal(routing_config_id);for (const key in res_data.body) {expect(res_data.body[key]).to.equal(response.body[key]);}} else {- expect(response.body).to.have.property("error");- for (const key in res_data.body.error) {- expect(res_data.body.error[key]).to.equal(response.body.error[key]);- }+ defaultErrorHandler(response, res_data);}});}