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

test(cypress): add Poll config coverage for stripe (#12335)

HS-QUALIBOT8dece87d24c3
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Stripe.js b/cypress-tests/cypress/e2e/configs/Payment/Stripe.js
index 0486d788c4..967be38c5d 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Stripe.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Stripe.js
@@ -878,6 +878,64 @@ export const connectorDetails = {
},
},
},
+ PollConfig: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: {
+ card_number: "4000000000003220",
+ card_exp_month: "10",
+ card_exp_year: "27",
+ card_holder_name: "John Doe",
+ card_cvc: "737",
+ },
+ },
+ authentication_type: "three_ds",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ authentication_type: "three_ds",
+ },
+ },
+ },
+ PollConfigNotFound: {
+ Response: {
+ status: 404,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Poll does not exist in our records",
+ code: "HE_02",
+ },
+ },
+ },
+ },
+ PollConfigInvalidPollId: {
+ Response: {
+ status: 404,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Poll does not exist in our records",
+ code: "HE_02",
+ },
+ },
+ },
+ },
+ PollConfigUnauthorized: {
+ Response: {
+ status: 401,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "API key not provided or invalid API key used",
+ code: "IR_01",
+ },
+ },
+ },
+ },
external_three_ds: {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index d79aa85cd0..28c2749882 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -596,6 +596,7 @@ export const CONNECTOR_LISTS = {
"worldpay",
"worldpayvantiv",
],
+ POLL_CONFIG: ["stripe"],
// Add more inclusion lists
},
};
diff --git a/cypress-tests/cypress/e2e/spec/Payment/47-PollConfig.cy.js b/cypress-tests/cypress/e2e/spec/Payment/47-PollConfig.cy.js
new file mode 100644
index 0000000000..563fa54d30
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/47-PollConfig.cy.js
@@ -0,0 +1,239 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Poll Config - Payment status polling", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ const connectorId = globalState.get("connectorId");
+
+ if (!utils.CONNECTOR_LISTS.INCLUDE.POLL_CONFIG.includes(connectorId)) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("3DS payment confirm triggers polling state", () => {
+ it("create payment intent -> confirm 3DS payment -> verify polling state", () => {
+ let shouldContinue = true;
+
+ cy.step("create payment intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("confirm 3DS payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: confirm 3DS payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PollConfig"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("verify poll config - next_action redirect URL exists", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: verify poll config");
+ return;
+ }
+ const nextActionUrl = globalState.get("nextActionUrl");
+ expect(nextActionUrl, "next_action redirect URL").to.not.be.undefined;
+ expect(nextActionUrl, "next_action redirect URL").to.not.be.empty;
+ });
+ });
+ });
+
+ context(
+ "Poll endpoint with constructed poll_id returns 404 when poll_id not in Redis",
+ () => {
+ it("create payment intent -> confirm 3DS -> poll with constructed poll_id -> verify 404", () => {
+ let shouldContinue = true;
+
+ cy.step("create payment intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("confirm 3DS payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: confirm 3DS payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PollConfig"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("poll with constructed poll_id", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: poll with constructed poll_id");
+ return;
+ }
+ const paymentID = globalState.get("paymentID");
+ const pollId = `external_authentication_${paymentID}`;
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PollConfigNotFound"];
+
+ cy.pollStatusCallTest(pollId, data, globalState, true);
+ });
+ });
+ }
+ );
+
+ context("Poll endpoint with invalid poll_id", () => {
+ it("poll with invalid poll_id and publishable key returns 404", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PollConfigInvalidPollId"];
+
+ cy.pollStatusCallTest("test_poll_invalid", data, globalState, true);
+ });
+
+ it("poll with invalid poll_id and merchant api key returns 401", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PollConfigUnauthorized"];
+
+ cy.pollStatusCallTest("test_poll_invalid", data, globalState, false);
+ });
+ });
+
+ context("Non-3DS payment does not trigger polling state", () => {
+ it("create payment intent -> confirm non-3DS payment -> verify success", () => {
+ let shouldContinue = true;
+
+ cy.step("create payment intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("confirm non-3DS payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: confirm non-3DS payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ });
+ });
+ });
+
+ context("Force sync retrieves 3DS payment status", () => {
+ it("create payment intent -> confirm 3DS -> force sync -> verify status", () => {
+ let shouldContinue = true;
+
+ cy.step("create payment intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("confirm 3DS payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: confirm 3DS payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PollConfig"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("force sync payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: force sync payment");
+ return;
+ }
+ cy.retrievePaymentCallTest({ globalState });
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index c5944d5291..206a630c78 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -797,6 +797,48 @@ Cypress.Commands.add(
}
);
+Cypress.Commands.add(
+ "pollStatusCallTest",
+ (pollId, data, globalState, usePublishableKey = true) => {
+ const { Response: resData } = data || {};
+
+ const apiKey = usePublishableKey
+ ? globalState.get("publishableKey") || globalState.get("apiKey")
+ : globalState.get("apiKey");
+ const baseUrl = globalState.get("baseUrl");
+
+ cy.request({
+ method: "GET",
+ url: `${baseUrl}/poll/status/${pollId}`,
+ headers: {
+ "api-key": apiKey,
+ "Content-Type": "application/json",
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+
+ if (resData?.status) {
+ expect(response.status, "status_code").to.equal(resData.status);
+ }
+
+ if (resData?.body) {
+ for (const key in resData.body) {
+ expect(response.body[key], [key]).to.deep.equal(resData.body[key]);
+ }
+ }
+
+ if (response.status === 200 && response.body.poll_id) {
+ expect(response.body.poll_id, "poll_id").to.equal(pollId);
+ }
+ });
+ });
+ }
+);
+
Cypress.Commands.add(
"UpdateBusinessProfileTest",
(