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 Session Token Testcases (#6683)

Gnanasundari2484a4fb13d5d4
diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml
index bc83c2388f..070682b9c3 100644
--- a/.github/workflows/cypress-tests-runner.yml
+++ b/.github/workflows/cypress-tests-runner.yml
@@ -222,6 +222,11 @@ jobs:
- name: Setup Local Server
if: ${{ env.RUN_TESTS == 'true' }}
+ env:
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC: ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE }}
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC_KEY: ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE_KEY }}
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT: ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE }}
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT_KEY: ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE_KEY }}
run: |
# Start the server in the background
target/debug/router &
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00024-SessionCall.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00024-SessionCall.cy.js
new file mode 100644
index 0000000000..8d729a2f77
--- /dev/null
+++ b/cypress-tests/cypress/e2e/PaymentTest/00024-SessionCall.cy.js
@@ -0,0 +1,50 @@
+import * as fixtures from "../../fixtures/imports";
+import State from "../../utils/State";
+import getConnectorDetails, * as utils from "../PaymentUtils/Utils";
+
+let globalState;
+
+describe("Customer Create flow test", () => {
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ const shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+ it("create-payment-call-test", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ 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("session-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][
+ "SessionToken"
+ ];
+
+ cy.sessionTokenCall(fixtures.sessionTokenBody, data, globalState);
+ });
+});
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
index 85718d8f9b..998c6b91f7 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
@@ -398,6 +398,27 @@ export const payment_methods_enabled = [
},
],
},
+ {
+ payment_method: "wallet",
+ payment_method_types: [
+ {
+ payment_method_type: "apple_pay",
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: true,
+ installment_payment_enabled: true,
+ payment_experience: "invoke_sdk_client",
+ },
+ {
+ payment_method_type: "google_pay",
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: true,
+ installment_payment_enabled: true,
+ payment_experience: "invoke_sdk_client",
+ },
+ ],
+ },
];
export const connectorDetails = {
@@ -684,6 +705,14 @@ export const connectorDetails = {
setup_future_usage: "on_session",
},
}),
+ SessionToken: {
+ Response: {
+ status: 200,
+ body: {
+ session_token: [],
+ },
+ },
+ },
No3DSManualCapture: getCustomExchange({
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
index b98973250e..6877d609ac 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
@@ -151,6 +151,23 @@ export const connectorDetails = {
},
},
},
+ SessionToken: {
+ Response: {
+ status: 200,
+ body: {
+ session_token: [
+ {
+ wallet_name: "apple_pay",
+ connector: "cybersource",
+ },
+ {
+ wallet_name: "google_pay",
+ connector: "cybersource",
+ },
+ ],
+ },
+ },
+ },
PaymentIntentWithShippingCost: {
Request: {
currency: "USD",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
index b8dd275afa..8d4d94fa56 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
@@ -163,6 +163,23 @@ export const connectorDetails = {
},
},
},
+ SessionToken: {
+ Response: {
+ status: 200,
+ body: {
+ session_token: [
+ {
+ wallet_name: "apple_pay",
+ connector: "stripe",
+ },
+ {
+ wallet_name: "google_pay",
+ connector: "stripe",
+ },
+ ],
+ },
+ },
+ },
PaymentIntentWithShippingCost: {
Request: {
currency: "USD",
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 6135f26934..bcbe64512f 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -1016,21 +1016,56 @@ Cypress.Commands.add(
}
);
-Cypress.Commands.add("sessionTokenCall", (globalState, sessionTokenBody) => {
- cy.request({
- method: "POST",
- url: `${globalState.get("baseUrl")}/payments/session_tokens`,
- headers: {
- Accept: "application/json",
- "Content-Type": "application/json",
- "api-key": globalState.get("publishableKey"),
- },
- body: sessionTokenBody,
- failOnStatusCode: false,
- }).then((response) => {
- logRequestId(response.headers["x-request-id"]);
- });
-});
+Cypress.Commands.add(
+ "sessionTokenCall",
+ (sessionTokenBody, data, globalState) => {
+ const { Response: resData } = data || {};
+
+ sessionTokenBody.payment_id = globalState.get("paymentID");
+ sessionTokenBody.client_secret = globalState.get("clientSecret");
+
+ cy.request({
+ method: "POST",
+ url: `${globalState.get("baseUrl")}/payments/session_tokens`,
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ "api-key": globalState.get("publishableKey"),
+ "x-merchant-domain": "hyperswitch - demo - store.netlify.app",
+ "x-client-platform": "web",
+ },
+ body: sessionTokenBody,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ if (response.status === 200) {
+ const expectedTokens = resData.body.session_token;
+ const actualTokens = response.body.session_token;
+
+ // Verifying length of array
+ expect(actualTokens.length, "arrayLength").to.equal(
+ expectedTokens.length
+ );
+
+ // Verify specific fields in each session_token object
+ expectedTokens.forEach((expectedToken, index) => {
+ const actualToken = actualTokens[index];
+
+ // Check specific fields only
+ expect(actualToken.wallet_name, "wallet_name").to.equal(
+ expectedToken.wallet_name
+ );
+ expect(actualToken.connector, "connector").to.equal(
+ expectedToken.connector
+ );
+ });
+ } else {
+ defaultErrorHandler(response, resData);
+ }
+ });
+ }
+);
Cypress.Commands.add(
"createPaymentIntentTest",