From c88ed0763921327f79d55ce3d2ffd95149386d5d Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Wed, 8 May 2024 18:00:45 +0530 Subject: [PATCH 01/14] feat: make response connector specific --- .../00004-ThreeDSAutoCapture.cy.js | 12 +++++--- .../cypress/e2e/ConnectorUtils/Stripe.js | 29 ++++++++++++++----- cypress-tests/cypress/support/commands.js | 21 ++++++++------ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js index 43cab5e189f4..6cfda3150b04 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js @@ -25,8 +25,10 @@ describe("Card - ThreeDS payment flow test", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); }); it("payment_methods-call-test", () => { @@ -35,9 +37,11 @@ describe("Card - ThreeDS payment flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; cy.task('cli_log', "GLOBAL STATE -> " + JSON.stringify(globalState.data)); - cy.confirmCallTest(confirmBody, det, true, globalState); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("Handle redirection", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 43c136a87d24..0a3d1e78ea49 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -18,15 +18,28 @@ const successfulThreeDSTestCardDetails = { }; export const connectorDetails = { + "PaymentIntent": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": "requires_payment_method" + } + }, "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session" + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": "succeeded" + } + }, "No3DS": { "card": successfulTestCardDetails, diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 3caed6e07716..8af9284c42af 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -133,14 +133,14 @@ Cypress.Commands.add("createCustomerCallTest", (customerCreateBody, globalState) }); }); -Cypress.Commands.add("createPaymentIntentTest", (request, det, authentication_type, capture_method, globalState) => { - if (!request || typeof request !== "object" || !det.currency || !authentication_type) { +Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, authentication_type, capture_method, globalState) => { + if (!request || typeof request !== "object" || !req_data.currency || !authentication_type) { throw new Error("Invalid parameters provided to createPaymentIntentTest command"); } - request.currency = det.currency; + request.currency = req_data.currency; request.authentication_type = authentication_type; request.capture_method = capture_method; - request.setup_future_usage = det.setup_future_usage; + request.setup_future_usage = req_data.setup_future_usage; request.customer_id = globalState.get("customerId"); globalState.set("paymentAmount", request.amount); cy.request({ @@ -161,7 +161,10 @@ Cypress.Commands.add("createPaymentIntentTest", (request, det, authentication_ty globalState.set("clientSecret", clientSecret); globalState.set("paymentID", response.body.payment_id); cy.log(clientSecret); - expect("requires_payment_method").to.equal(response.body.status); + for(const key in res_data) { + expect(res_data[key]).to.equal(response.body[key]); + } + expect(res_data.status).to.equal(response.body.status); expect(request.amount).to.equal(response.body.amount); expect(null).to.equal(response.body.amount_received); expect(request.amount).to.equal(response.body.amount_capturable); @@ -191,12 +194,12 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => { }); }); -Cypress.Commands.add("confirmCallTest", (confirmBody, details, confirm, globalState) => { +Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confirm, globalState) => { const paymentIntentID = globalState.get("paymentID"); - confirmBody.payment_method_data.card = details.card; + confirmBody.payment_method_data.card = req_data.card; confirmBody.confirm = confirm; confirmBody.client_secret = globalState.get("clientSecret"); - confirmBody.customer_acceptance = details.customer_acceptance; + confirmBody.customer_acceptance = req_data.customer_acceptance; cy.request({ method: "POST", @@ -217,7 +220,7 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, details, confirm, globalSt .to.have.property("redirect_to_url"); globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - expect(details.paymentSuccessfulStatus).to.equal(response.body.status); + expect(res_data.status).to.equal(response.body.status); } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); From f67d1de1e329c76029b576bb2976631e2901960a Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Thu, 9 May 2024 13:27:51 +0530 Subject: [PATCH 02/14] refactor: non-3ds flow with auto capture --- .../00003-NoThreeDSAutoCapture.cy.js | 18 ++++++++++------ .../cypress/e2e/ConnectorUtils/Stripe.js | 21 ++++++++++++------- cypress-tests/cypress/support/commands.js | 18 +++++++++------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js index 2f7e0ccaea27..0cd316de0398 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js @@ -24,8 +24,10 @@ describe("Card - NoThreeDS payment flow test", () => { context("Card-NoThreeDS payment flow test Create and confirm", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it("payment_methods-call-test", () => { @@ -33,8 +35,10 @@ describe("Card - NoThreeDS payment flow test", () => { }); it("Confirm No 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -47,8 +51,10 @@ describe("Card - NoThreeDS payment flow test", () => { it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it("retrieve-payment-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 0a3d1e78ea49..06ae4bcf30a0 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -42,14 +42,19 @@ export const connectorDetails = { }, "No3DS": { - "card": successfulTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session" + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": "succeeded" + } }, "MandateSingleUse3DS": { "card": successfulThreeDSTestCardDetails, diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 8af9284c42af..519dfe875152 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -220,7 +220,9 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir .to.have.property("redirect_to_url"); globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - expect(res_data.status).to.equal(response.body.status); + for(const key in res_data) { + expect(res_data[key]).to.equal(response.body[key]); + } } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); @@ -244,13 +246,13 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir }); }); -Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, details, authentication_type, capture_method, globalState) => { - createConfirmPaymentBody.payment_method_data.card = details.card; +Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_data, res_data, authentication_type, capture_method, globalState) => { + createConfirmPaymentBody.payment_method_data.card = req_data.card; createConfirmPaymentBody.authentication_type = authentication_type; - createConfirmPaymentBody.currency = details.currency; + createConfirmPaymentBody.currency = req_data.currency; createConfirmPaymentBody.capture_method = capture_method; - createConfirmPaymentBody.customer_acceptance = details.customer_acceptance; - createConfirmPaymentBody.setup_future_usage = details.setup_future_usage; + createConfirmPaymentBody.customer_acceptance = req_data.customer_acceptance; + createConfirmPaymentBody.setup_future_usage = req_data.setup_future_usage; createConfirmPaymentBody.customer_id = globalState.get("customerId"); cy.request({ @@ -275,7 +277,9 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, deta globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - expect(details.paymentSuccessfulStatus).to.equal(response.body.status); + for(const key in res_data) { + expect(res_data[key]).to.equal(response.body[key]); + } } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); From ad68c27c2694a90c67d2b5faa4471ad93c646a4c Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Thu, 9 May 2024 14:45:55 +0530 Subject: [PATCH 03/14] refactor: non 3ds with manual capture --- .../00005-NoThreeDSManualCapture.cy.js | 74 ++++++++++++------- .../cypress/e2e/ConnectorUtils/Stripe.js | 38 +++++++++- .../cypress/fixtures/create-confirm-body.json | 4 +- cypress-tests/cypress/support/commands.js | 20 +---- 4 files changed, 88 insertions(+), 48 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js index 095ab5381d04..c1bc4cd32a86 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js @@ -27,8 +27,10 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("payment Create and Confirm", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -37,9 +39,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -47,9 +51,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("retrieve-payment-call-test", () => { @@ -61,9 +67,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("Payment Create+Confirm", () => { it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("retrieve-payment-call-test", () => { @@ -71,9 +79,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 6540, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("retrieve-payment-call-test", () => { @@ -89,8 +99,10 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("payment Create and Payment Confirm", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -99,9 +111,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -109,8 +123,10 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - cy.captureCallTest(captureBody, 100, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); it("retrieve-payment-call-test", () => { @@ -121,9 +137,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("payment + Confirm", () => { it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("retrieve-payment-call-test", () => { @@ -131,9 +149,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 5000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); it("retrieve-payment-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 06ae4bcf30a0..77d3555d4201 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -20,7 +20,7 @@ const successfulThreeDSTestCardDetails = { export const connectorDetails = { "PaymentIntent": { "Request": { - "card": successfulThreeDSTestCardDetails, + "card": successfulTestCardDetails, "currency": "USD", "customer_acceptance": null, "setup_future_usage": "on_session" @@ -42,6 +42,17 @@ export const connectorDetails = { }, "No3DS": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": "succeeded" + } + }, + "Capture": { "Request": { "card": successfulTestCardDetails, "currency": "USD", @@ -53,7 +64,30 @@ export const connectorDetails = { "setup_future_usage": "on_session" }, "Response": { - "status": "succeeded" + "status": "succeeded", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 6500, + + } + }, + "PartialCapture": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": "partially_captured", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 100, + } }, "MandateSingleUse3DS": { diff --git a/cypress-tests/cypress/fixtures/create-confirm-body.json b/cypress-tests/cypress/fixtures/create-confirm-body.json index 1399f181342d..cf95e6f8c8fe 100644 --- a/cypress-tests/cypress/fixtures/create-confirm-body.json +++ b/cypress-tests/cypress/fixtures/create-confirm-body.json @@ -1,10 +1,10 @@ { - "amount": 6540, + "amount": 6500, "currency": "USD", "confirm": true, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", - "amount_to_capture": 6540, + "amount_to_capture": 6500, "customer_id": "john123", "email": "guest@example.com", "name": "John Doe", diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 519dfe875152..33ef9f7c7149 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -353,7 +353,7 @@ Cypress.Commands.add("saveCardConfirmCallTest", (confirmBody, det, globalState) }); }); -Cypress.Commands.add("captureCallTest", (requestBody, amount_to_capture, paymentSuccessfulStatus, globalState) => { +Cypress.Commands.add("captureCallTest", (requestBody, req_data, res_data, amount_to_capture, globalState) => { const payment_id = globalState.get("paymentID"); requestBody.amount_to_capture = amount_to_capture; let amount = globalState.get("paymentAmount"); @@ -370,22 +370,8 @@ Cypress.Commands.add("captureCallTest", (requestBody, amount_to_capture, payment expect(response.headers["content-type"]).to.include("application/json"); expect(response.body.payment_id).to.equal(payment_id); - if (amount_to_capture == amount && response.body.status == "succeeded") { - expect(response.body.amount).to.equal(amount_to_capture); - expect(response.body.amount_capturable).to.equal(0); - expect(response.body.amount_received).to.equal(amount); - expect(response.body.status).to.equal(paymentSuccessfulStatus); - } else if (response.body.status == "processing") { - expect(response.body.amount).to.equal(amount); - expect(response.body.amount_capturable).to.equal(amount); - expect(response.body.amount_received).to.equal(0); - expect(response.body.status).to.equal(paymentSuccessfulStatus); - } - else { - expect(response.body.amount).to.equal(amount); - expect(response.body.amount_capturable).to.equal(0); - expect(response.body.amount_received).to.equal(amount_to_capture); - expect(response.body.status).to.equal("partially_captured"); + for(const key in res_data) { + expect(res_data[key]).to.equal(response.body[key]); } }); }); From 6a8d4c7b1cf424c1487dee06ae2d88661dc3ff69 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Fri, 10 May 2024 17:49:51 +0530 Subject: [PATCH 04/14] feat: refactor flows for void, sync and refund --- .../e2e/ConnectorTest/00006-VoidPayment.cy.js | 34 ++- .../e2e/ConnectorTest/00007-SyncPayment.cy.js | 14 +- .../ConnectorTest/00008-RefundPayment.cy.js | 245 ++++++++++++------ .../cypress/e2e/ConnectorUtils/Stripe.js | 146 +++++++---- cypress-tests/cypress/support/commands.js | 48 ++-- 5 files changed, 318 insertions(+), 169 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js index 61a27763134b..d471dad31dcb 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js @@ -23,8 +23,10 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("Card - void payment in Requires_capture state flow test", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -33,9 +35,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("void-call-test", () => { @@ -45,8 +49,10 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("Card - void payment in Requires_payment_method state flow test", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -60,8 +66,10 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("Card - void payment in Requires_payment_method state flow test", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -70,9 +78,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, false, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, false, globalState); }); it("void-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js index efdeeb8da2d4..35ce792f636a 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js @@ -20,8 +20,10 @@ describe("Card - Sync payment flow test", () => { cy.task('setGlobalState', globalState.data); }) it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it("payment_methods-call-test", () => { @@ -30,9 +32,11 @@ describe("Card - Sync payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js index d45aa6dfec9b..c9d4473d4b78 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js @@ -29,8 +29,10 @@ describe("Card - Refund flow test", () => { context("Card - Full Refund flow test for No-3DS", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it("payment_methods-call-test", () => { @@ -39,9 +41,11 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -49,16 +53,20 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 6500, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); }); }); context("Card - Partial Refund flow test for No-3DS", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it("payment_methods-call-test", () => { @@ -67,23 +75,30 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { + console.log("in_retrieve_call"); cy.retrievePaymentCallTest(globalState); }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 1200, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 1200, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); }); }); @@ -91,8 +106,10 @@ describe("Card - Refund flow test", () => { it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); }); it("retrieve-payment-call-test", () => { @@ -100,8 +117,10 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 6540, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); }); }); @@ -110,8 +129,10 @@ describe("Card - Refund flow test", () => { it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); }); it("retrieve-payment-call-test", () => { @@ -119,18 +140,24 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 3000, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 3000, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); }); @@ -138,8 +165,10 @@ describe("Card - Refund flow test", () => { context("Card - Full Refund for fully captured No-3DS payment", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -148,9 +177,11 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -158,9 +189,11 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("retrieve-payment-call-test", () => { @@ -168,21 +201,27 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 6500, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); }); context("Card - Partial Refund for fully captured No-3DS payment", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -191,9 +230,11 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -201,9 +242,11 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("retrieve-payment-call-test", () => { @@ -211,17 +254,23 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 5000, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 500, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); it("list-refund-call-test", () => { cy.listRefundCallTest(listRefundCall, globalState); @@ -231,8 +280,10 @@ describe("Card - Refund flow test", () => { context("Card - Full Refund for partially captured No-3DS payment", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -241,9 +292,11 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -251,9 +304,11 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 4000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); it("retrieve-payment-call-test", () => { @@ -261,21 +316,27 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 4000, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); }); context("Card - partial Refund for partially captured No-3DS payment", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -284,9 +345,11 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -294,9 +357,11 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 4000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); it("retrieve-payment-call-test", () => { @@ -304,22 +369,28 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 3000, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); }); context("Card - Full Refund for Create + Confirm Automatic CIT and MIT payment flow test", () => { it("Confirm No 3DS CIT", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + req_data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { @@ -331,13 +402,17 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - cy.refundCallTest(refundBody, 7000, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 7000, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); }); diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index c92a3303a005..186e8616abe9 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -27,7 +27,10 @@ card_pm:{ "setup_future_usage": "on_session" }, "Response": { - "status": "requires_payment_method" + "status": 200, + "body": { + "status": "requires_payment_method" + } } }, "3DS": { @@ -38,9 +41,11 @@ card_pm:{ "setup_future_usage": "on_session" }, "Response": { - "status": "succeeded" + "status": 200, + "body": { + "status": "succeeded" + } } - }, "No3DS": { "Request": { @@ -50,26 +55,27 @@ card_pm:{ "setup_future_usage": "on_session" }, "Response": { - "status": "succeeded" + "status": 200, + "body": { + "status": "succeeded" + } } }, "Capture": { "Request": { "card": successfulTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "customer_acceptance": null, - "setup_future_usage": "on_session" }, "Response": { - "status": "succeeded", - "amount": 6500, - "amount_capturable": 0, - "amount_received": 6500, + "status": 200, + "body":{ + "status": "succeeded", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 6500, + } } }, "PartialCapture": { @@ -81,55 +87,99 @@ card_pm:{ "refundStatus": "succeeded", "refundSyncStatus": "succeeded", "customer_acceptance": null, - "setup_future_usage": "on_session" }, "Response": { - "status": "partially_captured", - "amount": 6500, - "amount_capturable": 0, - "amount_received": 100, + "status": 200, + "body": { + "status": "partially_captured", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 100, + } + + } + }, + "Refund": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + // "amount": 6500, + // "amount_capturable": 0, + // "amount_received": 100, + } } }, "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" } } + }, "MandateSingleUseNo3DS": { - "card": successfulTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } } }, "MandateMultiUseNo3DS": { - "card": successfulTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" } } }, diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 2652fd3d22d8..afcaebb47815 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -155,16 +155,16 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("client_secret"); const clientSecret = response.body.client_secret; globalState.set("clientSecret", clientSecret); globalState.set("paymentID", response.body.payment_id); cy.log(clientSecret); - for(const key in res_data) { - expect(res_data[key]).to.equal(response.body[key]); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); } - expect(res_data.status).to.equal(response.body.status); expect(request.amount).to.equal(response.body.amount); expect(null).to.equal(response.body.amount_received); expect(request.amount).to.equal(response.body.amount_capturable); @@ -212,6 +212,7 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", paymentIntentID); if (response.body.capture_method === "automatic") { @@ -220,8 +221,8 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir .to.have.property("redirect_to_url"); globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - for(const key in res_data) { - expect(res_data[key]).to.equal(response.body[key]); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); } } else { // Handle other authentication types as needed @@ -266,6 +267,7 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("status"); globalState.set("paymentAmount", createConfirmPaymentBody.amount); @@ -277,8 +279,8 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - for(const key in res_data) { - expect(res_data[key]).to.equal(response.body[key]); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); } } else { // Handle other authentication types as needed @@ -368,10 +370,11 @@ Cypress.Commands.add("captureCallTest", (requestBody, req_data, res_data, amount }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); expect(response.body.payment_id).to.equal(payment_id); - for(const key in res_data) { - expect(res_data[key]).to.equal(response.body[key]); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); } }); }); @@ -419,7 +422,7 @@ Cypress.Commands.add("retrievePaymentCallTest", (globalState) => { }); }); -Cypress.Commands.add("refundCallTest", (requestBody, refund_amount, det, globalState) => { +Cypress.Commands.add("refundCallTest", (requestBody, req_data, res_data, refund_amount, globalState) => { const payment_id = globalState.get("paymentID"); requestBody.payment_id = payment_id; requestBody.amount = refund_amount; @@ -434,15 +437,17 @@ Cypress.Commands.add("refundCallTest", (requestBody, refund_amount, det, globalS }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("refundId", response.body.refund_id); - expect(response.body.status).to.equal(det.refundStatus); - expect(response.body.amount).to.equal(refund_amount); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } expect(response.body.payment_id).to.equal(payment_id); }); }); -Cypress.Commands.add("syncRefundCallTest", (det, globalState) => { +Cypress.Commands.add("syncRefundCallTest", (req_data, res_data, globalState) => { const refundId = globalState.get("refundId"); cy.request({ method: "GET", @@ -454,19 +459,22 @@ Cypress.Commands.add("syncRefundCallTest", (det, globalState) => { }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - expect(response.body.status).to.equal(det.refundSyncStatus); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } }); }); -Cypress.Commands.add("citForMandatesCallTest", (requestBody, amount, details, confirm, capture_method, payment_type, globalState) => { - requestBody.payment_method_data.card = details.card; +Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, amount, confirm, capture_method, payment_type, globalState) => { + requestBody.payment_method_data.card = req_data.card; requestBody.payment_type = payment_type; requestBody.confirm = confirm; requestBody.amount = amount; - requestBody.currency = details.currency; + requestBody.currency = req_data.currency; requestBody.capture_method = capture_method; - requestBody.mandate_data.mandate_type = details.mandate_type; + requestBody.mandate_data.mandate_type = req_data.mandate_type; requestBody.customer_id = globalState.get("customerId"); globalState.set("paymentAmount", requestBody.amount); cy.request({ @@ -493,7 +501,9 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, amount, details, co cy.log(response.body); cy.log(nextActionUrl); } else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal(details.paymentSuccessfulStatus); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); From f2224e826bbc10e3ac361eb223fd444d0214a192 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Fri, 10 May 2024 18:05:02 +0530 Subject: [PATCH 05/14] refactor: flow for sync refund, single , multiple and revoke mandate --- .../e2e/ConnectorTest/00009-SyncRefund.cy.js | 26 ++++++--- .../00010-CreateSingleuseMandate.cy.js | 46 +++++++++------ .../00011-CreateMultiuseMandate.cy.js | 56 ++++++++++++------- .../00012-ListAndRevokeMandate.cy.js | 8 ++- 4 files changed, 86 insertions(+), 50 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js index 6bf9639da263..7700acfbad5e 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js @@ -22,8 +22,10 @@ describe("Card - Sync Refund flow test", () => { }) it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it("payment_methods-call-test", () => { @@ -32,9 +34,11 @@ describe("Card - Sync Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - console.log("det -> " + det.card); - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("retrieve-payment-call-test", () => { @@ -42,13 +46,17 @@ describe("Card - Sync Refund flow test", () => { }); it("refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.refundCallTest(refundBody, 6500, det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); }); it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; - cy.syncRefundCallTest(det, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); }); }); \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js index bd795d8a38b3..144755779b79 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js @@ -25,9 +25,11 @@ describe("Card - SingleUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { @@ -39,15 +41,19 @@ describe("Card - SingleUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "manual", "new_mandate", globalState); }); it("cit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 7000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); }); it("Confirm No 3DS MIT", () => { @@ -55,9 +61,11 @@ describe("Card - SingleUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 7000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); }); it("list-mandate-call-test", () => { @@ -69,15 +77,19 @@ describe("Card - SingleUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 6500, det, true, "automatic", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "automatic", "new_mandate", globalState); }); it("cit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("Confirm No 3DS MIT", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js index 474024a1bcb7..f027ef3e1fe5 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js @@ -26,9 +26,11 @@ describe("Card - MultiUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { @@ -43,15 +45,19 @@ describe("Card - MultiUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "manual", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "manual", "new_mandate", globalState); }); it("cit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 7000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); }); it("Confirm No 3DS MIT 1", () => { @@ -59,9 +65,11 @@ describe("Card - MultiUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 7000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); }); it("Confirm No 3DS MIT 2", () => { @@ -69,9 +77,11 @@ describe("Card - MultiUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 7000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); }); }); @@ -79,15 +89,19 @@ describe("Card - MultiUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 6500, det, true, "automatic", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "automatic", "new_mandate", globalState); }); it("cit-capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DS"]; - console.log("det -> " + det.card); - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("Confirm No 3DS MIT", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js index 8504f602cc5d..41604ef87082 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js @@ -25,9 +25,11 @@ describe("Card - SingleUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - console.log("det -> " + det.card); - cy.citForMandatesCallTest(citConfirmBody, 7000, det, true, "automatic", "new_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + console.log("det -> " + data.card); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); }); it("Confirm No 3DS MIT", () => { From d8951f446ad473a036fbfce1d588a1d70ab5d276 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Fri, 10 May 2024 18:38:06 +0530 Subject: [PATCH 06/14] refactor: flow for save card, manual capture and zero auth mandate --- .../ConnectorTest/00013-SaveCardFlow.cy.js | 66 ++++++++++++------- .../ConnectorTest/00014-ZeroAuthMandate.cy.js | 12 ++-- .../00015-ThreeDSManualCapture.cy.js | 60 +++++++++++------ .../cypress/e2e/ConnectorUtils/Stripe.js | 36 ++++++---- cypress-tests/cypress/support/commands.js | 8 ++- 5 files changed, 119 insertions(+), 63 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js index f3e240aa88ca..c152dfe739dd 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js @@ -25,8 +25,10 @@ describe("Card - SaveCard payment flow test", () => { }); it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); }); it("retrieve-payment-call-test", () => { @@ -38,13 +40,17 @@ describe("Card - SaveCard payment flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.createPaymentIntentTest( createPaymentBody, det, "no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); }); it ("confirm-save-card-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.saveCardConfirmCallTest(SaveCardConfirmBody,det,globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); }); }); @@ -55,8 +61,10 @@ describe("Card - SaveCard payment flow test", () => { }); it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); }); it("retrieve-payment-call-test", () => { @@ -68,19 +76,25 @@ describe("Card - SaveCard payment flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.createPaymentIntentTest( createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it ("confirm-save-card-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.saveCardConfirmCallTest(SaveCardConfirmBody,det,globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); @@ -90,8 +104,10 @@ describe("Card - SaveCard payment flow test", () => { }); it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, det,"no_three_ds", "automatic", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); }); it("retrieve-payment-call-test", () => { @@ -103,19 +119,25 @@ describe("Card - SaveCard payment flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.createPaymentIntentTest( createPaymentBody, det, "no_three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); }); it ("confirm-save-card-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.saveCardConfirmCallTest(SaveCardConfirmBody,det,globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.saveCardConfirmCallTest(SaveCardConfirmBody,req_data, res_data,globalState); }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - cy.captureCallTest(captureBody, 5500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); }); }); diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js index 23b9526f58b4..30b3a8881ec7 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js @@ -23,8 +23,10 @@ describe("Card - SingleUse Mandates flow test", () => { context("Card - NoThreeDS Create + Confirm Automatic CIT and Single use MIT payment flow test", () => { it("Confirm No 3DS CIT", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - cy.citForMandatesCallTest(citConfirmBody, 0, det, true, "automatic", "setup_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 0, true, "automatic", "setup_mandate", globalState); }); it("Confirm No 3DS MIT", () => { @@ -34,8 +36,10 @@ describe("Card - SingleUse Mandates flow test", () => { context("Card - NoThreeDS Create + Confirm Automatic CIT and Multi use MIT payment flow test", () => { it("Confirm No 3DS CIT", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; - cy.citForMandatesCallTest(citConfirmBody, 0, det, true, "automatic", "setup_mandate", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 0, true, "automatic", "setup_mandate", globalState); }); it("Confirm No 3DS MIT", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js index fb308c7fbec2..81dbf24c63fe 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js @@ -24,8 +24,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { context("Card - ThreeDS Manual Full Capture payment flow test", () => { context("payment Create and Confirm", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -33,8 +35,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("confirm-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("Handle redirection", () => { @@ -47,8 +51,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.captureCallTest(captureBody, 6500, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("retrieve-payment-call-test", () => { @@ -59,8 +65,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { context("Payment Create+Confirm", () => { it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "manual", globalState); }); it("Handle redirection", () => { @@ -74,8 +82,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.captureCallTest(captureBody, 6540, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); }); it("retrieve-payment-call-test", () => { @@ -89,8 +99,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { context("Card - ThreeDS Manual Partial Capture payment flow test - Create and Confirm", () => { context("payment Create and Payment Confirm", () => { it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.createPaymentIntentTest(createPaymentBody, det, "three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); }); it("payment_methods-call-test", () => { @@ -98,8 +110,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("confirm-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.confirmCallTest(confirmBody, det, true, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); }); it("Handle redirection", () => { @@ -112,8 +126,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.captureCallTest(captureBody, 100, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); it("retrieve-payment-call-test", () => { @@ -123,8 +139,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { context("payment + Confirm", () => { it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.createConfirmPaymentTest(createConfirmPaymentBody, det, "three_ds", "manual", globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "manual", globalState); }); it("Handle redirection", () => { @@ -137,8 +155,10 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.captureCallTest(captureBody, 5000, det.paymentSuccessfulStatus, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); }); it("retrieve-payment-call-test", () => { diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 186e8616abe9..0786b917e3e9 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -198,21 +198,29 @@ card_pm:{ } }, "SaveCardUseNo3DS": { - "card": successfulTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" - } + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } }, } }; \ No newline at end of file diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index afcaebb47815..a27aec6e5b91 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -304,9 +304,9 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ }); // This is consequent saved card payment confirm call test(Using payment token) -Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody,det,globalState) => { +Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, res_data,globalState) => { const paymentIntentID = globalState.get("paymentID"); - SaveCardConfirmBody.card_cvc = det.card_cvc; + SaveCardConfirmBody.card_cvc = req_data.card_cvc; SaveCardConfirmBody.payment_token = globalState.get("paymentToken"); SaveCardConfirmBody.client_secret = globalState.get("clientSecret"); console.log("conf conn ->" + globalState.get("connectorId")); @@ -330,7 +330,9 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody,det,globalS .to.have.property("redirect_to_url"); const nextActionUrl = response.body.next_action.redirect_to_url; } else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal(det.paymentSuccessfulStatus); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } expect(response.body.customer_id).to.equal(globalState.get("customerId")); } else { // Handle other authentication types as needed From 02ed37bfa3898e14a1d950f2e55dddaabb97f771 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Tue, 14 May 2024 16:47:28 +0530 Subject: [PATCH 07/14] feat: handle breaking of flow in failure cases --- .../00003-NoThreeDSAutoCapture.cy.js | 32 +- .../00004-ThreeDSAutoCapture.cy.js | 22 +- .../00005-NoThreeDSManualCapture.cy.js | 59 +- .../e2e/ConnectorTest/00006-VoidPayment.cy.js | 44 +- .../e2e/ConnectorTest/00007-SyncPayment.cy.js | 22 +- .../ConnectorTest/00008-RefundPayment.cy.js | 165 +++++- .../e2e/ConnectorTest/00009-SyncRefund.cy.js | 24 +- .../00010-CreateSingleuseMandate.cy.js | 56 +- .../00011-CreateMultiuseMandate.cy.js | 57 +- .../00012-ListAndRevokeMandate.cy.js | 21 +- .../ConnectorTest/00013-SaveCardFlow.cy.js | 212 ++++--- .../ConnectorTest/00014-ZeroAuthMandate.cy.js | 31 +- .../00015-ThreeDSManualCapture.cy.js | 61 +- .../cypress/e2e/ConnectorUtils/Stripe.js | 3 - .../cypress/e2e/ConnectorUtils/Trustpay.js | 520 +++++++++++++++--- .../cypress/fixtures/confirm-body.json | 3 +- .../fixtures/save-card-confirm-body.json | 27 +- cypress-tests/cypress/support/commands.js | 84 ++- 18 files changed, 1176 insertions(+), 267 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js index 21dd9783d8c4..93b8486e729e 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js @@ -22,12 +22,20 @@ describe("Card - NoThreeDS payment flow test", () => { }) context("Card-NoThreeDS payment flow test Create and confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -35,10 +43,11 @@ describe("Card - NoThreeDS payment flow test", () => { }); it("Confirm No 3DS", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -48,13 +57,21 @@ describe("Card - NoThreeDS payment flow test", () => { }); context("Card-NoThreeDS payment flow test Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -63,4 +80,13 @@ describe("Card - NoThreeDS payment flow test", () => { }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js index 4af0795cde87..a77918537fe0 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js @@ -6,6 +6,13 @@ import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; describe("Card - ThreeDS payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); before("seed global state", () => { @@ -29,6 +36,7 @@ describe("Card - ThreeDS payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -37,11 +45,12 @@ describe("Card - ThreeDS payment flow test", () => { }); it("Confirm 3DS", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.task('cli_log', "GLOBAL STATE -> " + JSON.stringify(globalState.data)); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Handle redirection", () => { @@ -49,4 +58,13 @@ describe("Card - ThreeDS payment flow test", () => { cy.handleRedirection(globalState, expected_redirection); }) -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js index f62a07e97515..0100a493b867 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js @@ -25,12 +25,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("Card - NoThreeDS Manual Full Capture payment flow test", () => { context("payment Create and Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -39,11 +47,12 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -56,6 +65,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -65,13 +75,22 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); context("Payment Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -84,6 +103,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -97,12 +117,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => { context("Card - NoThreeDS Manual Partial Capture payment flow test - Create and Confirm", () => { context("payment Create and Payment Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -111,11 +139,12 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -127,6 +156,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -135,13 +165,22 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); context("payment + Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -154,6 +193,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -164,4 +204,13 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } + } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js index d471dad31dcb..beb7bcbf0888 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js @@ -22,11 +22,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }) context("Card - void payment in Requires_capture state flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -35,11 +44,12 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("void-call-test", () => { @@ -48,11 +58,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); context("Card - void payment in Requires_payment_method state flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -65,11 +84,20 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); context("Card - void payment in Requires_payment_method state flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -78,15 +106,25 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, false, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("void-call-test", () => { cy.voidCallTest(voidBody, globalState); }); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } + } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js index 35ce792f636a..787e436d8291 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js @@ -6,6 +6,13 @@ import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; describe("Card - Sync payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); before("seed global state", () => { @@ -24,6 +31,7 @@ describe("Card - Sync payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -32,15 +40,25 @@ describe("Card - Sync payment flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { cy.retrievePaymentCallTest(globalState); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js index c9d4473d4b78..7837419a8414 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js @@ -27,12 +27,20 @@ describe("Card - Refund flow test", () => { }) context("Card - Full Refund flow test for No-3DS", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -41,14 +49,16 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); }); @@ -57,16 +67,25 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Card - Partial Refund flow test for No-3DS", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -75,41 +94,51 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { - console.log("in_retrieve_call"); cy.retrievePaymentCallTest(globalState); }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Fully Refund Card-NoThreeDS payment flow test Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -121,18 +150,27 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Partially Refund Card-NoThreeDS payment flow test Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create+confirm-payment-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -140,35 +178,45 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); - }); - + context("Card - Full Refund for fully captured No-3DS payment", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -177,11 +225,12 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -194,6 +243,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -201,10 +251,11 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -212,16 +263,25 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Card - Partial Refund for fully captured No-3DS payment", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -230,11 +290,12 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -247,6 +308,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -254,23 +316,26 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("list-refund-call-test", () => { cy.listRefundCallTest(listRefundCall, globalState); @@ -278,12 +343,20 @@ describe("Card - Refund flow test", () => { }); context("Card - Full Refund for partially captured No-3DS payment", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -292,11 +365,12 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -309,6 +383,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -316,10 +391,12 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); it("sync-refund-call-test", () => { @@ -327,16 +404,25 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Card - partial Refund for partially captured No-3DS payment", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -345,11 +431,12 @@ describe("Card - Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -362,6 +449,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -369,28 +457,38 @@ describe("Card - Refund flow test", () => { }); it("refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Card - Full Refund for Create + Confirm Automatic CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + req_data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -406,14 +504,25 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 7000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.syncRefundCallTest(req_data, res_data, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); }); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js index 7700acfbad5e..92bc66b0cb52 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js @@ -7,6 +7,13 @@ import getConnectorDetails from "../ConnectorUtils/utils"; let globalState; describe("Card - Sync Refund flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); before("seed global state", () => { @@ -26,6 +33,7 @@ describe("Card - Sync Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -34,11 +42,12 @@ describe("Card - Sync Refund flow test", () => { it("confirm-call-test", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["No3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -50,6 +59,7 @@ describe("Card - Sync Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -57,6 +67,16 @@ describe("Card - Sync Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js index 144755779b79..0663500134c6 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js @@ -22,14 +22,22 @@ describe("Card - SingleUse Mandates flow test", () => { }) context("Card - NoThreeDS Create + Confirm Automatic CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -38,22 +46,31 @@ describe("Card - SingleUse Mandates flow test", () => { }); context("Card - NoThreeDS Create + Confirm Manual CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "manual", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -61,11 +78,12 @@ describe("Card - SingleUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("list-mandate-call-test", () => { @@ -73,23 +91,32 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); - context.skip("Card - ThreeDS Create + Confirm Manual CIT and MIT payment flow test", () => { + context("Card - ThreeDS Create + Confirm Manual CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "automatic", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; - console.log("det -> " + det.card); + console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -100,4 +127,13 @@ describe("Card - SingleUse Mandates flow test", () => { cy.listMandateCallTest(globalState); }); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js index f027ef3e1fe5..16420aebee42 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js @@ -23,14 +23,22 @@ describe("Card - MultiUse Mandates flow test", () => { context("Card - NoThreeDS Create + Confirm Automatic CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -42,22 +50,31 @@ describe("Card - MultiUse Mandates flow test", () => { }); context("Card - NoThreeDS Create + Confirm Manual CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "manual", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT 1", () => { @@ -65,11 +82,12 @@ describe("Card - MultiUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT 2", () => { @@ -77,35 +95,54 @@ describe("Card - MultiUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); - context.skip("Card - ThreeDS Create + Confirm Manual CIT and MIT payment flow test", () => { + context("Card - ThreeDS Create + Confirm Manual CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "automatic", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { cy.mitForMandatesCallTest(mitConfirmBody, 7000, true, "automatic", globalState); }); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js index 41604ef87082..f9913b955877 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js @@ -22,14 +22,22 @@ describe("Card - SingleUse Mandates flow test", () => { }) context("Card - NoThreeDS Create + Confirm Automatic CIT and MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -49,4 +57,13 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js index c152dfe739dd..399e67c1d6f8 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js @@ -19,22 +19,78 @@ describe("Card - SaveCard payment flow test", () => { }) - context("Save card for NoThreeDS automatic capture payment- Create+Confirm", () => { + context("Save card for NoThreeDS automatic capture payment- Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + + it("customer-create-call-test", () => { + cy.createCustomerCallTest(customerCreateBody, globalState); + }); + + it("create+confirm-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DSAutoCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); + + it ("confirm-save-card-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DSAutoCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); + + }); + + context("Save card for NoThreeDS manual full capture payment- Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("customer-create-call-test", () => { cy.createCustomerCallTest(customerCreateBody, globalState); }); it("create+confirm-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { cy.retrievePaymentCallTest(globalState); }); - + it("retrieve-customerPM-call-test", () => { cy.listCustomerPMCallTest(globalState); }); @@ -43,103 +99,91 @@ describe("Card - SaveCard payment flow test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); + cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); + it ("confirm-save-card-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); - }); - - context("Save card for NoThreeDS manual full capture payment- Create+Confirm", () => { - it("customer-create-call-test", () => { - cy.createCustomerCallTest(customerCreateBody, globalState); - }); - - it("create+confirm-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + it("capture-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); - }); - - it("retrieve-customerPM-call-test", () => { - cy.listCustomerPMCallTest(globalState); - }); - - it("create-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - }); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); + }); - - it ("confirm-save-card-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); - }); - - it("capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - }); + context("Save card for NoThreeDS manual partial capture payment- Create + Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); - context("Save card for NoThreeDS manual partial capture payment- Create + Confirm", () => { - it("customer-create-call-test", () => { - cy.createCustomerCallTest(customerCreateBody, globalState); - }); - - it("create+confirm-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - }); - - it("retrieve-payment-call-test", () => { - cy.retrievePaymentCallTest(globalState); - }); - - it("retrieve-customerPM-call-test", () => { - cy.listCustomerPMCallTest(globalState); - }); + it("customer-create-call-test", () => { + cy.createCustomerCallTest(customerCreateBody, globalState); + }); - it("create-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - }); - + it("create+confirm-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DSAutoCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); - it ("confirm-save-card-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DS"]; + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); + + it("retrieve-customerPM-call-test", () => { + cy.listCustomerPMCallTest(globalState); + }); + + it("create-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); + + + it ("confirm-save-card-payment-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SaveCardUseNo3DSManualCapture"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.saveCardConfirmCallTest(SaveCardConfirmBody,req_data, res_data,globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); + + it("capture-call-test", () => { + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.saveCardConfirmCallTest(SaveCardConfirmBody,req_data, res_data,globalState); - }); - - it("capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; - let req_data = data["Request"]; - let res_data = data["Response"]; - cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - }); - }); + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); + }); }); -}) \ No newline at end of file + +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } +} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js index 30b3a8881ec7..63e4617a9960 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js @@ -21,12 +21,20 @@ describe("Card - SingleUse Mandates flow test", () => { }) context("Card - NoThreeDS Create + Confirm Automatic CIT and Single use MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["ZeroAuthMandate"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 0, true, "automatic", "setup_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -34,12 +42,20 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); context("Card - NoThreeDS Create + Confirm Automatic CIT and Multi use MIT payment flow test", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); it("Confirm No 3DS CIT", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["ZeroAuthMandate"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 0, true, "automatic", "setup_mandate", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -50,4 +66,13 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } + } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js index 81dbf24c63fe..7f7fed490ad0 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js @@ -23,11 +23,20 @@ describe("Card - ThreeDS Manual payment flow test", () => { context("Card - ThreeDS Manual Full Capture payment flow test", () => { context("payment Create and Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -35,10 +44,11 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("confirm-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Handle redirection", () => { @@ -55,6 +65,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -64,11 +75,20 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); context("Payment Create+Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create+confirm-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Handle redirection", () => { @@ -86,6 +106,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -98,11 +119,20 @@ describe("Card - ThreeDS Manual payment flow test", () => { context("Card - ThreeDS Manual Partial Capture payment flow test - Create and Confirm", () => { context("payment Create and Payment Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create-payment-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -110,10 +140,11 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); it("confirm-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Handle redirection", () => { @@ -130,6 +161,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -138,11 +170,20 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); context("payment + Confirm", () => { + let should_continue = true; // variable that will be used to skip tests if a previous test fails + + beforeEach(function () { + if(!should_continue) { + this.skip(); + } + }); + it("create+confirm-payment-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "manual", globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("Handle redirection", () => { @@ -159,6 +200,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -169,4 +211,13 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); -}); \ No newline at end of file +}); + +function should_continue_further(res_data) { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } + } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 0786b917e3e9..567451bc1047 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -109,9 +109,6 @@ card_pm:{ "status": 200, "body": { "status": "succeeded", - // "amount": 6500, - // "amount_capturable": 0, - // "amount_received": 100, } } diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js b/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js index 71d0348c5eec..dce341f40ddf 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js @@ -16,98 +16,438 @@ const successfulThreeDSTestCardDetails = { export const connectorDetails = { card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "manual is not supported by trustpay" + } + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "manual is not supported by trustpay" + } + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "This Payment could not be captured because it has a payment.status of requires_payment_method. The expected state is requires_capture, partially_captured_and_capturable, processing", + "code": "IR_14", + } + } + } + }, + "PartialCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "customer_acceptance": null, + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "This Payment could not be captured because it has a payment.status of requires_payment_method. The expected state is requires_capture, partially_captured_and_capturable, processing", + "code": "IR_14", + } + } + } + }, + "Refund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "PartialRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "error_code": "1", + "error_message": "transaction declined (invalid amount)", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + + }, + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + }, + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 501, + "body": { + "error": { + "type": "invalid_request", + "message": "Setup Mandate flow for Trustpay is not implemented", + "code": "IR_00", + } } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + } + } + } }, } } \ No newline at end of file diff --git a/cypress-tests/cypress/fixtures/confirm-body.json b/cypress-tests/cypress/fixtures/confirm-body.json index 526d55e3fa84..32b9a7108be7 100644 --- a/cypress-tests/cypress/fixtures/confirm-body.json +++ b/cypress-tests/cypress/fixtures/confirm-body.json @@ -47,6 +47,7 @@ "screen_width": 1728, "time_zone": -330, "java_enabled": true, - "java_script_enabled": true + "java_script_enabled": true, + "ip_address": "127.0.0.1" } } diff --git a/cypress-tests/cypress/fixtures/save-card-confirm-body.json b/cypress-tests/cypress/fixtures/save-card-confirm-body.json index 676e91871ff3..6c3867449a20 100644 --- a/cypress-tests/cypress/fixtures/save-card-confirm-body.json +++ b/cypress-tests/cypress/fixtures/save-card-confirm-body.json @@ -2,5 +2,30 @@ "client_secret": "{{client_secret}}", "payment_method": "card", "payment_token": "{{payment_token}}", - "card_cvc": "card_cvc" + "card_cvc": "card_cvc", + "billing": { + "address": { + "state": "New York", + "city": "New York", + "country": "US", + "first_name": "john", + "last_name": "doe", + "zip": "10001", + "line1": "123 Main Street Apt 4B", + "line2": "123 Main Street Apt 4B", + "line3": "123 Main Street Apt 4B" + } + }, + "browser_info": { + "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, + "ip_address": "127.0.0.1" + } } diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index a27aec6e5b91..1cbd90147a96 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -141,6 +141,7 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au request.authentication_type = authentication_type; request.capture_method = capture_method; request.setup_future_usage = req_data.setup_future_usage; + request.customer_acceptance = req_data.customer_acceptance; request.customer_id = globalState.get("customerId"); globalState.set("paymentAmount", request.amount); cy.request({ @@ -151,6 +152,7 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au Accept: "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: request, }).then((response) => { logRequestId(response.headers['x-request-id']); @@ -208,6 +210,7 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir "Content-Type": "application/json", "api-key": globalState.get("publishableKey"), }, + failOnStatusCode: false, body: confirmBody, }).then((response) => { logRequestId(response.headers['x-request-id']); @@ -242,7 +245,10 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir } } else { - throw new Error(`Unsupported capture method: ${capture_method}`); + 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]); + } } }); }); @@ -263,16 +269,18 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: createConfirmPaymentBody, }).then((response) => { logRequestId(response.headers['x-request-id']); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - expect(response.body).to.have.property("status"); - globalState.set("paymentAmount", createConfirmPaymentBody.amount); - globalState.set("paymentID", response.body.payment_id); + if (response.body.capture_method === "automatic") { + expect(response.body).to.have.property("status"); + globalState.set("paymentAmount", createConfirmPaymentBody.amount); + globalState.set("paymentID", response.body.payment_id); if (response.body.authentication_type === "three_ds") { expect(response.body).to.have.property("next_action") .to.have.property("redirect_to_url") @@ -288,6 +296,9 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ } } else if (response.body.capture_method === "manual") { + expect(response.body).to.have.property("status"); + globalState.set("paymentAmount", createConfirmPaymentBody.amount); + globalState.set("paymentID", response.body.payment_id); if (response.body.authentication_type === "three_ds") { expect(response.body).to.have.property("next_action") .to.have.property("redirect_to_url") @@ -300,6 +311,12 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ throw new Error(`Unsupported authentication type: ${authentication_type}`); } } + 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]); + } + } }); }); @@ -317,11 +334,15 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, "Content-Type": "application/json", "api-key": globalState.get("publishableKey"), }, + failOnStatusCode: false, body: SaveCardConfirmBody, }) .then((response) => { logRequestId(response.headers['x-request-id']); + // console.log(`res_here ${response.body.error.message}`) + + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", paymentIntentID); if (response.body.capture_method === "automatic") { @@ -352,7 +373,10 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, } } else { - throw new Error(`Unsupported capture method: ${capture_method}`); + 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]); + } } }); }); @@ -368,16 +392,26 @@ Cypress.Commands.add("captureCallTest", (requestBody, req_data, res_data, amount "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - expect(response.body.payment_id).to.equal(payment_id); - for(const key in res_data.body) { - expect(res_data.body[key]).to.equal(response.body[key]); + if(response.body.capture_method !== undefined) { + expect(response.body.payment_id).to.equal(payment_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]); + } + } + }); }); @@ -390,6 +424,7 @@ Cypress.Commands.add("voidCallTest", (requestBody, globalState) => { "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); @@ -413,6 +448,7 @@ Cypress.Commands.add("retrievePaymentCallTest", (globalState) => { "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, }).then((response) => { logRequestId(response.headers['x-request-id']); @@ -435,17 +471,28 @@ Cypress.Commands.add("refundCallTest", (requestBody, req_data, res_data, refund_ "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: requestBody }).then((response) => { logRequestId(response.headers['x-request-id']); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - globalState.set("refundId", response.body.refund_id); - for(const key in res_data.body) { - expect(res_data.body[key]).to.equal(response.body[key]); + + if(response.body.status !== undefined) { + globalState.set("refundId", response.body.refund_id); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } + expect(response.body.payment_id).to.equal(payment_id); } - expect(response.body.payment_id).to.equal(payment_id); + 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]); + } + } + }); }); @@ -458,6 +505,7 @@ Cypress.Commands.add("syncRefundCallTest", (req_data, res_data, globalState) => "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, }).then((response) => { logRequestId(response.headers['x-request-id']); @@ -486,16 +534,18 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - expect(response.body).to.have.property("mandate_id"); globalState.set("mandateId", response.body.mandate_id); globalState.set("paymentID", response.body.payment_id); if (response.body.capture_method === "automatic") { + expect(response.body).to.have.property("mandate_id"); if (response.body.authentication_type === "three_ds") { expect(response.body).to.have.property("next_action") .to.have.property("redirect_to_url"); @@ -512,6 +562,7 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, } } else if (response.body.capture_method === "manual") { + expect(response.body).to.have.property("mandate_id"); if (response.body.authentication_type === "three_ds") { expect(response.body).to.have.property("next_action") } @@ -521,6 +572,12 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, throw new Error(`Unsupported authentication type: ${authentication_type}`); } } + 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]); + } + } }); }); @@ -540,6 +597,7 @@ Cypress.Commands.add("mitForMandatesCallTest", (requestBody, amount, confirm, ca "Content-Type": "application/json", "api-key": globalState.get("apiKey"), }, + failOnStatusCode: false, body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); From 53dd322d84c5d743759a442aabdad73483a739e1 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Tue, 14 May 2024 19:33:10 +0530 Subject: [PATCH 08/14] refactor: flows for mandates --- .../00010-CreateSingleuseMandate.cy.js | 18 +- .../00011-CreateMultiuseMandate.cy.js | 24 +- .../cypress/e2e/ConnectorUtils/Stripe.js | 220 ++++++++++++++++-- cypress-tests/cypress/support/commands.js | 12 +- 4 files changed, 229 insertions(+), 45 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js index 0663500134c6..26c0f75db32f 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js @@ -60,29 +60,29 @@ describe("Card - SingleUse Mandates flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "manual", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); if(should_continue) should_continue = should_continue_further(res_data); }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { - cy.mitForMandatesCallTest(mitConfirmBody, 7000, true, "manual", globalState); + cy.mitForMandatesCallTest(mitConfirmBody, 6500, true, "manual", globalState); }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); @@ -100,9 +100,9 @@ describe("Card - SingleUse Mandates flow test", () => { } }); - it("Confirm No 3DS CIT", () => { + it("Create No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -111,7 +111,7 @@ describe("Card - SingleUse Mandates flow test", () => { }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUse3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js index 16420aebee42..419a8f500868 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js @@ -64,42 +64,42 @@ describe("Card - MultiUse Mandates flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "manual", "new_mandate", globalState); + cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); if(should_continue) should_continue = should_continue_further(res_data); }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT 1", () => { - cy.mitForMandatesCallTest(mitConfirmBody, 7000, true, "manual", globalState); + cy.mitForMandatesCallTest(mitConfirmBody, 6500, true, "manual", globalState); }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); it("Confirm No 3DS MIT 2", () => { - cy.mitForMandatesCallTest(mitConfirmBody, 7000, true, "manual", globalState); + cy.mitForMandatesCallTest(mitConfirmBody, 6500, true, "manual", globalState); }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); - cy.captureCallTest(captureBody, req_data, res_data, 7000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); }); @@ -115,7 +115,7 @@ describe("Card - MultiUse Mandates flow test", () => { it("Confirm No 3DS CIT", () => { console.log("confirm -> " + globalState.get("connectorId")); - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUseNo3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -124,7 +124,7 @@ describe("Card - MultiUse Mandates flow test", () => { }); it("cit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateMultiUse3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -133,7 +133,7 @@ describe("Card - MultiUse Mandates flow test", () => { }); it("Confirm No 3DS MIT", () => { - cy.mitForMandatesCallTest(mitConfirmBody, 7000, true, "automatic", globalState); + cy.mitForMandatesCallTest(mitConfirmBody, 6500, true, "automatic", globalState); }); }); }); diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 567451bc1047..435428b26750 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -33,7 +33,7 @@ card_pm:{ } } }, - "3DS": { + "3DSManualCapture": { "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", @@ -47,7 +47,35 @@ card_pm:{ } } }, - "No3DS": { + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSAutoCapture": { "Request": { "card": successfulTestCardDetails, "currency": "USD", @@ -113,7 +141,21 @@ card_pm:{ } }, - "MandateSingleUse3DS": { + "PartialRefund": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", @@ -136,7 +178,30 @@ card_pm:{ } }, - "MandateSingleUseNo3DS": { + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_capture", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_customer_action" + } + } + + }, + "MandateSingleUseNo3DSAutoCapture": { "Request": { "card": successfulTestCardDetails, "currency": "USD", @@ -158,7 +223,29 @@ card_pm:{ } } }, - "MandateMultiUseNo3DS": { + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { "Request": { "card": successfulTestCardDetails, "currency": "USD", @@ -180,21 +267,120 @@ card_pm:{ } } }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "requires_customer_action", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulTestCardDetails, + "currency": "USD", + "paymentSuccessfulStatus": "succeeded", + "paymentSyncStatus": "succeeded", + "refundStatus": "succeeded", + "refundSyncStatus": "succeeded", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" } } }, - "SaveCardUseNo3DS": { + "SaveCardUseNo3DSManualCapture": { "Request": { "card": successfulTestCardDetails, "currency": "USD", diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index cdda963d5a6c..fbcd50b1870f 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -558,9 +558,9 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, for(const key in res_data.body) { expect(res_data.body[key]).to.equal(response.body[key]); } - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); + } + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); } } else if (response.body.capture_method === "manual") { @@ -568,10 +568,8 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, if (response.body.authentication_type === "three_ds") { expect(response.body).to.have.property("next_action") } - else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal("requires_capture"); - } else { - throw new Error(`Unsupported authentication type: ${authentication_type}`); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); } } else{ From f4e21faf964f41d732431a1ac2d5c3ad234c3a42 Mon Sep 17 00:00:00 2001 From: gnanasundarig Date: Mon, 20 May 2024 00:29:33 +0530 Subject: [PATCH 09/14] Handling 2xx 4xx for all connectors --- .../e2e/ConnectorTest/00006-VoidPayment.cy.js | 20 +- .../ConnectorTest/00008-RefundPayment.cy.js | 78 ++- .../e2e/ConnectorTest/00009-SyncRefund.cy.js | 2 +- .../00010-CreateSingleuseMandate.cy.js | 2 +- .../ConnectorTest/00013-SaveCardFlow.cy.js | 7 + .../cypress/e2e/ConnectorUtils/Adyen.js | 448 ++++++++++++---- .../e2e/ConnectorUtils/BankOfAmerica.js | 461 ++++++++++++---- .../cypress/e2e/ConnectorUtils/Bluesnap.js | 504 +++++++++++++---- .../cypress/e2e/ConnectorUtils/Cybersource.js | 460 ++++++++++++---- .../cypress/e2e/ConnectorUtils/Nmi.js | 507 ++++++++++++++---- .../cypress/e2e/ConnectorUtils/Paypal.js | 466 +++++++++++++--- .../cypress/e2e/ConnectorUtils/Stripe.js | 111 ++-- .../cypress/e2e/ConnectorUtils/Trustpay.js | 69 +-- cypress-tests/cypress/support/commands.js | 51 +- cypress-tests/readme.md | 2 +- 15 files changed, 2461 insertions(+), 727 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js index beb7bcbf0888..96c7d50b3e04 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js @@ -53,7 +53,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("void-call-test", () => { - cy.voidCallTest(voidBody, globalState); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Void"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.voidCallTest(voidBody, req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); @@ -79,8 +83,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("void-call-test", () => { - cy.voidCallTest(voidBody, globalState); - }); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Void"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.voidCallTest(voidBody, req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); context("Card - void payment in Requires_payment_method state flow test", () => { @@ -115,8 +122,11 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); it("void-call-test", () => { - cy.voidCallTest(voidBody, globalState); - }); + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Void"]; + let req_data = data["Request"]; + let res_data = data["Response"]; + cy.voidCallTest(voidBody, req_data, res_data, globalState); + if(should_continue) should_continue = should_continue_further(res_data); }); }); }); diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js index 64b626d16664..ed7f6bfe3f97 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js @@ -194,7 +194,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -259,7 +259,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -331,7 +331,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -400,7 +400,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -465,7 +465,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -508,7 +508,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -529,7 +529,7 @@ describe("Card - Refund flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); @@ -542,7 +542,7 @@ describe("Card - Refund flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -579,7 +579,7 @@ describe("Card - Refund flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); @@ -591,7 +591,7 @@ describe("Card - Refund flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -636,10 +636,10 @@ describe("Card - Refund flow test", () => { }); it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.createConfirmPaymentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); if(should_continue) should_continue = should_continue_further(res_data); }); @@ -656,7 +656,7 @@ describe("Card - Refund flow test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.refundCallTest(refundBody, req_data, res_data, 6540, globalState); + cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); @@ -673,10 +673,10 @@ describe("Card - Refund flow test", () => { }); it("create+confirm-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSAutoCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.createConfirmPaymentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); + cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); if(should_continue) should_continue = should_continue_further(res_data); }); @@ -706,7 +706,7 @@ describe("Card - Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); @@ -726,7 +726,7 @@ describe("Card - Refund flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); @@ -738,7 +738,7 @@ describe("Card - Refund flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -757,7 +757,7 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["capture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); @@ -790,7 +790,7 @@ describe("Card - Refund flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); @@ -802,7 +802,7 @@ describe("Card - Refund flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -821,7 +821,7 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["capture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); @@ -848,10 +848,6 @@ describe("Card - Refund flow test", () => { if(should_continue) should_continue = should_continue_further(res_data); }); - it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.syncRefundCallTest(det, globalState); - }); }); @@ -866,7 +862,7 @@ describe("Card - Refund flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); @@ -878,7 +874,7 @@ describe("Card - Refund flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -897,10 +893,10 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["capture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.captureCallTest(captureBody, req_data, res_data, 4000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); @@ -913,14 +909,11 @@ describe("Card - Refund flow test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.refundCallTest(refundBody, req_data, res_data, 4000, globalState); + cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); - it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DS"]; - cy.syncRefundCallTest(det, globalState); - }); + }); context("Card - partial Refund for partially captured 3DS payment", () => { @@ -934,7 +927,7 @@ describe("Card - Refund flow test", () => { }); it("create-payment-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PaymentIntent"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); @@ -946,7 +939,7 @@ describe("Card - Refund flow test", () => { }); it("Confirm 3DS", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["3DSManualCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); @@ -965,10 +958,10 @@ describe("Card - Refund flow test", () => { }); it("capture-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["capture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.captureCallTest(captureBody, req_data, res_data, 4000, globalState); + cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); @@ -981,14 +974,9 @@ describe("Card - Refund flow test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; let req_data = data["Request"]; let res_data = data["Response"]; - cy.refundCallTest(refundBody, req_data, res_data, 2000, globalState); + cy.refundCallTest(refundBody, req_data, res_data, 50 , globalState); if(should_continue) should_continue = should_continue_further(res_data); }); - - it("sync-refund-call-test", () => { - let det = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; - cy.syncRefundCallTest(det, globalState); - }); }); function should_continue_further(res_data) { diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js index 92bc66b0cb52..79d7f514a53a 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js @@ -63,7 +63,7 @@ describe("Card - Sync Refund flow test", () => { }); it("sync-refund-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["SyncRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js index 26c0f75db32f..de150e2c2860 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js @@ -78,7 +78,7 @@ describe("Card - SingleUse Mandates flow test", () => { }); it("mit-capture-call-test", () => { - let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["MandateSingleUseNo3DSAutoCapture"]; + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; let req_data = data["Request"]; let res_data = data["Response"]; console.log("det -> " + data.card); diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js index 399e67c1d6f8..c40a1e71b8d4 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js @@ -111,6 +111,10 @@ describe("Card - SaveCard payment flow test", () => { cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); if(should_continue) should_continue = should_continue_further(res_data); }); + + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); it("capture-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Capture"]; @@ -166,6 +170,9 @@ describe("Card - SaveCard payment flow test", () => { cy.saveCardConfirmCallTest(SaveCardConfirmBody,req_data, res_data,globalState); if(should_continue) should_continue = should_continue_further(res_data); }); + it("retrieve-payment-call-test", () => { + cy.retrievePaymentCallTest(globalState); + }); it("capture-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialCapture"]; diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js b/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js index 94ffe3009f68..1bbbbbd4b5b5 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Adyen.js @@ -17,98 +17,366 @@ const successfulThreeDSTestCardDetails = { export const connectorDetails = { card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "processing", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "processing", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body":{ + "status": "processing", + "amount": 6500, + "amount_capturable": 6500, + "amount_received": 0, + + } + } + }, + + "PartialCapture": { + "Request": { + }, + "Response": { + "status": 200, + "body": { + "status": "processing", + "amount": 6500, + "amount_capturable": 6500, + "amount_received": 0, + } + + } + }, + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "processing" + + } + } + }, + "Refund": { + "Request": { + + "currency": "USD", + + }, + "Response": { + "status": 400, + "body": { + "status": "pending", } + + } + }, + "PartialRefund": { + "Request": { + + "currency": "USD", + + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "SyncRefund": { + "Request": { + + "currency": "USD", + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + + }, + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_customer_action" + } + } + + }, + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } }, } }; \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js index 92b5f50981ac..5b3df0efc5d8 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/BankOfAmerica.js @@ -14,101 +14,368 @@ const successfulThreeDSTestCardDetails = { "card_holder_name": "joseph Doe", "card_cvc": "123" }; - export const connectorDetails = { -card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" - } - }, - }, -} -}; \ No newline at end of file + card_pm:{ + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body":{ + "status": "succeeded", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 6500, + + } + } + }, + "PartialCapture": { + "Request": { + + }, + "Response": { + "status": 200, + "body": { + "status": "partially_captured", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 100, + } + + } + }, + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "cancelled" + + } + } + }, + "Refund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "PartialRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + + }, + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_customer_action" + } + } + + }, + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + } + }; diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js b/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js index 523e6003ae5d..17e040668adc 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Bluesnap.js @@ -15,99 +15,411 @@ const successfulThreeDSTestCardDetails = { }; export const connectorDetails = { -card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" - } - }, - }, - } -}; \ No newline at end of file + card_pm:{ + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body":{ + "status": "succeeded", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 6500, + + } + } + }, + "PartialCapture": { + "Request": { + + }, + "Response": { + "status": 200, + "body": { + "status": "partially_captured", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 100, + } + + } + }, + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "cancelled" + + } + } + }, + "Refund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "PartialRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + + }, + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + + }, + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by bluesnap" + } + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 501, + "body": { + "error": { + "type": "invalid_request", + "message": "Setup Mandate flow for Bluesnap is not implemented", + "code": "IR_00", + } + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + } + }; \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js b/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js index c200adf64c53..67d2875df5c8 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Cybersource.js @@ -15,99 +15,367 @@ const successfulThreeDSTestCardDetails = { }; export const connectorDetails = { -card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "pending", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" - } - }, - }, - } -}; \ No newline at end of file + card_pm:{ + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body":{ + "status": "succeeded", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 6500, + + } + } + }, + "PartialCapture": { + "Request": { + + }, + "Response": { + "status": 200, + "body": { + "status": "partially_captured", + "amount": 6500, + "amount_capturable": 0, + "amount_received": 100, + } + + } + }, + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "cancelled" + + } + } + }, + "Refund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "PartialRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + + }, + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_customer_action" + } + } + + }, + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + } + }; \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js b/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js index 55d25a8ecf9d..27caaa82dc83 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Nmi.js @@ -15,100 +15,413 @@ const successfulThreeDSTestCardDetails = { }; export const connectorDetails = { -card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session", - - }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "processing", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, - "setup_future_usage": "on_session", - }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "processing", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "processing", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "processing", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" - } - } - }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "processing", - "paymentSyncStatus": "succeeded", - "refundStatus": "pending", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" - } - }, - }, - } -}; \ No newline at end of file + card_pm:{ + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body":{ + "status": "processing", + "amount": 6500, + "amount_capturable": 6500, + + } + } + }, + "PartialCapture": { + "Request": { + + }, + "Response": { + "status": 200, + "body": { + "status": "processing", + "amount": 6500, + "amount_capturable": 6500, + } + + } + }, + "Void":{ + "Request": { + }, + "Response": { + "status": 400, + "body":{ + "error":{ + "code":"IR_16", + "message":"You cannot cancel this payment because it has status processing", + "type":"invalid_request", + } + + } + } + }, + "Refund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "PartialRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "pending", + } + + } + }, + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + + }, + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + + }, + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by nmi" + } + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 501, + "body": { + "error": { + "type": "invalid_request", + "message": "Setup Mandate flow for Nmi is not implemented", + "code": "IR_00", + } + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + } + }; \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js b/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js index b0e876a71278..056b4b5e8ac3 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Paypal.js @@ -17,90 +17,424 @@ const successfulThreeDSTestCardDetails = { export const connectorDetails = { card_pm:{ - "3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "processing", - "customer_acceptance":null, - "setup_future_usage": "on_session", + "PaymentIntent": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_payment_method" + } + } + }, + "3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "No3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + "No3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + "setup_future_usage": "on_session" + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "Capture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body":{ + "status": "processing", + "amount": 6500, + "amount_capturable": 6500, + "amount_received": 0, + } + } }, - "No3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "processing", - "paymentSyncStatus": "processing", - "customer_acceptance":null, - "setup_future_usage": "on_session", + "PartialCapture": { + "Request": { + + }, + "Response": { + "status": 200, + "body": { + "status": "processing", + "amount": 6500, + "amount_capturable": 6500, + "amount_received": 0, + } + } }, - "MandateSingleUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "processing", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "cancelled" + + } + } + }, + "Refund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + "code" : "IR_14" + }, } + } }, - "MandateSingleUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "mandate_type": { - "single_use": { - "amount": 8000, - "currency": "USD" + "PartialRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + "code" : "IR_14" + }, } + } }, - "MandateMultiUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 400, + "body": { + "error": { + "type": "invalid_request", + "message": "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + "code" : "IR_14" + }, } + } }, - "MandateMultiUse3DS": { - "card": successfulThreeDSTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "processing", - "mandate_type": { - "multi_use": { - "amount": 8000, - "currency": "USD" + "MandateSingleUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } } } + }, - "SaveCardUseNo3DS": { - "card": successfulNo3DSCardDetails, - "currency":"USD", - "paymentSuccessfulStatus": "processing", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "setup_future_usage": "on_session", - "customer_acceptance": { - "acceptance_type": "offline", - "accepted_at": "1963-05-03T04:07:52.723Z", - "online": { - "ip_address": "127.0.0.1", - "user_agent": "amet irure esse" + "MandateSingleUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } } }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, - }, -}; + "MandateSingleUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, + "MandateSingleUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, + "MandateMultiUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, + "MandateMultiUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, + "MandateMultiUse3DSAutoCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, + "MandateMultiUse3DSManualCapture": { + "Request": { + "card": successfulThreeDSTestCardDetails, + "currency": "USD", + "mandate_type": { + "multi_use": { + "amount": 8000, + "currency": "USD" + } + }, + }, + "Response": { + "status": 400, + "body":{ + "error": { + "type": "invalid_request", + "message": "Payment method type not supported", + "code": "HE_03", + "reason": "debit mandate payment is not supported by paypal" + } + } + } + }, + "ZeroAuthMandate": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "mandate_type": { + "single_use": { + "amount": 8000, + "currency": "USD" + } + } + }, + "Response": { + "status": 501, + "body": { + "error": { + "type": "invalid_request", + "message": "Setup Mandate flow for Paypal is not implemented", + "code": "IR_00", + } + } + } + }, + "SaveCardUseNo3DSAutoCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "processing" + } + } + }, + "SaveCardUseNo3DSManualCapture": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "setup_future_usage": "on_session", + "customer_acceptance": { + "acceptance_type": "offline", + "accepted_at": "1963-05-03T04:07:52.723Z", + "online": { + "ip_address": "127.0.0.1", + "user_agent": "amet irure esse" + } + }, + }, + "Response": { + "status": 200, + "body": { + "status": "requires_capture" + } + } + }, + } + }; diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js index 435428b26750..1003946dd736 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Stripe.js @@ -1,7 +1,7 @@ const successfulTestCard = "4242424242424242"; const successful3DSCard = "4000002760003184"; -const successfulTestCardDetails = { +const successfulNo3DSCardDetails = { "card_number": "4242424242424242", "card_exp_month": "10", "card_exp_year": "25", @@ -21,7 +21,7 @@ export const connectorDetails = { card_pm:{ "PaymentIntent": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", "customer_acceptance": null, "setup_future_usage": "on_session" @@ -43,7 +43,7 @@ card_pm:{ "Response": { "status": 200, "body": { - "status": "succeeded" + "status": "requires_capture" } } }, @@ -63,7 +63,7 @@ card_pm:{ }, "No3DSManualCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", "customer_acceptance": null, "setup_future_usage": "on_session" @@ -71,13 +71,13 @@ card_pm:{ "Response": { "status": 200, "body": { - "status": "succeeded" + "status": "requires_capture" } } }, "No3DSAutoCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", "customer_acceptance": null, "setup_future_usage": "on_session" @@ -91,7 +91,7 @@ card_pm:{ }, "Capture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", "customer_acceptance": null, }, @@ -108,13 +108,7 @@ card_pm:{ }, "PartialCapture": { "Request": { - "card": successfulTestCardDetails, - "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", - "customer_acceptance": null, + }, "Response": { "status": 200, @@ -127,9 +121,20 @@ card_pm:{ } }, + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "cancelled" + + } + } + }, "Refund": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", "customer_acceptance": null, }, @@ -143,7 +148,21 @@ card_pm:{ }, "PartialRefund": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, "currency": "USD", "customer_acceptance": null, }, @@ -159,10 +178,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -182,10 +197,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_capture", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -203,12 +214,8 @@ card_pm:{ }, "MandateSingleUseNo3DSAutoCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -225,12 +232,8 @@ card_pm:{ }, "MandateSingleUseNo3DSManualCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -247,12 +250,8 @@ card_pm:{ }, "MandateMultiUseNo3DSAutoCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -269,12 +268,8 @@ card_pm:{ }, "MandateMultiUseNo3DSManualCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -293,10 +288,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -315,10 +306,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -335,12 +322,8 @@ card_pm:{ }, "ZeroAuthMandate": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -357,12 +340,8 @@ card_pm:{ }, "SaveCardUseNo3DSAutoCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "setup_future_usage": "on_session", "customer_acceptance": { "acceptance_type": "offline", @@ -382,12 +361,8 @@ card_pm:{ }, "SaveCardUseNo3DSManualCapture": { "Request": { - "card": successfulTestCardDetails, + "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "setup_future_usage": "on_session", "customer_acceptance": { "acceptance_type": "offline", @@ -401,7 +376,7 @@ card_pm:{ "Response": { "status": 200, "body": { - "status": "succeeded" + "status": "requires_capture" } } }, diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js b/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js index dce341f40ddf..182d10857ece 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/Trustpay.js @@ -134,6 +134,17 @@ card_pm:{ } } }, + "Void":{ + "Request": { + }, + "Response": { + "status": 200, + "body":{ + status: "cancelled" + + } + } + }, "Refund": { "Request": { "card": successfulNo3DSCardDetails, @@ -163,14 +174,24 @@ card_pm:{ } }, + "SyncRefund": { + "Request": { + "card": successfulNo3DSCardDetails, + "currency": "USD", + "customer_acceptance": null, + }, + "Response": { + "status": 200, + "body": { + "status": "succeeded", + } + + } + }, "MandateSingleUse3DSAutoCapture": { "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -194,10 +215,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -221,10 +238,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -247,10 +260,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -273,10 +282,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -299,10 +304,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -325,10 +326,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -347,10 +344,6 @@ card_pm:{ "Request": { "card": successfulThreeDSTestCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "requires_customer_action", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "multi_use": { "amount": 8000, @@ -373,10 +366,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "mandate_type": { "single_use": { "amount": 8000, @@ -399,10 +388,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "setup_future_usage": "on_session", "customer_acceptance": { "acceptance_type": "offline", @@ -424,10 +409,6 @@ card_pm:{ "Request": { "card": successfulNo3DSCardDetails, "currency": "USD", - "paymentSuccessfulStatus": "succeeded", - "paymentSyncStatus": "succeeded", - "refundStatus": "succeeded", - "refundSyncStatus": "succeeded", "setup_future_usage": "on_session", "customer_acceptance": { "acceptance_type": "offline", diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index d65258ac9eda..09062eb5e41f 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -240,8 +240,9 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - expect("requires_capture").to.equal(response.body.status); - } else { + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); } @@ -308,8 +309,9 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } else if (response.body.authentication_type === "no_three_ds") { - expect("requires_capture").to.equal(response.body.status); - } else { + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); } @@ -326,7 +328,7 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ // This is consequent saved card payment confirm call test(Using payment token) Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, res_data,globalState) => { const paymentIntentID = globalState.get("paymentID"); - SaveCardConfirmBody.card_cvc = req_data.card_cvc; + SaveCardConfirmBody.card_cvc = req_data.card.card_cvc; SaveCardConfirmBody.payment_token = globalState.get("paymentToken"); SaveCardConfirmBody.client_secret = globalState.get("clientSecret"); console.log("conf conn ->" + globalState.get("connectorId")); @@ -367,8 +369,9 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, .to.have.property("redirect_to_url") } else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal("requires_capture"); - expect(response.body.customer_id).to.equal(globalState.get("customerId")); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } expect(response.body.customer_id).to.equal(globalState.get("customerId")); } else { // Handle other authentication types as needed throw new Error(`Unsupported authentication type: ${authentication_type}`); @@ -417,7 +420,7 @@ Cypress.Commands.add("captureCallTest", (requestBody, req_data, res_data, amount }); }); -Cypress.Commands.add("voidCallTest", (requestBody, globalState) => { +Cypress.Commands.add("voidCallTest", (requestBody, req_data, res_data, globalState) => { const payment_id = globalState.get("paymentID"); cy.request({ method: "POST", @@ -430,13 +433,21 @@ Cypress.Commands.add("voidCallTest", (requestBody, globalState) => { body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); + console.log(response); + expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - expect(response.body.payment_id).to.equal(payment_id); - expect(response.body.amount).to.equal(globalState.get("paymentAmount")); - // expect(response.body.amount_capturable).to.equal(0); - expect(response.body.amount_received).to.be.oneOf([0, null]); - expect(response.body.status).to.equal("cancelled"); + if(response.body.payment_id !== undefined) { + 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]); + } + } }); }); @@ -477,7 +488,7 @@ Cypress.Commands.add("refundCallTest", (requestBody, req_data, res_data, refund_ body: requestBody }).then((response) => { logRequestId(response.headers['x-request-id']); - + console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -510,7 +521,7 @@ Cypress.Commands.add("syncRefundCallTest", (req_data, res_data, globalState) => failOnStatusCode: false, }).then((response) => { logRequestId(response.headers['x-request-id']); - + console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); for(const key in res_data.body) { @@ -540,7 +551,7 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - + console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("mandateId", response.body.mandate_id); @@ -602,7 +613,7 @@ Cypress.Commands.add("mitForMandatesCallTest", (requestBody, amount, confirm, ca body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - + console.log(response); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", response.body.payment_id); console.log("mit statusss-> " + response.body.status); @@ -706,13 +717,13 @@ Cypress.Commands.add("handleRedirection", (globalState, expected_redirection) => }) } else if (globalState.get("connectorId") === "nmi" || globalState.get("connectorId") === "noon") { - cy.get('iframe', { timeout: 100000 }) + cy.get('iframe', { timeout: 150000 }) .its('0.contentDocument.body') .within((body) => { - cy.get('iframe', { timeout: 10000 }) + cy.get('iframe', { timeout: 20000 }) .its('0.contentDocument.body') .within((body) => { - cy.get('form[name="cardholderInput"]', { timeout: 10000 }).should('exist').then(form => { + cy.get('form[name="cardholderInput"]', { timeout: 20000 }).should('exist').then(form => { cy.get('input[name="challengeDataEntry"]').click().type("1234"); cy.get('input[value="SUBMIT"]').click(); }) diff --git a/cypress-tests/readme.md b/cypress-tests/readme.md index 9285066bfe60..511625cdbfb9 100644 --- a/cypress-tests/readme.md +++ b/cypress-tests/readme.md @@ -37,7 +37,7 @@ To run test cases, follow these steps: export CYPRESS_BASEURL="base_url" export DEBUG=cypress:cli export CYPRESS_ADMINAPIKEY="admin_api_key" - export CYPRESS_CONNECToR_AUtH_FILE_PATH="path/to/creds.json" + export CYPRESS_CONNECTOR_AUTH_FILE_PATH="path/to/creds.json" ``` 4. Run Cypress test cases From ef8e5994aaced074dbdfdc83f3a2ebfacd9c6559 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Mon, 20 May 2024 17:30:23 +0530 Subject: [PATCH 10/14] refactor: comments --- cypress-tests/cypress/support/commands.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 09062eb5e41f..a405173798d7 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -126,9 +126,6 @@ Cypress.Commands.add("createCustomerCallTest", (customerCreateBody, globalState) }).then((response) => { logRequestId(response.headers['x-request-id']); - // Handle the response as needed - console.log(response); - globalState.set("customerId", response.body.customer_id); }); }); @@ -156,7 +153,6 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au body: request, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -168,9 +164,6 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au for(const key in res_data.body) { expect(res_data.body[key]).to.equal(response.body[key]); } - expect(request.amount).to.equal(response.body.amount); - expect(null).to.equal(response.body.amount_received); - expect(request.amount).to.equal(response.body.amount_capturable); }); }); @@ -188,7 +181,6 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => { }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(response.headers["content-type"]).to.include("application/json"); expect(response.body).to.have.property("redirect_url"); expect(response.body).to.have.property("payment_methods"); @@ -215,7 +207,6 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir body: confirmBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -276,7 +267,6 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ body: createConfirmPaymentBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -344,7 +334,6 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, }) .then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -433,7 +422,6 @@ Cypress.Commands.add("voidCallTest", (requestBody, req_data, res_data, globalSta body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -488,7 +476,6 @@ Cypress.Commands.add("refundCallTest", (requestBody, req_data, res_data, refund_ body: requestBody }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); @@ -521,7 +508,6 @@ Cypress.Commands.add("syncRefundCallTest", (req_data, res_data, globalState) => failOnStatusCode: false, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); for(const key in res_data.body) { @@ -551,7 +537,6 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("mandateId", response.body.mandate_id); @@ -613,7 +598,6 @@ Cypress.Commands.add("mitForMandatesCallTest", (requestBody, amount, confirm, ca body: requestBody, }).then((response) => { logRequestId(response.headers['x-request-id']); - console.log(response); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", response.body.payment_id); console.log("mit statusss-> " + response.body.status); From 566444b7b6148607eee9f9f04b3140081a291e95 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Mon, 20 May 2024 18:36:09 +0530 Subject: [PATCH 11/14] refactor: comments --- cypress-tests/cypress/support/commands.js | 136 ++++++++++++---------- 1 file changed, 74 insertions(+), 62 deletions(-) diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index a405173798d7..2221723bfb8f 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -156,13 +156,21 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); + if(response.status === "200"){ + + } expect(response.body).to.have.property("client_secret"); const clientSecret = response.body.client_secret; - globalState.set("clientSecret", clientSecret); - globalState.set("paymentID", response.body.payment_id); - cy.log(clientSecret); - for(const key in res_data.body) { - expect(res_data.body[key]).to.equal(response.body[key]); + if(response.status === "200"){ + globalState.set("clientSecret", clientSecret); + globalState.set("paymentID", response.body.payment_id); + cy.log(clientSecret); + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } + expect(request.amount).to.equal(response.body.amount); + expect(null).to.equal(response.body.amount_received); + expect(request.amount).to.equal(response.body.amount_capturable); } }); }); @@ -270,40 +278,42 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - - if (response.body.capture_method === "automatic") { - expect(response.body).to.have.property("status"); - globalState.set("paymentAmount", createConfirmPaymentBody.amount); - globalState.set("paymentID", response.body.payment_id); - if (response.body.authentication_type === "three_ds") { - expect(response.body).to.have.property("next_action") - .to.have.property("redirect_to_url") - globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); - } - 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]); + + if(response.status === "200"){ + if (response.body.capture_method === "automatic") { + expect(response.body).to.have.property("status"); + globalState.set("paymentAmount", createConfirmPaymentBody.amount); + globalState.set("paymentID", response.body.payment_id); + if (response.body.authentication_type === "three_ds") { + expect(response.body).to.have.property("next_action") + .to.have.property("redirect_to_url") + globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); + } + 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 { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${authentication_type}`); } - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); - } - } - else if (response.body.capture_method === "manual") { - expect(response.body).to.have.property("status"); - globalState.set("paymentAmount", createConfirmPaymentBody.amount); - globalState.set("paymentID", response.body.payment_id); - if (response.body.authentication_type === "three_ds") { - expect(response.body).to.have.property("next_action") - .to.have.property("redirect_to_url") - globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); } - 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 { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); + else if (response.body.capture_method === "manual") { + expect(response.body).to.have.property("status"); + globalState.set("paymentAmount", createConfirmPaymentBody.amount); + globalState.set("paymentID", response.body.payment_id); + if (response.body.authentication_type === "three_ds") { + expect(response.body).to.have.property("next_action") + .to.have.property("redirect_to_url") + globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); + } + 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 { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${authentication_type}`); + } } } else{ @@ -338,32 +348,34 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", paymentIntentID); - 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; - } 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]); + if(response.status === "200"){ + 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; + } 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]); + } + expect(response.body.customer_id).to.equal(globalState.get("customerId")); + } else { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${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") + } + 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]); + } expect(response.body.customer_id).to.equal(globalState.get("customerId")); + } else { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${authentication_type}`); } - expect(response.body.customer_id).to.equal(globalState.get("customerId")); - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${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") - } - 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]); - } expect(response.body.customer_id).to.equal(globalState.get("customerId")); - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); } } else { From 288ff77597e4345d8a9db2be0c42c3cf9d90d573 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Tue, 21 May 2024 13:42:55 +0530 Subject: [PATCH 12/14] refactor: resolve comments --- .../00003-NoThreeDSAutoCapture.cy.js | 16 +- .../00004-ThreeDSAutoCapture.cy.js | 14 +- .../00005-NoThreeDSManualCapture.cy.js | 30 ++-- .../e2e/ConnectorTest/00006-VoidPayment.cy.js | 26 ++-- .../e2e/ConnectorTest/00007-SyncPayment.cy.js | 14 +- .../ConnectorTest/00008-RefundPayment.cy.js | 144 +++++++++--------- .../e2e/ConnectorTest/00009-SyncRefund.cy.js | 18 +-- .../00010-CreateSingleuseMandate.cy.js | 22 +-- .../00011-CreateMultiuseMandate.cy.js | 24 +-- .../00012-ListAndRevokeMandate.cy.js | 12 +- .../ConnectorTest/00013-SaveCardFlow.cy.js | 32 ++-- .../ConnectorTest/00014-ZeroAuthMandate.cy.js | 14 +- .../00015-ThreeDSManualCapture.cy.js | 30 ++-- .../cypress/e2e/ConnectorUtils/utils.js | 9 ++ cypress-tests/cypress/support/commands.js | 120 ++++++++------- 15 files changed, 219 insertions(+), 306 deletions(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js index 93b8486e729e..4dc3f2a3e78f 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00003-NoThreeDSAutoCapture.cy.js @@ -3,6 +3,7 @@ import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -35,7 +36,7 @@ describe("Card - NoThreeDS payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -47,7 +48,7 @@ describe("Card - NoThreeDS payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -71,7 +72,7 @@ describe("Card - NoThreeDS payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -81,12 +82,3 @@ describe("Card - NoThreeDS payment flow test", () => { }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js index a77918537fe0..c970d9716eff 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00004-ThreeDSAutoCapture.cy.js @@ -2,6 +2,7 @@ import confirmBody from "../../fixtures/confirm-body.json"; import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -36,7 +37,7 @@ describe("Card - ThreeDS payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -50,7 +51,7 @@ describe("Card - ThreeDS payment flow test", () => { let res_data = data["Response"]; cy.task('cli_log', "GLOBAL STATE -> " + JSON.stringify(globalState.data)); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -59,12 +60,3 @@ describe("Card - ThreeDS payment flow test", () => { }) }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js index 0100a493b867..48a22f5a5c03 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00005-NoThreeDSManualCapture.cy.js @@ -4,6 +4,7 @@ import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -38,7 +39,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -52,7 +53,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -65,7 +66,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -90,7 +91,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -103,7 +104,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -130,7 +131,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -144,7 +145,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -156,7 +157,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -180,7 +181,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -193,7 +194,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -205,12 +206,3 @@ describe("Card - NoThreeDS Manual payment flow test", () => { }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } - } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js index 96c7d50b3e04..06615f3f67e8 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js @@ -3,6 +3,7 @@ import createPaymentBody from "../../fixtures/create-payment-body.json"; import voidBody from "../../fixtures/void-payment-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -35,7 +36,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -49,7 +50,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("void-call-test", () => { @@ -57,7 +58,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.voidCallTest(voidBody, req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -75,7 +76,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.hould_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -87,7 +88,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.voidCallTest(voidBody, req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); }); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); context("Card - void payment in Requires_payment_method state flow test", () => { @@ -104,7 +105,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -118,7 +119,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, false, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("void-call-test", () => { @@ -126,15 +127,6 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.voidCallTest(voidBody, req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); }); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } - } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js index 787e436d8291..10c16f7ff6e9 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00007-SyncPayment.cy.js @@ -2,6 +2,7 @@ import confirmBody from "../../fixtures/confirm-body.json"; import createPaymentBody from "../../fixtures/create-payment-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -31,7 +32,7 @@ describe("Card - Sync payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -45,7 +46,7 @@ describe("Card - Sync payment flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -53,12 +54,3 @@ describe("Card - Sync payment flow test", () => { }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js index ed7f6bfe3f97..dfdd0df21d17 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00008-RefundPayment.cy.js @@ -8,6 +8,7 @@ import refundBody from "../../fixtures/refund-flow-body.json"; import listRefundCall from "../../fixtures/list-refund-call-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -40,7 +41,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -54,7 +55,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -67,7 +68,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -85,7 +86,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -99,7 +100,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -111,7 +112,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("refund-call-test", () => { @@ -119,7 +120,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -138,7 +139,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -150,7 +151,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -170,7 +171,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -182,7 +183,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("refund-call-test", () => { @@ -190,7 +191,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -198,7 +199,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -216,7 +217,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -230,7 +231,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -243,7 +244,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -255,7 +256,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -263,7 +264,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -281,7 +282,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -295,7 +296,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -308,7 +309,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -320,14 +321,14 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["PartialRefund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -335,7 +336,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("list-refund-call-test", () => { cy.listRefundCallTest(listRefundCall, globalState); @@ -356,7 +357,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -370,7 +371,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -383,7 +384,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -395,7 +396,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -404,7 +405,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -422,7 +423,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -436,7 +437,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -449,7 +450,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -461,7 +462,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -469,7 +470,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -488,7 +489,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + req_data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -504,7 +505,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 7000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -512,7 +513,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -533,7 +534,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -547,7 +548,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -564,7 +565,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -583,7 +584,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -596,7 +597,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -613,7 +614,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("refund-call-test", () => { @@ -621,7 +622,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1200, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -640,7 +641,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -657,7 +658,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -677,7 +678,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -694,7 +695,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("refund-call-test", () => { @@ -702,7 +703,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 3000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -710,7 +711,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -730,7 +731,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -743,7 +744,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -761,7 +762,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -774,7 +775,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -794,7 +795,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -807,7 +808,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -825,7 +826,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -838,14 +839,14 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 5000, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("refund-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 1500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -866,7 +867,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -879,7 +880,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -897,7 +898,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -910,7 +911,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -931,7 +932,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -944,7 +945,7 @@ describe("Card - Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -962,7 +963,7 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -975,15 +976,6 @@ describe("Card - Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 50 , globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); - - function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } - } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js index 79d7f514a53a..31e5e6855d6a 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00009-SyncRefund.cy.js @@ -3,6 +3,7 @@ import createPaymentBody from "../../fixtures/create-payment-body.json"; import refundBody from "../../fixtures/refund-flow-body.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -33,7 +34,7 @@ describe("Card - Sync Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -47,7 +48,7 @@ describe("Card - Sync Refund flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -59,7 +60,7 @@ describe("Card - Sync Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.refundCallTest(refundBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("sync-refund-call-test", () => { @@ -67,16 +68,7 @@ describe("Card - Sync Refund flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.syncRefundCallTest(req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js index de150e2c2860..4ece0319324e 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00010-CreateSingleuseMandate.cy.js @@ -3,6 +3,7 @@ import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -37,7 +38,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -61,7 +62,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("cit-capture-call-test", () => { @@ -70,7 +71,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -83,7 +84,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("list-mandate-call-test", () => { @@ -107,7 +108,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("cit-capture-call-test", () => { @@ -116,7 +117,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -128,12 +129,3 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js index 419a8f500868..898258c8d6a3 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00011-CreateMultiuseMandate.cy.js @@ -3,6 +3,7 @@ import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -38,7 +39,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -65,7 +66,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("cit-capture-call-test", () => { @@ -74,7 +75,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT 1", () => { @@ -87,7 +88,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT 2", () => { @@ -100,7 +101,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -120,7 +121,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 6500, true, "manual", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("cit-capture-call-test", () => { @@ -129,7 +130,7 @@ describe("Card - MultiUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -137,12 +138,3 @@ describe("Card - MultiUse Mandates flow test", () => { }); }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js index f9913b955877..8de48fbf95a4 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00012-ListAndRevokeMandate.cy.js @@ -1,6 +1,7 @@ import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; import State from "../../utils/State"; @@ -37,7 +38,7 @@ describe("Card - SingleUse Mandates flow test", () => { let res_data = data["Response"]; console.log("det -> " + data.card); cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 7000, true, "automatic", "new_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -58,12 +59,3 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js index c40a1e71b8d4..1168a5690893 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00013-SaveCardFlow.cy.js @@ -5,6 +5,7 @@ import createConfirmPaymentBody from "../../fixtures/create-confirm-body.json"; import customerCreateBody from "../../fixtures/create-customer-body.json"; import SaveCardConfirmBody from "../../fixtures/save-card-confirm-body.json"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; import State from "../../utils/State"; let globalState; @@ -37,7 +38,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -53,7 +54,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it ("confirm-save-card-payment-call-test", () => { @@ -61,7 +62,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -84,7 +85,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -100,7 +101,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -109,7 +110,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.saveCardConfirmCallTest(SaveCardConfirmBody, req_data, res_data, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -121,7 +122,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); @@ -143,7 +144,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest( createConfirmPaymentBody, req_data, res_data,"no_three_ds", "automatic", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -159,7 +160,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest( createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); @@ -168,7 +169,7 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.saveCardConfirmCallTest(SaveCardConfirmBody,req_data, res_data,globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { cy.retrievePaymentCallTest(globalState); @@ -179,18 +180,9 @@ describe("Card - SaveCard payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } -} \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js index 63e4617a9960..ee0edcb94ac2 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00014-ZeroAuthMandate.cy.js @@ -2,6 +2,7 @@ import citConfirmBody from "../../fixtures/create-mandate-cit.json"; import mitConfirmBody from "../../fixtures/create-mandate-mit.json"; import State from "../../utils/State"; import getConnectorDetails from "../ConnectorUtils/utils"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -34,7 +35,7 @@ describe("Card - SingleUse Mandates flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 0, true, "automatic", "setup_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -55,7 +56,7 @@ describe("Card - SingleUse Mandates flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.citForMandatesCallTest(citConfirmBody, req_data, res_data, 0, true, "automatic", "setup_mandate", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Confirm No 3DS MIT", () => { @@ -67,12 +68,3 @@ describe("Card - SingleUse Mandates flow test", () => { }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } - } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js index 7f7fed490ad0..fa6de0092dc8 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00015-ThreeDSManualCapture.cy.js @@ -4,6 +4,7 @@ import confirmBody from "../../fixtures/confirm-body.json"; import getConnectorDetails from "../ConnectorUtils/utils"; import State from "../../utils/State"; import captureBody from "../../fixtures/capture-flow-body.json"; +import * as utils from "../ConnectorUtils/utils"; let globalState; @@ -36,7 +37,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -48,7 +49,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -65,7 +66,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -88,7 +89,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -106,7 +107,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 6500, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -132,7 +133,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { @@ -144,7 +145,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.confirmCallTest(confirmBody, req_data, res_data, true, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -161,7 +162,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -183,7 +184,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createConfirmPaymentTest(createConfirmPaymentBody, req_data, res_data, "three_ds", "manual", globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("Handle redirection", () => { @@ -200,7 +201,7 @@ describe("Card - ThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.captureCallTest(captureBody, req_data, res_data, 100, globalState); - if(should_continue) should_continue = should_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("retrieve-payment-call-test", () => { @@ -212,12 +213,3 @@ describe("Card - ThreeDS Manual payment flow test", () => { }); }); - -function should_continue_further(res_data) { - if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ - return false; - } - else { - return true; - } - } \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/ConnectorUtils/utils.js b/cypress-tests/cypress/e2e/ConnectorUtils/utils.js index c667c402c564..960481a1252a 100644 --- a/cypress-tests/cypress/e2e/ConnectorUtils/utils.js +++ b/cypress-tests/cypress/e2e/ConnectorUtils/utils.js @@ -34,4 +34,13 @@ function getValueByKey(jsonObject, key) { } else { return null; } +} + +export const should_continue_further = (res_data) => { + if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ + return false; + } + else { + return true; + } } \ No newline at end of file diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 2221723bfb8f..5432e7df4e48 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -156,12 +156,10 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - if(response.status === "200"){ - - } - expect(response.body).to.have.property("client_secret"); - const clientSecret = response.body.client_secret; - if(response.status === "200"){ + + if(response.status === 200){ + expect(response.body).to.have.property("client_secret"); + const clientSecret = response.body.client_secret; globalState.set("clientSecret", clientSecret); globalState.set("paymentID", response.body.payment_id); cy.log(clientSecret); @@ -172,6 +170,12 @@ Cypress.Commands.add("createPaymentIntentTest", (request, req_data, res_data, au expect(null).to.equal(response.body.amount_received); expect(request.amount).to.equal(response.body.amount_capturable); } + 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]); + } + } }); }); @@ -218,32 +222,34 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - globalState.set("paymentID", paymentIntentID); - 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"); - globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); - } 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]); + if(response.status === 200){ + globalState.set("paymentID", paymentIntentID); + 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"); + globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); + } 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 { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${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") + globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); + } + 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 { + // Handle other authentication types as needed + throw new Error(`Unsupported authentication type: ${authentication_type}`); } - } else { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${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") - globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); - } - 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 { - // Handle other authentication types as needed - throw new Error(`Unsupported authentication type: ${authentication_type}`); } } else { @@ -252,6 +258,7 @@ Cypress.Commands.add("confirmCallTest", (confirmBody, req_data, res_data, confir expect(res_data.body.error[key]).to.equal(response.body.error[key]); } } + }); }); @@ -279,7 +286,7 @@ Cypress.Commands.add("createConfirmPaymentTest", (createConfirmPaymentBody, req_ expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - if(response.status === "200"){ + if(response.status === 200){ if (response.body.capture_method === "automatic") { expect(response.body).to.have.property("status"); globalState.set("paymentAmount", createConfirmPaymentBody.amount); @@ -348,7 +355,7 @@ Cypress.Commands.add("saveCardConfirmCallTest", (SaveCardConfirmBody, req_data, expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); globalState.set("paymentID", paymentIntentID); - if(response.status === "200"){ + if(response.status === 200){ if (response.body.capture_method === "automatic") { if (response.body.authentication_type === "three_ds") { expect(response.body).to.have.property("next_action") @@ -491,7 +498,7 @@ Cypress.Commands.add("refundCallTest", (requestBody, req_data, res_data, refund_ expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - if(response.body.status !== undefined) { + 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]); @@ -554,31 +561,33 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, globalState.set("mandateId", response.body.mandate_id); globalState.set("paymentID", response.body.payment_id); - if (response.body.capture_method === "automatic") { - expect(response.body).to.have.property("mandate_id"); - 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; - globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); - cy.log(response.body); - cy.log(nextActionUrl); - } else if (response.body.authentication_type === "no_three_ds") { + if(response.status === 200) { + if (response.body.capture_method === "automatic") { + expect(response.body).to.have.property("mandate_id"); + 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; + globalState.set("nextActionUrl", response.body.next_action.redirect_to_url); + cy.log(response.body); + cy.log(nextActionUrl); + } 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]); } - } - for(const key in res_data.body) { - expect(res_data.body[key]).to.equal(response.body[key]); - } - } - else if (response.body.capture_method === "manual") { - expect(response.body).to.have.property("mandate_id"); - if (response.body.authentication_type === "three_ds") { - expect(response.body).to.have.property("next_action") } - for(const key in res_data.body) { - expect(res_data.body[key]).to.equal(response.body[key]); + else if (response.body.capture_method === "manual") { + expect(response.body).to.have.property("mandate_id"); + if (response.body.authentication_type === "three_ds") { + expect(response.body).to.have.property("next_action") + } + for(const key in res_data.body) { + expect(res_data.body[key]).to.equal(response.body[key]); + } } } else{ @@ -587,7 +596,6 @@ Cypress.Commands.add("citForMandatesCallTest", (requestBody, req_data, res_data, expect(res_data.body.error[key]).to.equal(response.body.error[key]); } } - }); }); From ca9308956a28be39dbe45a4bc8230de7124589fb Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Tue, 21 May 2024 13:54:18 +0530 Subject: [PATCH 13/14] refactor: spell check --- cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js index 06615f3f67e8..15f2e0e7930a 100644 --- a/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/ConnectorTest/00006-VoidPayment.cy.js @@ -76,7 +76,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { let req_data = data["Request"]; let res_data = data["Response"]; cy.createPaymentIntentTest(createPaymentBody, req_data, res_data, "no_three_ds", "manual", globalState); - if(should_continue) should_continue = utils.hould_continue_further(res_data); + if(should_continue) should_continue = utils.should_continue_further(res_data); }); it("payment_methods-call-test", () => { From 271bcf8fe7ee9d6a1ba4fce8089107cca993c4a0 Mon Sep 17 00:00:00 2001 From: Sk Sakil Mostak Date: Tue, 21 May 2024 14:51:27 +0530 Subject: [PATCH 14/14] refactor: resolve comments --- cypress-tests/cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 5432e7df4e48..b28619d788a6 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -444,7 +444,7 @@ Cypress.Commands.add("voidCallTest", (requestBody, req_data, res_data, globalSta expect(res_data.status).to.equal(response.status); expect(response.headers["content-type"]).to.include("application/json"); - if(response.body.payment_id !== undefined) { + if(response.status === 200) { for(const key in res_data.body) { expect(res_data.body[key]).to.equal(response.body[key]); }