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 test coverage for Order Details in payment requests (#12134)

HS-QUALIBOT1366d1ffa1e9
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 829375b36a..c6a1586ddc 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -2819,6 +2819,79 @@ export const connectorDetails = {
currency: "USD",
},
}),
+ OrderDetails: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ order_details: [
+ {
+ product_name: "Test Product",
+ quantity: 1,
+ amount: 6000,
+ },
+ ],
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ OrderDetailsMultipleItems: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ order_details: [
+ {
+ product_name: "Test Product 1",
+ quantity: 1,
+ amount: 3000,
+ },
+ {
+ product_name: "Test Product 2",
+ quantity: 2,
+ amount: 1500,
+ },
+ ],
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ OrderDetailsMissingProductName: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ order_details: [
+ {
+ quantity: 1,
+ amount: 6000,
+ },
+ ],
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ error_type: "invalid_request",
+ code: "IR_06",
+ },
+ },
+ },
+ }),
},
upi_pm: {
PaymentIntent: getCustomExchange({
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 331db2cc97..4f9f852891 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -560,6 +560,16 @@ export const CONNECTOR_LISTS = {
PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],
USE_BILLING_AS_PAYMENT_METHOD_BILLING: ["bankofamerica"],
MIT_WITH_LIMITED_CARD_DATA: ["peachpayments"],
+ ORDER_DETAILS: [
+ "stripe",
+ "cybersource",
+ "checkout",
+ "airwallex",
+ "braintree",
+ "bankofamerica",
+ "paypal",
+ "trustpay",
+ ],
CARD_TESTING_GUARD: ["bankofamerica"],
L2L3DATA: ["checkout", "nuvei", "worldpayvantiv"],
REFUND_MANUAL_UPDATE: ["bankofamerica", "cybersource"],
diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-OrderDetails.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-OrderDetails.cy.js
new file mode 100644
index 0000000000..3b3343afb2
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/52-OrderDetails.cy.js
@@ -0,0 +1,142 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let connector;
+let globalState;
+
+describe("Card - Order Details payment flow test", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ connector = globalState.get("connectorId");
+
+ // Skip the test if the connector is not in the inclusion list
+ if (
+ utils.shouldIncludeConnector(
+ connector,
+ utils.CONNECTOR_LISTS.INCLUDE.ORDER_DETAILS
+ )
+ ) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Create and confirm payment with single order_details item", () => {
+ it("Create and Confirm Payment with order_details -> Retrieve Payment with order_details", () => {
+ let shouldContinue = true;
+
+ cy.step("Create and Confirm Payment with order_details", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["OrderDetails"];
+
+ cy.createConfirmPaymentTest(
+ fixtures.createConfirmPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment with order_details", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Payment with order_details"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["OrderDetails"];
+
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context(
+ "Create and confirm payment with multiple order_details items",
+ () => {
+ it("Create and Confirm Payment with multiple order_details -> Retrieve Payment with order_details", () => {
+ let shouldContinue = true;
+
+ cy.step(
+ "Create and Confirm Payment with multiple order_details",
+ () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["OrderDetailsMultipleItems"];
+
+ cy.createConfirmPaymentTest(
+ fixtures.createConfirmPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ }
+ );
+
+ cy.step("Retrieve Payment with multiple order_details", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Payment with multiple order_details"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["OrderDetailsMultipleItems"];
+
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ }
+ );
+
+ context(
+ "Create and confirm payment with missing required order_details field",
+ () => {
+ it("Create and Confirm Payment with missing product_name -> Expect validation error IR_06", () => {
+ cy.step("Create and Confirm Payment with missing product_name", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["OrderDetailsMissingProductName"];
+
+ cy.createConfirmPaymentTest(
+ fixtures.createConfirmPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ });
+ });
+ }
+ );
+});