diff --git a/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js b/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js index 7005a308cb48..89b27a6b2716 100644 --- a/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js +++ b/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js @@ -1,15 +1,13 @@ -import apiKeyCreateBody from "../../fixtures/create-api-key-body.json"; -import createConnectorBody from "../../fixtures/create-connector-body.json"; -import merchantCreateBody from "../../fixtures/merchant-create-body.json"; +import * as fixtures from "../../fixtures/imports"; import State from "../../utils/State"; import { - bank_redirect_ideal_and_credit_enabled, - bank_redirect_ideal_enabled, - card_credit_enabled, - card_credit_enabled_in_US, - card_credit_enabled_in_USD, - create_payment_body_with_currency, - create_payment_body_with_currency_country, + bankRedirectIdealAndCreditEnabled, + bankRedirectIdealEnabled, + cardCreditEnabled, + cardCreditEnabledInUs, + cardCreditEnabledInUsd, + createPaymentBodyWithCurrency, + createPaymentBodyWithCurrencyCountry, } from "../PaymentMethodListUtils/Commons"; import getConnectorDetails from "../PaymentMethodListUtils/Utils"; @@ -34,19 +32,22 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); + }); + it("customer-create-call-test", () => { + cy.createCustomerCallTest(fixtures.customerCreateBody, globalState); }); // stripe connector create with ideal enabled it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - bank_redirect_ideal_enabled, + fixtures.createConnectorBody, + bankRedirectIdealEnabled, globalState, "stripe", "stripe_US_default" @@ -57,8 +58,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled, + fixtures.createConnectorBody, + cardCreditEnabled, globalState, "cybersource", "cybersource_US_default" @@ -76,7 +77,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency("EUR"), + createPaymentBodyWithCurrency("EUR"), newData, "no_three_ds", "automatic", @@ -117,19 +118,19 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); }); // stripe connector create with ideal enabled it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - bank_redirect_ideal_enabled, + fixtures.createConnectorBody, + bankRedirectIdealEnabled, globalState, "stripe", "stripe_US_default" @@ -140,8 +141,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled_in_USD, + fixtures.createConnectorBody, + cardCreditEnabledInUsd, globalState, "cybersource", "cybersource_US_default" @@ -159,7 +160,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency("INR"), + createPaymentBodyWithCurrency("INR"), newData, "no_three_ds", "automatic", @@ -200,19 +201,19 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); }); // stripe connector create with credit enabled for US it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled_in_US, + fixtures.createConnectorBody, + cardCreditEnabledInUs, globalState, "stripe", "stripe_US_default" @@ -223,8 +224,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled_in_US, + fixtures.createConnectorBody, + cardCreditEnabledInUs, globalState, "cybersource", "cybersource_US_default" @@ -242,7 +243,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency("USD"), + createPaymentBodyWithCurrency("USD"), newData, "no_three_ds", "automatic", @@ -283,19 +284,19 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); }); // stripe connector create with ideal enabled it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - bank_redirect_ideal_enabled, + fixtures.createConnectorBody, + bankRedirectIdealEnabled, globalState, "stripe", "stripe_US_default" @@ -306,8 +307,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - bank_redirect_ideal_enabled, + fixtures.createConnectorBody, + bankRedirectIdealEnabled, globalState, "cybersource", "cybersource_US_default" @@ -325,7 +326,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency_country("EUR", "US", "US"), + createPaymentBodyWithCurrencyCountry("EUR", "US", "US"), newData, "no_three_ds", "automatic", @@ -368,19 +369,19 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); }); // stripe connector create with card credit enabled it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled, + fixtures.createConnectorBody, + cardCreditEnabled, globalState, "stripe", "stripe_US_default" @@ -391,8 +392,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - bank_redirect_ideal_and_credit_enabled, + fixtures.createConnectorBody, + bankRedirectIdealAndCreditEnabled, globalState, "cybersource", "cybersource_US_default" @@ -410,7 +411,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency_country("USD", "IN", "IN"), + createPaymentBodyWithCurrencyCountry("USD", "IN", "IN"), newData, "no_three_ds", "automatic", @@ -452,19 +453,19 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); }); // stripe connector create with card credit enabled it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled, + fixtures.createConnectorBody, + cardCreditEnabled, globalState, "stripe", "stripe_US_default" @@ -475,8 +476,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled, + fixtures.createConnectorBody, + cardCreditEnabled, globalState, "cybersource", "cybersource_US_default" @@ -494,7 +495,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency("USD"), + createPaymentBodyWithCurrency("USD"), newData, "no_three_ds", "automatic", @@ -535,19 +536,19 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }); it("merchant-create-call-test", () => { - cy.merchantCreateCallTest(merchantCreateBody, globalState); + cy.merchantCreateCallTest(fixtures.merchantCreateBody, globalState); }); it("api-key-create-call-test", () => { - cy.apiKeyCreateTest(apiKeyCreateBody, globalState); + cy.apiKeyCreateTest(fixtures.apiKeyCreateBody, globalState); }); // stripe connector create with ideal enabled it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - bank_redirect_ideal_enabled, + fixtures.createConnectorBody, + bankRedirectIdealEnabled, globalState, "stripe", "stripe_US_default" @@ -558,8 +559,8 @@ describe("Payment Method list using Constraint Graph flow tests", () => { it("connector-create-call-test", () => { cy.createNamedConnectorCallTest( "payment_processor", - createConnectorBody, - card_credit_enabled, + fixtures.createConnectorBody, + cardCreditEnabled, globalState, "cybersource", "cybersource_US_default" @@ -577,7 +578,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => { }; cy.createPaymentIntentTest( - create_payment_body_with_currency_country("EUR", "NL", "US"), + createPaymentBodyWithCurrencyCountry("EUR", "NL", "US"), newData, "no_three_ds", "automatic", diff --git a/cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js index 7119a9aabc97..ae72465b6065 100644 --- a/cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js +++ b/cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js @@ -1,4 +1,4 @@ -export const card_credit_enabled = [ +export const cardCreditEnabled = [ { payment_method: "card", payment_method_types: [ @@ -6,6 +6,10 @@ export const card_credit_enabled = [ payment_method_type: "credit", card_networks: ["Visa"], minimum_amount: 0, + accepted_currencies: { + type: "enable_only", + list: ["USD"], + }, maximum_amount: 68607706, recurring_enabled: false, installment_payment_enabled: true, @@ -14,7 +18,7 @@ export const card_credit_enabled = [ }, ]; -export const card_credit_enabled_in_USD = [ +export const cardCreditEnabledInUsd = [ { payment_method: "card", payment_method_types: [ @@ -34,7 +38,7 @@ export const card_credit_enabled_in_USD = [ }, ]; -export const card_credit_enabled_in_US = [ +export const cardCreditEnabledInUs = [ { payment_method: "card", payment_method_types: [ @@ -54,7 +58,7 @@ export const card_credit_enabled_in_US = [ }, ]; -export const bank_redirect_ideal_enabled = [ +export const bankRedirectIdealEnabled = [ { payment_method: "bank_redirect", payment_method_types: [ @@ -72,7 +76,7 @@ export const bank_redirect_ideal_enabled = [ }, ]; -export const bank_redirect_ideal_and_credit_enabled = [ +export const bankRedirectIdealAndCreditEnabled = [ { payment_method: "card", payment_method_types: [ @@ -103,7 +107,7 @@ export const bank_redirect_ideal_and_credit_enabled = [ }, ]; -export const create_payment_body_with_currency_country = ( +export const createPaymentBodyWithCurrencyCountry = ( currency, billingCountry, shippingCountry @@ -158,7 +162,7 @@ export const create_payment_body_with_currency_country = ( }, }); -export const create_payment_body_with_currency = (currency) => ({ +export const createPaymentBodyWithCurrency = (currency) => ({ currency: currency, amount: 6500, authentication_type: "three_ds", diff --git a/cypress-tests/cypress/e2e/PaymentTest/00026-DynamicFields.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00026-DynamicFields.cy.js new file mode 100644 index 000000000000..a325ac5f2f0d --- /dev/null +++ b/cypress-tests/cypress/e2e/PaymentTest/00026-DynamicFields.cy.js @@ -0,0 +1,175 @@ +import * as fixtures from "../../fixtures/imports"; +import State from "../../utils/State"; +import { cardCreditEnabled } from "../PaymentMethodListUtils/Commons"; +import getConnectorDetails, * as utils from "../PaymentUtils/Utils"; + +let globalState; + +describe("Dynamic Fields Verification", () => { + context("Verify the Dynamic fields for card", () => { + before("seed global state", () => { + cy.task("getGlobalState").then((state) => { + globalState = new State(state); + }); + }); + + after("flush global state", () => { + cy.task("setGlobalState", globalState.data); + }); + + context( + "Verify the Dynamic fields - Payment without billing address", + () => { + let shouldContinue = true; + + beforeEach(function () { + if (!shouldContinue) { + this.skip(); + } + }); + + it("Create Business Profile", () => { + cy.createBusinessProfileTest( + fixtures.businessProfile.bpCreate, + globalState + ); + }); + + it("connector-create-call-test", () => { + cy.createConnectorCallTest( + "payment_processor", + fixtures.createConnectorBody, + cardCreditEnabled, + globalState + ); + }); + + it("Create Payment Intent", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentWithoutBilling"]; + + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + if (shouldContinue) + shouldContinue = utils.should_continue_further(data); + }); + + it("Payment Method List", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "pm_list" + ]["PmListResponse"]["pmListDynamicFieldWithoutBilling"]; + cy.paymentMethodListTestWithRequiredFields(data, globalState); + }); + } + ); + + context("Verify the Dynamic fields - Payment with billing address", () => { + let shouldContinue = true; + + beforeEach(function () { + if (!shouldContinue) { + this.skip(); + } + }); + + it("Create Payment Intent", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentWithBilling"]; + + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + if (shouldContinue) + shouldContinue = utils.should_continue_further(data); + }); + + it("Payment Method List", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "pm_list" + ]["PmListResponse"]["pmListDynamicFieldWithBilling"]; + cy.paymentMethodListTestWithRequiredFields(data, globalState); + }); + }); + + context( + "Verify the Dynamic fields - Payment with billing First and Last name", + () => { + let shouldContinue = true; + + beforeEach(function () { + if (!shouldContinue) { + this.skip(); + } + }); + + it("Create Payment Intent", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentWithFullName"]; + + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + if (shouldContinue) + shouldContinue = utils.should_continue_further(data); + }); + + it("Payment Method List", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "pm_list" + ]["PmListResponse"]["pmListDynamicFieldWithNames"]; + cy.paymentMethodListTestWithRequiredFields(data, globalState); + }); + } + ); + + context("Verify the Dynamic fields - Payment with billing Email", () => { + let shouldContinue = true; + + beforeEach(function () { + if (!shouldContinue) { + this.skip(); + } + }); + + it("Create Payment Intent", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "card_pm" + ]["PaymentWithBillingEmail"]; + + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + if (shouldContinue) + shouldContinue = utils.should_continue_further(data); + }); + + it("Payment Method List", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "pm_list" + ]["PmListResponse"]["pmListDynamicFieldWithEmail"]; + cy.paymentMethodListTestWithRequiredFields(data, globalState); + }); + }); + }); +}); +1; diff --git a/cypress-tests/cypress/e2e/PaymentTest/00026-IncrementalAuth.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00027-IncrementalAuth.cy.js similarity index 100% rename from cypress-tests/cypress/e2e/PaymentTest/00026-IncrementalAuth.cy.js rename to cypress-tests/cypress/e2e/PaymentTest/00027-IncrementalAuth.cy.js diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js index 81525041147d..db3206e5dde5 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Adyen.js @@ -982,4 +982,215 @@ export const connectorDetails = { }, }, }, + pm_list: { + PmListResponse: { + PmListNull: { + payment_methods: [], + }, + pmListDynamicFieldWithoutBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["adyen"], + }, + ], + required_fields: { + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: null, + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: null, + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["adyen"], + }, + ], + required_fields: { + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithNames: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["adyen"], + }, + ], + required_fields: { + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithEmail: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["adyen"], + }, + ], + required_fields: { + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + }, + }, + ], + }, + ], + }, + }, + }, }; diff --git a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js index 6f383367e057..a5af06b908a2 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js @@ -675,4 +675,265 @@ export const connectorDetails = { }, }, }, + pm_list: { + PmListResponse: { + PmListNull: { + payment_methods: [], + }, + pmListDynamicFieldWithoutBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["bankofamerica"], + }, + ], + required_fields: { + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: null, + }, + "billing.address.state": { + required_field: "payment_method_data.billing.address.state", + display_name: "state", + field_type: "user_address_state", + value: null, + }, + "billing.address.country": { + required_field: + "payment_method_data.billing.address.country", + display_name: "country", + field_type: { + user_address_country: { + options: ["ALL"], + }, + }, + value: null, + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "billing.address.zip": { + required_field: "payment_method_data.billing.address.zip", + display_name: "zip", + field_type: "user_address_pincode", + value: null, + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: null, + }, + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "billing.address.line1": { + required_field: "payment_method_data.billing.address.line1", + display_name: "line1", + field_type: "user_address_line1", + value: null, + }, + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + email: { + required_field: "email", + display_name: "email", + field_type: "user_email_address", + value: "hyperswitch_sdk_demo_id@gmail.com", + }, + "billing.address.city": { + required_field: "payment_method_data.billing.address.city", + display_name: "city", + field_type: "user_address_city", + value: null, + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["bankofamerica"], + }, + ], + required_fields: { + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + "billing.address.state": { + required_field: "payment_method_data.billing.address.state", + display_name: "state", + field_type: "user_address_state", + value: "CA", + }, + "billing.address.country": { + required_field: + "payment_method_data.billing.address.country", + display_name: "country", + field_type: { + user_address_country: { + options: ["ALL"], + }, + }, + value: "PL", + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "billing.address.zip": { + required_field: "payment_method_data.billing.address.zip", + display_name: "zip", + field_type: "user_address_pincode", + value: "94122", + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "billing.address.line1": { + required_field: "payment_method_data.billing.address.line1", + display_name: "line1", + field_type: "user_address_line1", + value: "1467", + }, + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + email: { + required_field: "email", + display_name: "email", + field_type: "user_email_address", + value: "hyperswitch.example@gmail.com", + }, + "billing.address.city": { + required_field: "payment_method_data.billing.address.city", + display_name: "city", + field_type: "user_address_city", + value: "San Fransico", + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithNames: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["bankofamerica"], + }, + ], + required_fields: { + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithEmail: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["bankofamerica"], + }, + ], + required_fields: { + email: { + required_field: "email", + display_name: "email", + field_type: "user_email_address", + value: "hyperswitch_sdk_demo_id1@gmail.com", + }, + }, + }, + ], + }, + ], + }, + }, + }, }; diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js index 144b43fee7cd..28b85c854465 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js @@ -98,6 +98,49 @@ const multiUseMandateData = { }, }; +export const cardRequiredField = { + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, +}; + +export const fullNameRequiredField = { + "billing.address.last_name": { + required_field: "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + "billing.address.first_name": { + required_field: "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, +}; + +export const billingRequiredField = {}; /* `getDefaultExchange` contains the default Request and Response to be considered if none provided. `getCustomExchange` takes in 2 optional fields named as Request and Response. @@ -1383,6 +1426,96 @@ export const connectorDetails = { }, }, }), + PaymentWithoutBilling: { + Request: { + currency: "USD", + customer_acceptance: null, + setup_future_usage: "off_session", + authentication_type: "no_three_ds", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }, + PaymentWithBilling: { + Request: { + currency: "USD", + setup_future_usage: "off_session", + billing: { + address: { + line1: "1467", + line2: "CA", + line3: "Harrison Street", + city: "San Fransico", + state: "CA", + zip: "94122", + country: "PL", + first_name: "joseph", + last_name: "Doe", + }, + phone: { + number: "9111222333", + country_code: "+91", + }, + }, + email: "hyperswitch.example@gmail.com", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }, + PaymentWithFullName: { + Request: { + currency: "USD", + setup_future_usage: "off_session", + billing: { + address: { + first_name: "joseph", + last_name: "Doe", + }, + phone: { + number: "9111222333", + country_code: "+91", + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }, + PaymentWithBillingEmail: { + Request: { + currency: "USD", + setup_future_usage: "off_session", + email: "hyperswitch_sdk_demo_id1@gmail.com", + billing: { + address: { + first_name: "joseph", + last_name: "Doe", + }, + phone: { + number: "9111222333", + country_code: "+91", + }, + email: "hyperswitch.example@gmail.com", + }, + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }, }, upi_pm: { PaymentIntent: getCustomExchange({ @@ -1421,4 +1554,67 @@ export const connectorDetails = { }, }), }, + pm_list: { + PmListResponse: { + PmListNull: { + payment_methods: [], + }, + pmListDynamicFieldWithoutBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [], + required_fields: {}, + }, + ], + }, + ], + }, + pmListDynamicFieldWithBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [], + required_fields: {}, + }, + ], + }, + ], + }, + pmListDynamicFieldWithNames: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [], + required_fields: {}, + }, + ], + }, + ], + }, + pmListDynamicFieldWithEmail: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [], + required_fields: {}, + }, + ], + }, + ], + }, + }, + }, }; diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js index d2782d450cd4..97a5bd0971c0 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js @@ -931,4 +931,255 @@ export const connectorDetails = { }, }, }, + pm_list: { + PmListResponse: { + PmListNull: { + payment_methods: [], + }, + pmListDynamicFieldWithoutBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["cybersource"], + }, + ], + required_fields: { + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: null, + }, + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: null, + }, + "billing.address.state": { + required_field: "payment_method_data.billing.address.state", + display_name: "state", + field_type: "user_address_state", + value: null, + }, + "billing.email": { + required_field: "payment_method_data.billing.email", + display_name: "email", + field_type: "user_email_address", + value: "hyperswitch_sdk_demo_id@gmail.com", + }, + "billing.address.zip": { + required_field: "payment_method_data.billing.address.zip", + display_name: "zip", + field_type: "user_address_pincode", + value: null, + }, + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + "billing.address.line1": { + required_field: "payment_method_data.billing.address.line1", + display_name: "line1", + field_type: "user_address_line1", + value: null, + }, + "billing.address.city": { + required_field: "payment_method_data.billing.address.city", + display_name: "city", + field_type: "user_address_city", + value: null, + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithBilling: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["cybersource"], + }, + ], + required_fields: { + "billing.address.city": { + required_field: "payment_method_data.billing.address.city", + display_name: "city", + field_type: "user_address_city", + value: "San Fransico", + }, + "billing.address.state": { + required_field: "payment_method_data.billing.address.state", + display_name: "state", + field_type: "user_address_state", + value: "CA", + }, + "billing.address.zip": { + required_field: "payment_method_data.billing.address.zip", + display_name: "zip", + field_type: "user_address_pincode", + value: "94122", + }, + "billing.address.country": { + required_field: + "payment_method_data.billing.address.country", + display_name: "country", + field_type: { + user_address_country: { + options: ["ALL"], + }, + }, + value: "PL", + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + "billing.email": { + required_field: "payment_method_data.billing.email", + display_name: "email", + field_type: "user_email_address", + value: "hyperswitch.example@gmail.com", + }, + "payment_method_data.card.card_cvc": { + required_field: "payment_method_data.card.card_cvc", + display_name: "card_cvc", + field_type: "user_card_cvc", + value: null, + }, + "billing.address.line1": { + required_field: "payment_method_data.billing.address.line1", + display_name: "line1", + field_type: "user_address_line1", + value: "1467", + }, + "payment_method_data.card.card_exp_month": { + required_field: "payment_method_data.card.card_exp_month", + display_name: "card_exp_month", + field_type: "user_card_expiry_month", + value: null, + }, + "payment_method_data.card.card_number": { + required_field: "payment_method_data.card.card_number", + display_name: "card_number", + field_type: "user_card_number", + value: null, + }, + "payment_method_data.card.card_exp_year": { + required_field: "payment_method_data.card.card_exp_year", + display_name: "card_exp_year", + field_type: "user_card_expiry_year", + value: null, + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithNames: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["cybersource"], + }, + ], + required_fields: { + "billing.address.last_name": { + required_field: + "payment_method_data.billing.address.last_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "Doe", + }, + "billing.address.first_name": { + required_field: + "payment_method_data.billing.address.first_name", + display_name: "card_holder_name", + field_type: "user_full_name", + value: "joseph", + }, + }, + }, + ], + }, + ], + }, + pmListDynamicFieldWithEmail: { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["cybersource"], + }, + ], + required_fields: { + "billing.email": { + required_field: "payment_method_data.billing.email", + display_name: "email", + field_type: "user_email_address", + value: "hyperswitch.example@gmail.com", + }, + }, + }, + ], + }, + ], + }, + }, + }, }; diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js index 5c899e87d9c2..d68978c43023 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Stripe.js @@ -1,4 +1,4 @@ -import { getCustomExchange } from "./Commons"; +import { cardRequiredField, getCustomExchange } from "./Commons"; const successfulNo3DSCardDetails = { card_number: "4242424242424242", @@ -90,6 +90,25 @@ const payment_method_data_no3ds = { billing: null, }; +const requiredFields = { + payment_methods: [ + { + payment_method: "card", + payment_method_types: [ + { + payment_method_type: "credit", + card_networks: [ + { + eligible_connectors: ["stripe"], + }, + ], + required_fields: cardRequiredField, + }, + ], + }, + ], +}; + export const connectorDetails = { card_pm: { PaymentIntent: { @@ -944,4 +963,15 @@ export const connectorDetails = { }, }, }, + pm_list: { + PmListResponse: { + PmListNull: { + payment_methods: [], + }, + pmListDynamicFieldWithoutBilling: requiredFields, + pmListDynamicFieldWithBilling: requiredFields, + pmListDynamicFieldWithNames: requiredFields, + pmListDynamicFieldWithEmail: requiredFields, + }, + }, }; diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 95b981bc6001..f3ce856fe38a 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -384,21 +384,21 @@ Cypress.Commands.add( ( connectorType, createConnectorBody, - payment_methods_enabled, + paymentMethodsEnabled, globalState, connectorName, connectorLabel, - profile_prefix = "profile", - mca_prefix = "merchantConnector" + profilePrefix = "profile", + mcaPrefix = "merchantConnector" ) => { const merchantId = globalState.get("merchantId"); - const profile_id = globalState.get(`${profile_prefix}Id`); + const profileId = globalState.get(`${profilePrefix}Id`); - createConnectorBody.profile_id = profile_id; + createConnectorBody.profile_id = profileId; createConnectorBody.connector_type = connectorType; createConnectorBody.connector_name = connectorName; createConnectorBody.connector_label = connectorLabel; - createConnectorBody.payment_methods_enabled = payment_methods_enabled; + createConnectorBody.payment_methods_enabled = paymentMethodsEnabled; // readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature // it is best to use then() to handle the response within the same block of code cy.readFile(globalState.get("connectorAuthFilePath")).then( @@ -425,7 +425,7 @@ Cypress.Commands.add( if (response.status === 200) { expect(connectorName).to.equal(response.body.connector_name); globalState.set( - `${mca_prefix}Id`, + `${mcaPrefix}Id`, response.body.merchant_connector_id ); } else { @@ -864,6 +864,64 @@ Cypress.Commands.add( } ); +Cypress.Commands.add( + "paymentMethodListTestWithRequiredFields", + (data, globalState) => { + const apiKey = globalState.get("publishableKey"); + const baseUrl = globalState.get("baseUrl"); + const clientSecret = globalState.get("clientSecret"); + const url = `${baseUrl}/account/payment_methods?client_secret=${clientSecret}`; + + cy.request({ + method: "GET", + url: url, + headers: { + "Content-Type": "application/json", + Accept: "application/json", + "api-key": apiKey, + }, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + expect(response.headers["content-type"]).to.include("application/json"); + + if (response.status === 200) { + const responsePaymentMethods = response.body["payment_methods"]; + const responseRequiredFields = + responsePaymentMethods[0]["payment_method_types"][0][ + "required_fields" + ]; + + const expectedRequiredFields = + data["payment_methods"][0]["payment_method_types"][0][ + "required_fields" + ]; + + Object.keys(expectedRequiredFields).forEach((key) => { + const expectedField = expectedRequiredFields[key]; + const responseField = responseRequiredFields[key]; + + expect(responseField).to.exist; + expect(responseField.required_field).to.equal( + expectedField.required_field + ); + expect(responseField.display_name).to.equal( + expectedField.display_name + ); + expect(responseField.field_type).to.deep.equal( + expectedField.field_type + ); + expect(responseField.value).to.equal(expectedField.value); + }); + } else { + throw new Error( + `List payment methods failed with status code "${response.status}" and error message "${response.body.error.message}"` + ); + } + }); + } +); + Cypress.Commands.add( "paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit", (resData, globalState) => {