diff --git a/cypress-tests/cypress/e2e/configs/Payment/Dwolla.js b/cypress-tests/cypress/e2e/configs/Payment/Dwolla.js new file mode 100644 index 0000000000..af1bf2a10f --- /dev/null +++ b/cypress-tests/cypress/e2e/configs/Payment/Dwolla.js @@ -0,0 +1,126 @@ +const ach_bank_debit_data = { + account_number: "123456789", + routing_number: "110000000", + bank_account_holder_name: "Test User", + bank_type: "checking", + bank_holder_type: "personal", + billing: { + address: { + first_name: "Test", + last_name: "User", + line1: "123 Test St", + city: "San Francisco", + state: "CA", + zip: "94122", + country: "US", + }, + email: "test@example.com", + }, +}; + +const billing_data = { + address: { + first_name: "Test", + last_name: "User", + line1: "123 Test St", + city: "San Francisco", + state: "CA", + zip: "94122", + country: "US", + }, + email: "test@example.com", +}; + +const ir04_error = { + type: "invalid_request", + message: "Missing required param: connector_customer_id", + code: "IR_04", +}; + +export const connectorDetails = { + bank_debit_pm: { + PaymentIntent: (paymentMethodType) => { + if (paymentMethodType !== "Ach") { + return { + Configs: { + TRIGGER_SKIP: true, + }, + }; + } + return { + Request: { + currency: "USD", + setup_future_usage: "off_session", + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }; + }, + Ach: { + Request: { + payment_method: "bank_debit", + payment_method_type: "ach", + payment_method_data: { + bank_debit: { + ach_bank_debit: ach_bank_debit_data, + }, + }, + billing: billing_data, + }, + Response: { + status: 400, + body: { + error: ir04_error, + }, + }, + }, + AchDirectConfirm: { + Request: { + currency: "USD", + payment_method: "bank_debit", + payment_method_type: "ach", + payment_method_data: { + bank_debit: { + ach_bank_debit: ach_bank_debit_data, + }, + }, + billing: billing_data, + }, + Response: { + status: 400, + body: { + error: ir04_error, + }, + }, + }, + AchWithConnectorCustomerId: { + Request: { + currency: "USD", + payment_method: "bank_debit", + payment_method_type: "ach", + payment_method_data: { + bank_debit: { + ach_bank_debit: ach_bank_debit_data, + }, + }, + billing: billing_data, + connector_customer_id: "f338b9dc-af90-4022-9157-0ab5459ee20a", + }, + Response: { + status: 400, + body: { + error: { + error_type: "invalid_request", + message: + "Json deserialize error: unknown field `connector_customer_id`", + code: "IR_06", + }, + }, + }, + }, + }, +}; diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js index 6b2cfdc956..68e2e400ec 100644 --- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js +++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js @@ -83,6 +83,7 @@ import { connectorDetails as worldpayxmlConnectorDetails } from "./Worldpayxml.j import { connectorDetails as xenditConnectorDetails } from "./Xendit.js"; import { connectorDetails as ziftConnectorDetails } from "./Zift.js"; import { connectorDetails as mifinityConnectorDetails } from "./Mifinity.js"; +import { connectorDetails as dwollaConnectorDetails } from "./Dwolla.js"; const connectorDetails = { aci: aciConnectorDetails, adyen: adyenConnectorDetails, @@ -165,6 +166,7 @@ const connectorDetails = { zift: ziftConnectorDetails, loonio: loonioConnectorDetails, mifinity: mifinityConnectorDetails, + dwolla: dwollaConnectorDetails, }; /** @@ -604,6 +606,7 @@ export const CONNECTOR_LISTS = { "stripe", "wellsfargo", ], // payload verified as working + BANK_DEBIT_ERROR_PATH: ["dwolla"], BANK_REDIRECT_BANCONTACT: ["adyen", "stripe"], BANK_REDIRECT_MANDATE: ["adyen"], BLUECODE_WALLET: ["calida"], diff --git a/cypress-tests/cypress/e2e/spec/Payment/55-DwollaAchErrorPath.cy.js b/cypress-tests/cypress/e2e/spec/Payment/55-DwollaAchErrorPath.cy.js new file mode 100644 index 0000000000..815ad6f16f --- /dev/null +++ b/cypress-tests/cypress/e2e/spec/Payment/55-DwollaAchErrorPath.cy.js @@ -0,0 +1,138 @@ +import * as fixtures from "../../../fixtures/imports"; +import State from "../../../utils/State"; +import getConnectorDetails, { + CONNECTOR_LISTS, + shouldIncludeConnector, +} from "../../configs/Payment/Utils"; +import * as utils from "../../configs/Payment/Utils"; + +let globalState; + +describe("ACH Bank Debit Error Path tests", () => { + before("seed global state", function () { + let skip = false; + + cy.task("getGlobalState") + .then((state) => { + globalState = new State(state); + + if ( + shouldIncludeConnector( + globalState.get("connectorId"), + CONNECTOR_LISTS.INCLUDE.BANK_DEBIT_ERROR_PATH + ) + ) { + skip = true; + } + }) + .then(() => { + if (skip) { + this.skip(); + } + }); + }); + + afterEach("flush global state", () => { + cy.task("setGlobalState", globalState.data); + }); + + context("ACH Bank Debit Create + Confirm Error Path", () => { + it("Create Payment Intent -> List Payment Methods -> Confirm ACH Bank Debit (expect IR_04) -> Retrieve (skipped)", () => { + let shouldContinue = true; + + cy.step("Create Payment Intent for ACH", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "bank_debit_pm" + ]["PaymentIntent"]("Ach"); + cy.createPaymentIntentTest( + fixtures.createPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + if (!utils.should_continue_further(data)) { + shouldContinue = false; + } + }); + + cy.step("List Merchant Payment Methods", () => { + if (!shouldContinue) { + cy.task("cli_log", "Skipping step: List Merchant Payment Methods"); + return; + } + cy.paymentMethodsCallTest(globalState); + }); + + cy.step("Confirm ACH Bank Debit", () => { + if (!shouldContinue) { + cy.task("cli_log", "Skipping step: Confirm ACH Bank Debit"); + return; + } + const confirmData = getConnectorDetails(globalState.get("connectorId"))[ + "bank_debit_pm" + ]["Ach"]; + cy.confirmCallTest( + fixtures.confirmBody, + confirmData, + true, + globalState + ); + if (!utils.should_continue_further(confirmData)) { + shouldContinue = false; + } + }); + + cy.step("Retrieve Payment", () => { + if (!shouldContinue) { + cy.task("cli_log", "Skipping step: Retrieve Payment"); + return; + } + const confirmData = getConnectorDetails(globalState.get("connectorId"))[ + "bank_debit_pm" + ]["Ach"]; + cy.retrievePaymentCallTest({ globalState, data: confirmData }); + }); + }); + }); + + context("ACH Bank Debit Direct Create+Confirm Error Path", () => { + it("Create+Confirm Payment with ACH Bank Debit directly (expect IR_04)", () => { + cy.step("Create+Confirm ACH Bank Debit Payment", () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "bank_debit_pm" + ]["AchDirectConfirm"]; + cy.createConfirmPaymentTest( + fixtures.createConfirmPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + }); + }); + }); + + context( + "ACH Bank Debit with connector_customer_id in body (negative case)", + () => { + it("Create+Confirm Payment with connector_customer_id (expect IR_06 unknown field)", () => { + cy.step( + "Create+Confirm ACH Bank Debit with connector_customer_id", + () => { + const data = getConnectorDetails(globalState.get("connectorId"))[ + "bank_debit_pm" + ]["AchWithConnectorCustomerId"]; + cy.createConfirmPaymentTest( + fixtures.createConfirmPaymentBody, + data, + "no_three_ds", + "automatic", + globalState + ); + } + ); + }); + } + ); +});