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 shipping cost test case (#6779)

likhinbopanna08ab3ad7a2e6
diff --git a/cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js
index 62f4af2338..e5030647cb 100644
--- a/cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js
+++ b/cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js
@@ -96,4 +96,52 @@ describe("Card - NoThreeDS payment flow test", () => {
cy.retrievePaymentCallTest(globalState, data);
});
});
+
+ context("Card-NoThreeDS payment with shipping cost", () => {
+ let 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", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntentWithShippingCost"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("payment_methods-call-test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("Confirm No 3DS", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentConfirmWithShippingCost"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("retrieve-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentConfirmWithShippingCost"];
+
+ cy.retrievePaymentCallTest(globalState, data);
+ });
+ });
});
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js
index db3206e5dd..1fc4cf9649 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js
@@ -80,6 +80,40 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6550,
+ amount: 6500,
+ net_amount: 6550,
+ },
+ },
+ },
"3DSManualCapture": {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js
index a5af06b908..308565e72f 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js
@@ -78,6 +78,40 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ amount: 6500,
+ shipping_cost: 50,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6550,
+ amount: 6500,
+ net_amount: 6550,
+ },
+ },
+ },
"3DSManualCapture": {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js b/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js
index 708a8660d5..f27b7ef76c 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js
@@ -29,6 +29,41 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ amount: 6500,
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ amount: 6500,
+ shipping_cost: 50,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6550,
+ amount: 6500,
+ net_amount: 6550,
+ },
+ },
+ },
"3DSManualCapture": {
Configs: {
TRIGGER_SKIP: true,
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Checkout.js b/cypress-tests/cypress/e2e/PaymentUtils/Checkout.js
index 3307e90c37..9679b70866 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Checkout.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Checkout.js
@@ -38,6 +38,38 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "processing",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
"3DSManualCapture": {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
index 28b85c8544..a258d7fa0d 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
@@ -637,9 +637,35 @@ export const connectorDetails = {
status: 200,
body: {
status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
},
},
}),
+ PaymentIntentWithShippingCost: getCustomExchange({
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ }),
+ PaymentConfirmWithShippingCost: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ }),
"3DSManualCapture": getCustomExchange({
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
index ea7fe7b7ac..0c489f6df8 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
@@ -146,6 +146,40 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6550,
+ amount: 6500,
+ net_amount: 6550,
+ },
+ },
+ },
"3DSManualCapture": {
Configs: {
CONNECTOR_CREDENTIAL: {
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js
index 2ece2615b4..8ad218953d 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Nmi.js
@@ -38,6 +38,38 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "processing",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
"3DSManualCapture": {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Noon.js b/cypress-tests/cypress/e2e/PaymentUtils/Noon.js
index 6d2a392697..63f6b63173 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Noon.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Noon.js
@@ -115,6 +115,38 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "AED",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
"3DSManualCapture": {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js
index a551ed8595..024ad7377b 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Paypal.js
@@ -48,6 +48,39 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ error_code: "AMOUNT_MISMATCH",
+ error_message:
+ "description - Should equal item_total + tax_total + shipping + handling + insurance - shipping_discount - discount., value - 65.50, field - value;",
+ },
+ },
+ },
"3DSManualCapture": {
Configs: {
TRIGGER_SKIP: true,
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
index d68978c430..4e62c37c5b 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js
@@ -141,6 +141,40 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6550,
+ amount: 6500,
+ net_amount: 6550,
+ },
+ },
+ },
"3DSManualCapture": {
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js
index 76351c6c45..6c4db9df32 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Trustpay.js
@@ -54,6 +54,40 @@ export const connectorDetails = {
},
},
}),
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6500,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6550,
+ amount: 6500,
+ net_amount: 6550,
+ },
+ },
+ },
"3DSAutoCapture": {
Configs: {
CONNECTOR_CREDENTIAL: {
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index f3ce856fe3..89691f0410 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -1079,9 +1079,17 @@ Cypress.Commands.add(
createPaymentBody.setup_future_usage,
"setup_future_usage"
).to.equal(response.body.setup_future_usage);
- expect(createPaymentBody.amount, "amount_capturable").to.equal(
- response.body.amount_capturable
- );
+ // If 'shipping_cost' is not included in the request, the 'amount' in 'createPaymentBody' should match the 'amount_capturable' in the response.
+ if (typeof createPaymentBody?.shipping_cost === "undefined") {
+ expect(createPaymentBody.amount, "amount_capturable").to.equal(
+ response.body.amount_capturable
+ );
+ } else {
+ expect(
+ createPaymentBody.amount + createPaymentBody.shipping_cost,
+ "amount_capturable"
+ ).to.equal(response.body.amount_capturable);
+ }
expect(response.body.amount_received, "amount_received").to.be.oneOf([
0,
null,