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 card installment payment flow tests for Adyen (#11444)

Ayush Anand37196df0cfd1
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js
index b0ac112637..c07579fafb 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js
@@ -746,6 +746,78 @@ export const connectorDetails = {
},
},
},
+ PaymentIntentWithInstallments: {
+ Request: {
+ currency: "BRL",
+ installment_options: [
+ {
+ payment_method: "card",
+ installments: [
+ {
+ number_of_installments: [3, 6, 12],
+ billing_frequency: "month",
+ interest_rate: 5.0,
+ },
+ ],
+ },
+ ],
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
+ CardInstallmentConfirm: {
+ Request: {
+ payment_method: "card",
+ payment_method_type: "credit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ installment_data: {
+ number_of_installments: 3,
+ billing_frequency: "month",
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ net_amount: 6300,
+ },
+ },
+ },
+ PaymentIntentWithInstallmentsAndConfirmTrue: {
+ Request: {
+ currency: "BRL",
+ confirm: true,
+ installment_options: [
+ {
+ payment_method: "card",
+ installments: [
+ {
+ number_of_installments: [3, 6, 12],
+ billing_frequency: "month",
+ interest_rate: 5.0,
+ },
+ ],
+ },
+ ],
+ },
+ Response: {
+ status: 422,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "installment_options and installment_data are not supported when confirm is true.",
+ code: "IR_06",
+ },
+ },
+ },
+ },
},
bank_transfer_pm: {
Pix: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 4af0c0bcb3..951d6197bf 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -1985,6 +1985,77 @@ export const connectorDetails = {
`,
},
}),
+ PaymentIntentWithInstallments: getCustomExchange({
+ Request: {
+ currency: "BRL",
+ installment_options: [
+ {
+ payment_method: "card",
+ installments: [
+ {
+ number_of_installments: [3, 6, 12],
+ billing_frequency: "month",
+ interest_rate: 5.0,
+ },
+ ],
+ },
+ ],
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ CardInstallmentConfirm: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_type: "credit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ installment_data: {
+ number_of_installments: 3,
+ billing_frequency: "month",
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ PaymentIntentWithInstallmentsAndConfirmTrue: getCustomExchange({
+ Request: {
+ currency: "BRL",
+ confirm: true,
+ installment_options: [
+ {
+ payment_method: "card",
+ installments: [
+ {
+ number_of_installments: [3, 6, 12],
+ billing_frequency: "month",
+ interest_rate: 5.0,
+ },
+ ],
+ },
+ ],
+ },
+ Response: {
+ status: 422,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "installment_options and installment_data are not supported when confirm is true.",
+ 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 a397ee234c..bfe6cff976 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -467,6 +467,7 @@ export const CONNECTOR_LISTS = {
"worldpayxml",
],
PAYMENTS_WEBHOOK: ["noon", "stripe", "authorizedotnet"],
+ CARD_INSTALLMENTS: ["adyen"],
// Add more inclusion lists
},
};
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.js
new file mode 100644
index 0000000000..524f830272
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.js
@@ -0,0 +1,113 @@
+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 - Installment payment flow test", () => {
+ before(function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ connector = globalState.get("connectorId");
+
+ if (
+ utils.shouldIncludeConnector(
+ connector,
+ utils.CONNECTOR_LISTS.INCLUDE.CARD_INSTALLMENTS
+ )
+ ) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Card installment payment - Create and Confirm", () => {
+ let shouldContinue = true;
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create-installment-payment-intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntentWithInstallments"];
+
+ 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-installment-payment", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["CardInstallmentConfirm"];
+
+ 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"
+ ]["CardInstallmentConfirm"];
+
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ context(
+ "Card installment payment - Create with confirm true should fail",
+ () => {
+ let shouldContinue = true;
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create+confirm-installment-options-should-error", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntentWithInstallmentsAndConfirmTrue"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+ }
+ );
+});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00041-Wallet.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00041-Wallet.cy.js
new file mode 100644
index 0000000000..699d9579c0
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/00041-Wallet.cy.js
@@ -0,0 +1,90 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Wallet tests", () => {
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Bluecode Create and Confirm flow test", () => {
+ let shouldContinue = true;
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ });
+ });
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["PaymentIntent"]("Bluecode");
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "three_ds",
+ "automatic",
+ globalState
+ );
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("payment_methods-call-test", () => {
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ it("Confirm wallet redirect", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["Bluecode"];
+
+ cy.confirmBankRedirectCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+
+ if (shouldContinue) shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("Handle wallet redirection", () => {
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ const nextActionUrl = globalState.get("nextActionUrl");
+
+ expect(
+ nextActionUrl,
+ "nextActionUrl should be defined before handling wallet redirection"
+ ).to.be.a("string");
+
+ cy.handleWalletRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ it("Sync payment status", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "wallet_pm"
+ ]["Bluecode"];
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data,
+ expectedIntentStatus: "requires_customer_action",
+ });
+ });
+ });
+});