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
test(cypress): add CardTestingGuard test coverage (#12129)
likhinbopanna3d73a3ba3b7c
diff --git a/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js b/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.jsindex 0aa0bd0589..6abddcdb5a 100644--- a/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js+++ b/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js@@ -35,6 +35,25 @@ const billing_with_newline = {},};+const cardTestingGuardBilling = {+ address: {+ city: "sakilmostak",+ country: "US",+ line1: "here",+ line2: "there",+ line3: "anywhere",+ zip: "560090",+ state: "Washingtonr",+ first_name: "One",+ last_name: "Two",+ },+ phone: {+ number: "1234567890",+ country_code: "+1",+ },+ email: "[email protected]",+};+const singleUseMandateData = {customer_acceptance: customerAcceptance,mandate_type: {@@ -824,6 +843,83 @@ export const connectorDetails = {},},},+ CardTestingGuard: {+ FailConfirm: {+ Request: {+ payment_method: "card",+ payment_method_data: {+ billing: cardTestingGuardBilling,+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ billing: billing_with_newline,+ },+ Response: {+ status: 200,+ body: {+ status: "failed",+ },+ },+ },+ GuestFailConfirm: {+ Request: {+ payment_method: "card",+ payment_method_data: {+ billing: cardTestingGuardBilling,+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ billing: billing_with_newline,+ },+ Response: {+ status: 200,+ expectBlockedPayment: true,+ body: {+ status: "failed",+ },+ },+ },+ BlockedConfirm: {+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_16",+ message: "Blocked due to suspicious activity",+ },+ },+ },+ },+ GuestBlockedConfirm: {+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_16",+ message: "Blocked due to suspicious activity",+ },+ },+ },+ },+ },},pm_list: {PmListResponse: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex b03a5675cf..be5195231d 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -2628,6 +2628,79 @@ export const connectorDetails = {},},}),+ CardTestingGuard: {+ FailConfirm: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {+ status: "failed",+ },+ },+ }),+ GuestFailConfirm: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ },+ Response: {+ status: 200,+ expectBlockedPayment: true,+ body: {+ status: "failed",+ },+ },+ }),+ BlockedConfirm: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_16",+ message: "Blocked due to suspicious activity",+ },+ },+ },+ }),+ GuestBlockedConfirm: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ code: "IR_16",+ message: "Blocked due to suspicious activity",+ },+ },+ },+ }),+ },L2L3Data: getCustomExchange({Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 8114a6ebd3..95e907a230 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -552,6 +552,7 @@ export const CONNECTOR_LISTS = {PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],USE_BILLING_AS_PAYMENT_METHOD_BILLING: ["bankofamerica"],MIT_WITH_LIMITED_CARD_DATA: ["peachpayments"],+ CARD_TESTING_GUARD: ["bankofamerica"],L2L3DATA: ["checkout", "nuvei", "worldpayvantiv"],REFUND_MANUAL_UPDATE: ["bankofamerica", "cybersource"],// Add more inclusion listsdiff --git a/cypress-tests/cypress/e2e/spec/Payment/52-CardTestingGuard.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-CardTestingGuard.cy.jsnew file mode 100644index 0000000000..6608e0b3d9--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/52-CardTestingGuard.cy.js@@ -0,0 +1,763 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;+let connector;++describe("Card Testing Guard", () => {+ before("seed global state", 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_TESTING_GUARD+ )+ ) {+ skip = true;+ return;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("Card IP Blocking", () => {+ it("should block payment after card_ip_blocking threshold is reached", () => {+ let shouldContinue = true;++ cy.step("Enable only card_ip_blocking on business profile", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "enabled",+ card_ip_blocking_threshold: 3,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 100,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 100,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ cy.step("Create Payment Intent - IP failure 1", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - IP failure 1"+ );+ return;+ }+ globalState.set("customerId", `ctg_ip_1_${Date.now()}`);+ 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("Confirm Payment - IP failure 1", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment - IP failure 1");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["FailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - IP failure 2", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - IP failure 2"+ );+ return;+ }+ globalState.set("customerId", `ctg_ip_2_${Date.now()}`);+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - IP failure 2", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment - IP failure 2");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["FailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - IP failure 3", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - IP failure 3"+ );+ return;+ }+ globalState.set("customerId", `ctg_ip_3_${Date.now()}`);+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - IP failure 3", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment - IP failure 3");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["FailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - IP blocked attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - IP blocked attempt"+ );+ return;+ }+ globalState.set("customerId", `ctg_ip_4_${Date.now()}`);+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - should be blocked by IP", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - should be blocked by IP"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["BlockedConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ });++ cy.step("Disable card_testing_guard_config", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 3,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 100,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 100,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });+ });+ });++ context("Customer ID Blocking", () => {+ it("should block payment after customer_id_blocking threshold is reached", () => {+ let shouldContinue = true;++ cy.step("Enable only customer_id_blocking on business profile", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 100,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 100,+ customer_id_blocking_status: "enabled",+ customer_id_blocking_threshold: 2,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ cy.step("Create Customer", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ cy.step("Create Payment Intent - Customer ID failure 1", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - Customer ID failure 1"+ );+ return;+ }+ 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("Confirm Payment - Customer ID failure 1", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - Customer ID failure 1"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["FailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - Customer ID failure 2", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - Customer ID failure 2"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - Customer ID failure 2", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - Customer ID failure 2"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["FailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - Customer ID blocked attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - Customer ID blocked attempt"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - should be blocked by customer_id", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - should be blocked by customer_id"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["BlockedConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ });++ cy.step("Disable card_testing_guard_config", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 100,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 100,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 2,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });+ });+ });++ context("Guest User Card Blocking", () => {+ it("should block payment after guest_user_card_blocking threshold is reached", () => {+ let shouldContinue = true;++ cy.step(+ "Enable only guest_user_card_blocking on business profile",+ () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 100,+ guest_user_card_blocking_status: "enabled",+ guest_user_card_blocking_threshold: 2,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 100,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ }+ );++ cy.step("Create Payment Intent - Guest failure 1", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - Guest failure 1"+ );+ return;+ }+ globalState.set("customerId", undefined);+ 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("Confirm Payment - Guest failure 1", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - Guest failure 1"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["GuestFailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - Guest failure 2", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - Guest failure 2"+ );+ return;+ }+ globalState.set("customerId", undefined);+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - Guest failure 2", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - Guest failure 2"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["GuestFailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - Guest blocked attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - Guest blocked attempt"+ );+ return;+ }+ globalState.set("customerId", undefined);+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - should be blocked by guest user rule", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - should be blocked by guest user rule"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["GuestBlockedConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ });++ cy.step("Disable card_testing_guard_config", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 100,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 2,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 100,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });+ });+ });++ context("Successful Payment Below Threshold", () => {+ it("should allow payment when failures are below threshold", () => {+ let shouldContinue = true;++ cy.step(+ "Enable customer_id_blocking with threshold 2 on business profile",+ () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 100,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 100,+ customer_id_blocking_status: "enabled",+ customer_id_blocking_threshold: 2,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ }+ );++ cy.step("Create Customer for below-threshold test", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });++ cy.step("Create Payment Intent - single failure below threshold", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - single failure below threshold"+ );+ return;+ }+ 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("Confirm Payment - single failure (below threshold)", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - single failure (below threshold)"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["CardTestingGuard"]["FailConfirm"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Create Payment Intent - success attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Create Payment Intent - success attempt"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ cy.step("Confirm Payment - should succeed below threshold", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - should succeed below threshold"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ });++ cy.step("Disable card_testing_guard_config", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 100,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 100,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 2,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });+ });+ });++ context("Disable Card Testing Guard Config", () => {+ it("should not block payment when card_testing_guard is disabled", () => {+ let shouldContinue = true;++ cy.step("Disable all card_testing_guard mechanisms", () => {+ const updateBusinessProfileBody = {+ card_testing_guard_config: {+ card_ip_blocking_status: "disabled",+ card_ip_blocking_threshold: 3,+ guest_user_card_blocking_status: "disabled",+ guest_user_card_blocking_threshold: 2,+ customer_id_blocking_status: "disabled",+ customer_id_blocking_threshold: 2,+ card_testing_guard_expiry: 3600,+ },+ };+ cy.UpdateBusinessProfileTest(+ updateBusinessProfileBody,+ false, // is_connector_agnostic_enabled+ false, // collect_billing_address_from_wallet_connector+ false, // collect_shipping_address_from_wallet_connector+ false, // always_collect_billing_address_from_wallet_connector+ false, // always_collect_shipping_address_from_wallet_connector+ globalState+ );+ });++ cy.step(+ "Create Payment Intent - should succeed with guard disabled",+ () => {+ 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("Confirm Payment - should succeed with guard disabled", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Confirm Payment - should succeed with guard disabled"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);+ });+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 6efb241e07..b8a42c5c5b 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -2020,14 +2020,18 @@ Cypress.Commands.add(expect(createPaymentBody.email, "customer.email").to.equal(response.body.customer.email);- expect(createPaymentBody.customer_id, "customer.id").to.equal(- response.body.customer.id- );+ if (createPaymentBody.customer_id !== undefined) {+ expect(createPaymentBody.customer_id, "customer.id").to.equal(+ response.body.customer.id+ );+ } else {+ expect(response.body.customer.id, "customer.id").to.be.null;+ }expect(createPaymentBody.metadata, "metadata").to.deep.equal(response.body.metadata);expect(- createPaymentBody.setup_future_usage,+ createPaymentBody.setup_future_usage ?? null,"setup_future_usage").to.equal(response.body.setup_future_usage);// If 'shipping_cost' is not included in the request, the 'amount' in 'createPaymentBody' should match the 'amount_capturable' in the response.@@ -2181,7 +2185,7 @@ Cypress.Commands.add("createPaymentMethodTest", (globalState, data) => {response.body.payment_method);expect(response.body.last_used_at, "last_used_at").to.not.be.null;- expect(reqData.customer_id, "customer_id").to.equal(+ expect(reqData.customer_id ?? null, "customer_id").to.equal(response.body.customer_id);globalState.set("paymentMethodId", response.body.payment_method_id);@@ -2295,6 +2299,10 @@ Cypress.Commands.add(}}+ if (!reqData?.setup_future_usage && confirmBody.setup_future_usage) {+ delete confirmBody.setup_future_usage;+ }+if (reqData?.split_payments && isStripeConnect(globalState)) {confirmBody.split_payments = reqData.split_payments;}@@ -3124,7 +3132,7 @@ Cypress.Commands.add();}expect(response.body.customer_id).to.equal(- globalState.get("customerId")+ globalState.get("customerId") ?? null);if ([@@ -3170,7 +3178,7 @@ Cypress.Commands.add();}expect(response.body.customer_id).to.equal(- globalState.get("customerId")+ globalState.get("customerId") ?? null);} else {// Handle other authentication types as needed