Skip to content

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

test(cypress): add payout pre-FRM coverage for sanlam_payshield + gotyme_sanlam (#14432)

HS-QUALIBOTaaa7f1ef38d6
diff --git a/cypress-tests/cypress/e2e/configs/Payout/GotymeSanlam.js b/cypress-tests/cypress/e2e/configs/Payout/GotymeSanlam.js
index d5a2f09521..2100160c49 100644
--- a/cypress-tests/cypress/e2e/configs/Payout/GotymeSanlam.js
+++ b/cypress-tests/cypress/e2e/configs/Payout/GotymeSanlam.js
@@ -76,6 +76,144 @@ export const connectorDetails = {
},
},
},
+ /*
+ * FRM (pre-FRM) scenarios for the sanlam_payshield -> gotyme_sanlam
+ * payout chain (see cypress/e2e/spec/Payout/00009-PayoutFrm.cy.js).
+ * The Payshield sandbox flags an amount over 1,000,000 cents as fraud;
+ * frm_message details (frm_status, frm_score, frm_error) are asserted
+ * separately via cy.verifyPayoutFrmDetails since they contain
+ * non-deterministic ids and can't be part of a fixed deep-equal
+ * Response body.
+ *
+ * These scenarios run create+confirm in a single call, so
+ * payout_method_data has to be present on the request (unlike the
+ * two-step `payshap` scenario above, where it's only added on Confirm).
+ * As with `payshap`, only payout_method_type is declared here — the
+ * actual bank account fields are injected at request time by
+ * injectGotymePayoutBankTransfer (see the file-level comment above).
+ */
+ // These frm_* scenarios run create+confirm in a single call (no
+ // separate Confirm/Fulfill step), so Request/Response sit directly on
+ // the scenario instead of nested under a Create key.
+ frm_legit: {
+ Request: {
+ amount: 1000,
+ currency: "ZAR",
+ payout_type: "bank",
+ description: "Test Payout",
+ payout_method_data: {
+ bank_transfer: {
+ payout_method_type: "payshap",
+ },
+ },
+ billing: billing,
+ },
+ Response: {
+ status: 200,
+ body: {
+ payout_type: "bank",
+ status: "initiated",
+ connector: "gotyme_sanlam",
+ },
+ },
+ // Asserted via cy.verifyPayoutFrmDetails against a follow-up GET, since
+ // frm_message carries non-deterministic ids and can't be part of the
+ // fixed deep-equal Response.body above.
+ FrmDetails: {
+ frm_message: { frm_name: "sanlam_payshield", frm_status: "legit" },
+ status: "initiated",
+ connector: "gotyme_sanlam",
+ },
+ },
+ frm_fraud: {
+ Request: {
+ amount: 10000000,
+ currency: "ZAR",
+ payout_type: "bank",
+ description: "Test Payout",
+ payout_method_data: {
+ bank_transfer: {
+ payout_method_type: "payshap",
+ },
+ },
+ billing: billing,
+ },
+ Response: {
+ status: 200,
+ body: {
+ payout_type: "bank",
+ connector: null,
+ merchant_connector_id: null,
+ status: "failed",
+ error_code: "fraud",
+ },
+ },
+ FrmDetails: {
+ status: "failed",
+ error_code: "fraud",
+ connector: null,
+ frm_message: { frm_status: "fraud" },
+ greaterThan: { "frm_message.frm_score": 0 },
+ },
+ },
+ frm_transaction_failure_fail_closed: {
+ Request: {
+ amount: 1000,
+ currency: "ZAR",
+ payout_type: "bank",
+ description: "Test Payout",
+ payout_method_data: {
+ bank_transfer: {
+ payout_method_type: "payshap",
+ },
+ },
+ billing: billing,
+ },
+ Response: {
+ status: 200,
+ body: {
+ payout_type: "bank",
+ connector: null,
+ merchant_connector_id: null,
+ status: "failed",
+ error_code: "transaction_failure",
+ },
+ },
+ FrmDetails: {
+ status: "failed",
+ error_code: "transaction_failure",
+ connector: null,
+ frm_message: { frm_status: "transaction_failure" },
+ },
+ },
+ frm_transaction_failure_fail_open: {
+ Request: {
+ amount: 1000,
+ currency: "ZAR",
+ payout_type: "bank",
+ description: "Test Payout",
+ payout_method_data: {
+ bank_transfer: {
+ payout_method_type: "payshap",
+ },
+ },
+ billing: billing,
+ },
+ Response: {
+ status: 200,
+ body: {
+ payout_type: "bank",
+ status: "initiated",
+ connector: "gotyme_sanlam",
+ },
+ },
+ FrmDetails: {
+ status: "initiated",
+ connector: "gotyme_sanlam",
+ frm_message: { frm_status: "transaction_failure" },
+ notEqual: { error_code: "transaction_failure" },
+ },
+ },
payshap_proxy: {
Create: {
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
index da9b76d149..f6e9958d06 100644
--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
@@ -120,6 +120,9 @@ export const CONNECTOR_LISTS = {
BANK_TRANSFER_OPEN_BANKING_NO_BILLING: ["trustly"],
BANK_TRANSFER_PAYSHAP: ["gotyme_sanlam"],
BANK_TRANSFER_PAYSHAP_PROXY: ["gotyme_sanlam"],
+ // Payout FRM (sanlam_payshield pre-FRM gating gotyme_sanlam payouts) -
+ // only verified connector pairing
+ PAYOUT_FRM: ["gotyme_sanlam"],
BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],
SAVED_CARD: ["adyen", "adyenplatform", "nomupay", "wise"],
SAVED_BANK_TRANSFER_SEPA: ["adyen", "adyenplatform", "nomupay", "wise"],
diff --git a/cypress-tests/cypress/e2e/spec/Payout/00009-PayoutFrm.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00009-PayoutFrm.cy.js
new file mode 100644
index 0000000000..dd54af7e84
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payout/00009-PayoutFrm.cy.js
@@ -0,0 +1,257 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import * as utils from "../../configs/Payout/Utils";
+
+let globalState;
+
+// Coverage for pre-FRM support on payouts (PR #14189): a payout routed
+// through gotyme_sanlam is gated by a pre-FRM call to the sanlam_payshield
+// FRM connector before the payout connector is ever invoked. Mirrors the
+// scenario matrix from the PR's own manual verification:
+// Legit / Fraud / TransactionFailure(4xx) x FailOpen / FailClosed.
+//
+// payouts.payout_frm_call is disabled by default and gated behind
+// Superposition, same as frm.pre_frm_failure_mode, so both are toggled here
+// via the existing cy.setSuperpositionConfig infrastructure.
+describe("[Payout] [FRM - Pre-FRM with Payshield]", () => {
+ let shouldContinue = true;
+
+ before("seed global state", function () {
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+
+ if (!globalState.get("payoutsExecution")) {
+ shouldContinue = false;
+ }
+
+ if (
+ !utils.CONNECTOR_LISTS.INCLUDE.PAYOUT_FRM.includes(
+ globalState.get("connectorId")
+ )
+ ) {
+ shouldContinue = false;
+ }
+ })
+ .then(() => {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+ });
+
+ after("cleanup configs + flush global state", () => {
+ cy.deleteSuperpositionConfig(globalState, {
+ provider_merchant_id: globalState.get("merchantId"),
+ processor_merchant_id: globalState.get("merchantId"),
+ profile_id: globalState.get("profileId"),
+ });
+ cy.deleteFrmConnector(globalState);
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ context("[Payout FRM] Setup", () => {
+ it("create-frm-connector-sanlam-payshield", () => {
+ cy.createNamedConnectorCallTest(
+ "payment_vas",
+ fixtures.createConnectorBody,
+ {},
+ globalState,
+ "sanlam_payshield",
+ "sanlam_payshield_frm",
+ "profile",
+ "frmConnector",
+ "bank_transfer"
+ );
+ });
+
+ it("set-frm-routing-algorithm", () => {
+ cy.setFrmRoutingAlgorithm(
+ { frm_routing_algorithm: { type: "single", data: "sanlam_payshield" } },
+ globalState
+ );
+ });
+
+ it("enable-payout-frm-call-via-superposition", () => {
+ cy.setSuperpositionConfig(globalState, "payouts.payout_frm_call", true, {
+ provider_merchant_id: globalState.get("merchantId"),
+ processor_merchant_id: globalState.get("merchantId"),
+ profile_id: globalState.get("profileId"),
+ });
+ });
+ });
+
+ context("[Payout FRM] Legit — FRM passes, payout proceeds", () => {
+ let contextShouldContinue = true;
+
+ beforeEach(function () {
+ if (!contextShouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("payout-create-confirm-auto-fulfill-legit", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_legit"];
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ scenario,
+ true,
+ true,
+ globalState
+ );
+ if (contextShouldContinue)
+ contextShouldContinue = utils.should_continue_further(scenario);
+ });
+
+ it("verify frm_status is legit", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_legit"];
+
+ cy.verifyPayoutFrmDetails(globalState, scenario["FrmDetails"]);
+ });
+ });
+
+ context("[Payout FRM] Fraud — FRM blocks before the payout connector", () => {
+ const contextShouldContinue = true;
+
+ beforeEach(function () {
+ if (!contextShouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("payout-create-confirm-auto-fulfill-fraud", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_fraud"];
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ scenario,
+ true,
+ true,
+ globalState
+ );
+ });
+
+ it("verify frm_status is fraud and connector was never called", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_fraud"];
+
+ cy.verifyPayoutFrmDetails(globalState, scenario["FrmDetails"]);
+ });
+ });
+
+ context(
+ "[Payout FRM] Transaction Failure (4xx from Payshield) — FailClosed blocks",
+ () => {
+ it("break sanlam_payshield credentials", () => {
+ cy.breakFrmConnectorCredentials(globalState);
+ });
+
+ it("set pre_frm_failure_mode=fail_closed via superposition", () => {
+ cy.setSuperpositionConfig(
+ globalState,
+ "frm.pre_frm_failure_mode",
+ "fail_closed",
+ {
+ provider_merchant_id: globalState.get("merchantId"),
+ processor_merchant_id: globalState.get("merchantId"),
+ profile_id: globalState.get("profileId"),
+ }
+ );
+ });
+
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("payout-create-confirm-auto-fulfill-fail-closed", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_transaction_failure_fail_closed"];
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ scenario,
+ true,
+ true,
+ globalState
+ );
+ });
+
+ it("verify payout blocked with transaction_failure", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_transaction_failure_fail_closed"];
+
+ cy.verifyPayoutFrmDetails(globalState, scenario["FrmDetails"]);
+ });
+ }
+ );
+
+ context(
+ "[Payout FRM] Transaction Failure (4xx from Payshield) — FailOpen proceeds",
+ () => {
+ // sanlam_payshield credentials are already broken from the FailClosed
+ // context above; only the failure mode changes here.
+ it("set pre_frm_failure_mode=fail_open via superposition", () => {
+ cy.setSuperpositionConfig(
+ globalState,
+ "frm.pre_frm_failure_mode",
+ "fail_open",
+ {
+ provider_merchant_id: globalState.get("merchantId"),
+ processor_merchant_id: globalState.get("merchantId"),
+ profile_id: globalState.get("profileId"),
+ }
+ );
+ });
+
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("payout-create-confirm-auto-fulfill-fail-open", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_transaction_failure_fail_open"];
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ scenario,
+ true,
+ true,
+ globalState
+ );
+ });
+
+ it("verify FRM failure did not block the payout", () => {
+ const scenario = utils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["frm_transaction_failure_fail_open"];
+
+ cy.verifyPayoutFrmDetails(globalState, scenario["FrmDetails"]);
+ });
+ }
+ );
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index aec1271376..37b32ac9d9 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -1690,7 +1690,8 @@ Cypress.Commands.add(
connectorName,
connectorLabel,
profilePrefix = "profile",
- mcaPrefix = "merchantConnector"
+ mcaPrefix = "merchantConnector",
+ frmPaymentMethod = "card"
) => {
const merchantId = globalState.get("merchantId");
const profileId = globalState.get(`${profilePrefix}Id`);
@@ -1709,7 +1710,7 @@ Cypress.Commands.add(
gateway: getOriginalConnectorName(globalState.get("connectorId")),
payment_methods: [
{
- payment_method: "card",
+ payment_method: frmPaymentMethod,
flow: "pre",
},
],
@@ -2381,6 +2382,35 @@ Cypress.Commands.add("setFrmRoutingAlgorithm", (body, globalState) => {
});
});
+// Overwrites the FRM connector's account details with an invalid api_key, to
+// force the FRM connector itself to fail (4xx) - used to test
+// fail_open/fail_closed behavior when pre-FRM is unreachable.
+Cypress.Commands.add("breakFrmConnectorCredentials", (globalState) => {
+ const mcaUrl = `${globalState.get("baseUrl")}/account/${globalState.get("merchantId")}/connectors/${globalState.get("frmConnectorId")}`;
+
+ return cy
+ .request({
+ method: "POST",
+ url: mcaUrl,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("apiKey"),
+ },
+ body: {
+ connector_type: "payment_vas",
+ connector_account_details: {
+ auth_type: "HeaderKey",
+ api_key: "invalid_key_to_force_frm_failure",
+ },
+ },
+ })
+ .then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+ expect(response.status).to.equal(200);
+ return cy.wrap(response);
+ });
+});
+
Cypress.Commands.add("deleteFrmConnector", (globalState) => {
const frmMcaId = globalState.get("frmConnectorId");
@@ -7979,6 +8009,54 @@ Cypress.Commands.add(
}
);
+// Fetches the current payout and asserts against an `expected` shape:
+// - top-level or one-level-nested (e.g. `frm_message.frm_status`) keys are
+// compared with `.to.equal`
+// - `expected.greaterThan` / `expected.notEqual` take dotted paths for the
+// handful of non-deterministic/negative checks (e.g. `frm_message.frm_score`)
+// that a plain equality can't express.
+// Centralizes the pre-FRM payout assertions used across
+// `Payout/00009-PayoutFrm.cy.js` so scenario-specific expectations live in
+// connector configs (e.g. `GotymeSanlam.js`) instead of the spec file.
+Cypress.Commands.add("verifyPayoutFrmDetails", (globalState, expected = {}) => {
+ const getByPath = (obj, path) =>
+ path.split(".").reduce((value, key) => value?.[key], obj);
+
+ cy.request({
+ method: "GET",
+ url: `${globalState.get("baseUrl")}/payouts/${globalState.get("payoutID")}`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("apiKey"),
+ },
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+ Object.entries(expected).forEach(([key, value]) => {
+ if (key === "greaterThan") {
+ Object.entries(value).forEach(([path, threshold]) => {
+ expect(getByPath(response.body, path)).to.be.greaterThan(threshold);
+ });
+ return;
+ }
+
+ if (key === "notEqual") {
+ Object.entries(value).forEach(([path, notExpected]) => {
+ expect(getByPath(response.body, path)).to.not.equal(notExpected);
+ });
+ return;
+ }
+
+ if (value !== null && typeof value === "object") {
+ Object.entries(value).forEach(([nestedKey, nestedValue]) => {
+ expect(response.body[key]?.[nestedKey]).to.equal(nestedValue);
+ });
+ } else {
+ expect(response.body[key]).to.equal(value);
+ }
+ });
+ });
+});
+
Cypress.Commands.add("retrievePayoutCallTest", (globalState, data) => {
const payout_id = globalState.get("payoutID");
const resBody = data?.Response?.body || {};