Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

ci(cypress): Add Tests for Customer Deletion and Psync flows (#7158)

likhinbopanna9772cb36ee03
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00026-DeletedCustomerPsyncFlow.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00026-DeletedCustomerPsyncFlow.cy.js
new file mode 100644
index 0000000000..365137ee34
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/00026-DeletedCustomerPsyncFlow.cy.js
@@ -0,0 +1,337 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Card - Customer Deletion and Psync", () => {
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Card - Psync after Customer Deletion for Automatic Capture", () => {
+ context("No3DS Card - Psync after Customer Deletion ", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("Create Customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Confirm Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+
+ it("Delete Customer", () => {
+ cy.customerDeleteCall(globalState);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+ });
+
+ context("3DS Card - Psync after Customer Deletion ", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ it("Create Customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Confirm Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["3DSAutoCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Handle redirection", () => {
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ cy.handleRedirection(globalState, expected_redirection);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+
+ it("Delete Customer", () => {
+ cy.customerDeleteCall(globalState);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+ });
+ });
+
+ context("Card - Psync after Customer Deletion for Manual Capture", () => {
+ context("No3DS Card - Psync after Customer Deletion ", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("Create Customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "manual",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Confirm Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSManualCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSManualCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+
+ it("Capture Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Capture"];
+
+ cy.captureCallTest(fixtures.captureBody, data, 6500, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Capture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+
+ it("Delete Customer", () => {
+ cy.customerDeleteCall(globalState);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSManualCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+ });
+
+ context("3DS Card - Psync after Customer Deletion ", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ it("Create Customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "manual",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Confirm Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["3DSManualCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Handle redirection", () => {
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ cy.handleRedirection(globalState, expected_redirection);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["3DSManualCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+
+ it("Capture Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Capture"];
+
+ cy.captureCallTest(fixtures.captureBody, data, 6500, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Capture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+
+ it("Delete Customer", () => {
+ cy.customerDeleteCall(globalState);
+ });
+
+ it("Retrieve Payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["3DSManualCapture"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00026-BusinessProfileConfigs.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00027-BusinessProfileConfigs.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/spec/Payment/00026-BusinessProfileConfigs.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/00027-BusinessProfileConfigs.cy.js
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00027-DynamicFields.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00028-DynamicFields.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/spec/Payment/00027-DynamicFields.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/00028-DynamicFields.cy.js
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00028-IncrementalAuth.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00029-IncrementalAuth.cy.js
similarity index 100%
rename from cypress-tests/cypress/e2e/spec/Payment/00028-IncrementalAuth.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/00029-IncrementalAuth.cy.js
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 45be704311..f04d7762fa 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -2263,54 +2263,66 @@ Cypress.Commands.add(
logRequestId(response.headers["x-request-id"]);
cy.wrap(response).then(() => {
- 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.profile_id, "profile_id").to.not.be.null;
- expect(response.body.billing, "billing_address").to.not.be.empty;
- expect(response.body.customer, "customer").to.not.be.empty;
- if (
- ["succeeded", "processing", "requires_customer_action"].includes(
- response.body.status
- )
- ) {
- expect(response.body.connector, "connector").to.equal(
- globalState.get("connectorId")
+ if (response.status === 200) {
+ expect(response.headers["content-type"]).to.include(
+ "application/json"
);
- expect(response.body.payment_method_data, "payment_method_data").to
- .not.be.empty;
- expect(response.body.payment_method, "payment_method").to.not.be.null;
- expect(response.body.merchant_connector_id, "connector_id").to.equal(
- merchant_connector_id
+ expect(response.body.payment_id).to.equal(payment_id);
+ expect(response.body.amount).to.equal(
+ globalState.get("paymentAmount")
);
- }
+ expect(response.body.profile_id, "profile_id").to.not.be.null;
+ expect(response.body.billing, "billing_address").to.not.be.empty;
+ expect(response.body.customer, "customer").to.not.be.empty;
+ if (
+ ["succeeded", "processing", "requires_customer_action"].includes(
+ response.body.status
+ )
+ ) {
+ expect(response.body.connector, "connector").to.equal(
+ globalState.get("connectorId")
+ );
+ expect(response.body.payment_method_data, "payment_method_data").to
+ .not.be.empty;
+ expect(response.body.payment_method, "payment_method").to.not.be
+ .null;
+ expect(
+ response.body.merchant_connector_id,
+ "connector_id"
+ ).to.equal(merchant_connector_id);
+ }
- if (autoretries) {
- expect(response.body).to.have.property("attempts");
- expect(response.body.attempts).to.be.an("array").and.not.empty;
- expect(response.body.attempts.length).to.equal(attempt);
- expect(response.body.attempts[0].attempt_id).to.include(
- `${payment_id}_`
- );
- for (const key in response.body.attempts) {
- if (
- response.body.attempts[key].attempt_id ===
- `${payment_id}_${attempt}` &&
- response.body.status === "succeeded"
- ) {
- expect(response.body.attempts[key].status).to.equal("charged");
- } else if (
- response.body.attempts[key].attempt_id ===
- `${payment_id}_${attempt}` &&
- response.body.status === "requires_customer_action"
- ) {
- expect(response.body.attempts[key].status).to.equal(
- "authentication_pending"
- );
- } else {
- expect(response.body.attempts[key].status).to.equal("failure");
+ if (autoretries) {
+ expect(response.body).to.have.property("attempts");
+ expect(response.body.attempts).to.be.an("array").and.not.empty;
+ expect(response.body.attempts.length).to.equal(attempt);
+ expect(response.body.attempts[0].attempt_id).to.include(
+ `${payment_id}_`
+ );
+ for (const key in response.body.attempts) {
+ if (
+ response.body.attempts[key].attempt_id ===
+ `${payment_id}_${attempt}` &&
+ response.body.status === "succeeded"
+ ) {
+ expect(response.body.attempts[key].status).to.equal("charged");
+ } else if (
+ response.body.attempts[key].attempt_id ===
+ `${payment_id}_${attempt}` &&
+ response.body.status === "requires_customer_action"
+ ) {
+ expect(response.body.attempts[key].status).to.equal(
+ "authentication_pending"
+ );
+ } else {
+ expect(response.body.attempts[key].status).to.equal("failure");
+ }
}
}
+ } else {
+ throw new Error(
+ `Retrieve Payment Call Failed with error code "${response.body.error.code}" error message "${response.body.error.message}"`
+ );
}
});
});