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 client secret session expiry coverage (#12090)

HS-QUALIBOT4908dcce3e44
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 642fbc991f..0c929ae151 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -1248,6 +1248,38 @@ export const connectorDetails = {
},
},
}),
+ PaymentIntentWithSessionExpiry: getCustomExchange({
+ Request: {
+ currency: "USD",
+ session_expiry: 60,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ SessionExpiredConfirmPayment: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "The provided client_secret has expired",
+ code: "IR_08",
+ },
+ },
+ },
+ }),
Capture: getCustomExchange({
Request: {
amount_to_capture: 6000,
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00-CoreFlows.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00-CoreFlows.cy.js
index b64bfc4254..02e360c0c6 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/00-CoreFlows.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/00-CoreFlows.cy.js
@@ -1,5 +1,6 @@
import * as fixtures from "../../../fixtures/imports";
import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
import { payment_methods_enabled } from "../../configs/Payment/Commons";
let globalState;
@@ -157,6 +158,84 @@ describe("Core flows", () => {
});
});
+ context("Client Secret Session Expiry", () => {
+ const SESSION_EXPIRY_WAIT = 65000;
+ let shouldContinue = true;
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("Update business profile with session_expiry", () => {
+ const updateBusinessProfileBody = {
+ session_expiry: 60,
+ };
+ cy.UpdateBusinessProfileTest(
+ updateBusinessProfileBody,
+ false,
+ false,
+ false,
+ false,
+ false,
+ globalState
+ );
+ });
+
+ it("Create payment - session expiry inherited from business profile", () => {
+ 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 after session expiry - should fail with ClientSecretExpired", () => {
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
+ cy.wait(SESSION_EXPIRY_WAIT);
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["SessionExpiredConfirmPayment"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ });
+
+ it("Create payment with session_expiry in request body", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntentWithSessionExpiry"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+ });
+
context("Delete calls", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {