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): BlockImplicitCustomerCreation for adyen (#13928)
HS-QUALIBOT5e186d6044b5
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.jsindex 10086255b5..bf944b316b 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js@@ -1151,6 +1151,36 @@ export const connectorDetails = {},},},+ BlockImplicitCustomerCreationAllowed: {+ Request: {+ currency: "EUR",+ amount: 6500,+ email: null,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ },+ BlockImplicitCustomerCreationBlocked: {+ Request: {+ currency: "EUR",+ amount: 6500,+ email: null,+ },+ Response: {+ status: 404,+ body: {+ error: {+ type: "invalid_request",+ code: "HE_02",+ message: "Customer does not exist in our records",+ },+ },+ },+ },},bank_transfer_pm: {Pix: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex d816392601..5050de369f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -4161,6 +4161,36 @@ export const connectorDetails = {},}),},+ BlockImplicitCustomerCreationAllowed: getCustomExchange({+ Request: {+ currency: "EUR",+ amount: 6500,+ email: null,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ }),+ BlockImplicitCustomerCreationBlocked: getCustomExchange({+ Request: {+ currency: "EUR",+ amount: 6500,+ email: null,+ },+ Response: {+ status: 404,+ body: {+ error: {+ type: "invalid_request",+ code: "HE_02",+ message: "Customer does not exist in our records",+ },+ },+ },+ }),},upi_pm: {PaymentIntent: getCustomExchange({diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex fc828d70fc..13d835f8f8 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -814,6 +814,7 @@ export const CONNECTOR_LISTS = {CLIENT_SESSION_VALIDATION: ["stripe"],WEBHOOK_CONFIG: ["stripe"],REQUIRES_CVV: ["bankofamerica"],+ BLOCK_IMPLICIT_CUSTOMER_CREATION: ["adyen"],// Add more inclusion lists},};diff --git a/cypress-tests/cypress/e2e/spec/Payment/54-BlockImplicitCustomerCreation.cy.js b/cypress-tests/cypress/e2e/spec/Payment/54-BlockImplicitCustomerCreation.cy.jsnew file mode 100644index 0000000000..328a068d6e--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/54-BlockImplicitCustomerCreation.cy.js@@ -0,0 +1,214 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Block Implicit Customer Creation", () => {+ let specShouldSkip = false;++ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ const connectorId = globalState.get("connectorId");+ specShouldSkip = utils.shouldIncludeConnector(+ connectorId,+ utils.CONNECTOR_LISTS.INCLUDE.BLOCK_IMPLICIT_CUSTOMER_CREATION+ );+ if (+ !globalState.get("superpositionBaseUrl") ||+ !globalState.get("superpositionSecret")+ ) {+ cy.task(+ "cli_log",+ "Superposition credentials not set — skipping BlockImplicitCustomerCreation spec"+ );+ specShouldSkip = true;+ }+ });+ });++ beforeEach(function () {+ if (specShouldSkip) {+ this.skip();+ }+ });++ after("cleanup superposition config + flush global state", () => {+ cy.setSuperpositionConfig(+ globalState,+ "block_implicit_customer_creation",+ false,+ {+ organization_id: globalState.get("organizationId"),+ }+ );+ cy.task("setGlobalState", globalState.data);+ });++ context("Implicit customer creation allowed (default behavior)", () => {+ it("create payment with non-existent customer_id — verify implicit creation", () => {+ let shouldContinue = true;++ cy.step("Set non-existent customer_id in globalState", () => {+ globalState.set("customerId", `non_existent_customer_${Date.now()}`);+ });++ cy.step(+ "Create payment intent (expect 200, requires_payment_method)",+ () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Create payment intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["BlockImplicitCustomerCreationAllowed"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ }+ );++ cy.step("Retrieve customer — verify created (expect 200)", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve customer");+ return;+ }+ cy.customerRetrieveCall(globalState, 200);+ });+ });+ });++ context("Block implicit customer creation via superposition config", () => {+ it("set block config, create payment with non-existent customer (expect 404), verify customer not created", () => {+ const shouldContinue = true;++ cy.step(+ "Set block_implicit_customer_creation=true via superposition",+ () => {+ cy.setSuperpositionConfig(+ globalState,+ "block_implicit_customer_creation",+ true,+ {+ organization_id: globalState.get("organizationId"),+ }+ );+ }+ );++ cy.step("Wait for config propagation (poll until 404)", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Wait for config propagation");+ return;+ }+ cy.waitForConfigPropagation(globalState, 404, "block");+ });++ cy.step(+ "Create payment with non-existent customer_id (expect 404 HE_02)",+ () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Create payment");+ return;+ }+ globalState.set("customerId", `non_existent_customer_${Date.now()}`);+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["BlockImplicitCustomerCreationBlocked"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ // Do NOT call should_continue_further — 404 is expected,+ // retrieve must still run to verify customer was not created+ }+ );++ cy.step("Retrieve customer — verify not created (expect 404)", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve customer");+ return;+ }+ cy.customerRetrieveCall(globalState, 404);+ });+ });+ });++ context(+ "Restore default behavior after resetting superposition config",+ () => {+ it("reset block config, create payment with non-existent customer (expect 200), verify customer created", () => {+ let shouldContinue = true;++ cy.step(+ "Reset block_implicit_customer_creation to false via superposition",+ () => {+ cy.setSuperpositionConfig(+ globalState,+ "block_implicit_customer_creation",+ false,+ {+ organization_id: globalState.get("organizationId"),+ }+ );+ }+ );++ cy.step("Wait for config propagation (poll until 200)", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Wait for config propagation");+ return;+ }+ cy.waitForConfigPropagation(globalState, 200, "allow");+ });++ cy.step(+ "Create payment with non-existent customer_id (expect 200, requires_payment_method)",+ () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Create payment");+ return;+ }+ globalState.set(+ "customerId",+ `non_existent_customer_${Date.now()}`+ );+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["BlockImplicitCustomerCreationAllowed"];+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ }+ );++ cy.step("Retrieve customer — verify created (expect 200)", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve customer");+ return;+ }+ cy.customerRetrieveCall(globalState, 200);+ });+ });+ }+ );+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 97e6567cf2..4a7860bfa3 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -12006,6 +12006,57 @@ Cypress.Commands.add(});+// Wait for a superposition config change to propagate to the router.+// Polls payment creation with throwaway customer_ids until the response status+// matches `expectedStatus` (e.g. 404 while block_implicit_customer_creation is+// propagating, 200 after it is reset). `label` prefixes the throwaway customer ids.+Cypress.Commands.add(+ "waitForConfigPropagation",+ (globalState, expectedStatus, label) => {+ const maxAttempts = 60;+ const intervalMs = 5000;+ const poll = (attempt) => {+ if (attempt >= maxAttempts) {+ throw new Error(+ `Superposition config did not propagate within ${(maxAttempts * intervalMs) / 1000}s`+ );+ }+ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments`,+ headers: {+ "api-key": globalState.get("apiKey"),+ "Content-Type": "application/json",+ },+ body: {+ currency: "USD",+ amount: 100,+ customer_id: `config_poll_${label}_${Date.now()}_${attempt}`,+ authentication_type: "no_three_ds",+ capture_method: "automatic",+ profile_id: globalState.get("profileId"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ if (response.status === expectedStatus) {+ cy.task(+ "cli_log",+ `Config propagated after ${attempt + 1} poll attempt(s)`+ );+ } else {+ cy.task(+ "cli_log",+ `Poll attempt ${attempt + 1}: got ${response.status}, waiting ${intervalMs / 1000}s...`+ );+ // eslint-disable-next-line cypress/no-unnecessary-waiting+ cy.wait(intervalMs).then(() => poll(attempt + 1));+ }+ });+ };+ poll(0);+ }+);+// Delete a superposition config context.// `context` must match the dimensions used when the override was created.Cypress.Commands.add("deleteSuperpositionConfig", (globalState, context) => {