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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
ci(cypress): add pml test for card installments (#11557)
likhinbopannae8be1ad27455
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.jsindex f350748269..1875644b27 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js@@ -772,6 +772,7 @@ export const connectorDetails = {},PaymentIntentWithInstallments: {Request: {+ amount: 6000,currency: "BRL",installment_options: [{@@ -790,6 +791,8 @@ export const connectorDetails = {status: 200,body: {status: "requires_payment_method",+ amount: 6000,+ currency: "BRL",},},},@@ -1053,6 +1056,55 @@ export const connectorDetails = {PmListNull: {payment_methods: [],},+ PmListWithInstallmentsNull: {+ intent_data: {+ status: "requires_payment_method",+ amount: 6000,+ currency: "USD",+ installment_options: null,+ },+ },+ PmListWithInstallmentsBRL: {+ intent_data: {+ status: "requires_payment_method",+ amount: 6000,+ currency: "BRL",+ installment_options: [+ {+ payment_method: "card",+ available_plans: [+ {+ number_of_installments: 3,+ billing_frequency: "month",+ interest_rate: 5,+ amount_details: {+ amount_per_installment: 21,+ total_amount: 63,+ },+ },+ {+ number_of_installments: 6,+ billing_frequency: "month",+ interest_rate: 5,+ amount_details: {+ amount_per_installment: 10.5,+ total_amount: 63,+ },+ },+ {+ number_of_installments: 12,+ billing_frequency: "month",+ interest_rate: 5,+ amount_details: {+ amount_per_installment: 5.25,+ total_amount: 63,+ },+ },+ ],+ },+ ],+ },+ },pmListDynamicFieldWithoutBilling: {payment_methods: [{diff --git a/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.jsindex 524f830272..93a1ecafb6 100644--- a/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/00038-CardInstallments.cy.js@@ -1,12 +1,16 @@import * as fixtures from "../../../fixtures/imports";import State from "../../../utils/State";-import getConnectorDetails, * as utils from "../../configs/Payment/Utils";+import * as utils from "../../configs/Payment/Utils";+import getConnectorDetails, {+ CONNECTOR_LISTS,+ shouldIncludeConnector,+} from "../../configs/Payment/Utils";-let connector;let globalState;+let connector;describe("Card - Installment payment flow test", () => {- before(function () {+ before("seed global state", function () {let skip = false;cy.task("getGlobalState")@@ -14,13 +18,15 @@ describe("Card - Installment payment flow test", () => {globalState = new State(state);connector = globalState.get("connectorId");+ // Skip if connector is not in the CARD_INSTALLMENTS include listif (- utils.shouldIncludeConnector(+ shouldIncludeConnector(connector,- utils.CONNECTOR_LISTS.INCLUDE.CARD_INSTALLMENTS+ CONNECTOR_LISTS.INCLUDE.CARD_INSTALLMENTS)) {skip = true;+ return;}}).then(() => {@@ -34,79 +40,137 @@ describe("Card - Installment payment flow test", () => {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",+ "Card installment payment - Adyen configured + USD currency → installment_options: null",() => {- let shouldContinue = true;+ it("Create Payment Intent -> Payment Methods Call", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent with USD", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step(+ "Payment Methods Call - Verify installment_options is null",+ () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "pm_list"+ ]["PmListResponse"]["PmListWithInstallmentsNull"];+ cy.paymentMethodsCallTest(globalState, data);+ }+ );+ });+ }+ );- beforeEach(function () {- if (!shouldContinue) {- this.skip();- }+ context(+ "Card installment payment - Adyen configured + BRL currency → installment_options populated",+ () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment -> Retrieve Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent with BRL and installments", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Create Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntentWithInstallments"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call - Verify installment_options", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "pm_list"+ ]["PmListResponse"]["PmListWithInstallmentsBRL"];+ cy.paymentMethodsCallTest(globalState, data);+ });++ cy.step("Confirm Installment Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardInstallmentConfirm"];++ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardInstallmentConfirm"];++ cy.retrievePaymentCallTest({ globalState, data });+ });});+ }+ );- 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+ context(+ "Card installment payment - Create with confirm true should fail",+ () => {+ it("Create+Confirm Payment with installments should error", () => {+ cy.step(+ "Create Payment Intent with confirm true and installments",+ () => {+ 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/support/commands.js b/cypress-tests/cypress/support/commands.jsindex a1bbbca32e..1f2e866fb0 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -1883,7 +1883,8 @@ Cypress.Commands.add(});-Cypress.Commands.add("paymentMethodsCallTest", (globalState) => {+Cypress.Commands.add("paymentMethodsCallTest", (globalState, data = null) => {+ const resData = data?.Response || data;const clientSecret = globalState.get("clientSecret");const paymentIntentID = clientSecret.split("_secret_")[0];@@ -1899,6 +1900,25 @@ Cypress.Commands.add("paymentMethodsCallTest", (globalState) => {cy.wrap(response).then(() => {expect(response.headers["content-type"]).to.include("application/json");++ // Verify response against config data if provided (only check fields defined in config)+ if (resData?.body) {+ for (const key in resData.body) {+ expect(response.body[key], [key]).to.deep.equal(resData.body[key]);+ }+ }++ // Verify intent_data if provided in config (for installment tests)+ if (resData?.intent_data) {+ expect(response.body.intent_data, "intent_data").to.exist;+ for (const key in resData.intent_data) {+ expect(+ response.body.intent_data[key],+ `intent_data.${key}`+ ).to.deep.equal(resData.intent_data[key]);+ }+ }+expect(response.body).to.have.property("redirect_url");expect(response.body).to.have.property("payment_methods");if (