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 routing coverage for adyen (#12240)

HS-QUALIBOTdfd8464ed48e
diff --git a/cypress-tests/cypress/e2e/configs/Routing/Commons.js b/cypress-tests/cypress/e2e/configs/Routing/Commons.js
index d624bb7dc4..2ad0702915 100644
--- a/cypress-tests/cypress/e2e/configs/Routing/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Routing/Commons.js
@@ -1,4 +1,76 @@
export const connectorDetails = {
+ payoutRouting: {
+ Request: {
+ name: "payout routing",
+ description: "payout routing config",
+ algorithm: {
+ type: "priority",
+ data: [],
+ },
+ profile_id: "{{profile_id}}",
+ transaction_type: "payout",
+ },
+ Response: {
+ status: 200,
+ body: {
+ algorithm_for: "payout",
+ },
+ },
+ },
+ payoutVolumeRouting: {
+ Request: {
+ name: "payout volume routing",
+ description: "payout volume based routing config",
+ algorithm: {
+ type: "volume_split",
+ data: [],
+ },
+ profile_id: "{{profile_id}}",
+ transaction_type: "payout",
+ },
+ Response: {
+ status: 200,
+ body: {
+ algorithm_for: "payout",
+ },
+ },
+ },
+ payoutRuleBasedRouting: {
+ Request: {
+ name: "payout rule based routing",
+ description: "payout rule based routing config",
+ algorithm: {
+ type: "advanced",
+ data: [],
+ },
+ profile_id: "{{profile_id}}",
+ transaction_type: "payout",
+ },
+ Response: {
+ status: 200,
+ body: {
+ algorithm_for: "payout",
+ },
+ },
+ },
+ payoutDefaultFallbackRouting: {
+ Request: {
+ name: "payout default fallback routing",
+ description: "payout default fallback routing config",
+ algorithm: {
+ type: "advanced",
+ data: [],
+ },
+ profile_id: "{{profile_id}}",
+ transaction_type: "payout",
+ },
+ Response: {
+ status: 200,
+ body: {
+ algorithm_for: "payout",
+ },
+ },
+ },
priorityRouting: {
Request: {
name: "priority routing",
diff --git a/cypress-tests/cypress/e2e/configs/Routing/Utils.js b/cypress-tests/cypress/e2e/configs/Routing/Utils.js
index a661c5d499..cd6c974f90 100644
--- a/cypress-tests/cypress/e2e/configs/Routing/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Routing/Utils.js
@@ -39,3 +39,13 @@ export const should_continue_further = (data) => {
return true;
}
};
+
+export const CONNECTOR_LISTS = {
+ INCLUDE: {
+ PAYOUT_ROUTING: ["adyenplatform", "wise"],
+ },
+};
+
+export const shouldRunForConnectorList = (connectorId, list) => {
+ return list.includes(connectorId);
+};
diff --git a/cypress-tests/cypress/e2e/spec/Routing/00010-PayoutRouting.cy.js b/cypress-tests/cypress/e2e/spec/Routing/00010-PayoutRouting.cy.js
new file mode 100644
index 0000000000..4a808eaea1
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Routing/00010-PayoutRouting.cy.js
@@ -0,0 +1,524 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import * as routingUtils from "../../configs/Routing/Utils";
+import * as payoutUtils from "../../configs/Payout/Utils";
+
+let globalState;
+
+describe("Payout Priority Routing Test", () => {
+ let shouldContinue = true;
+ let outerGuardPassed = true;
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ if (
+ !routingUtils.shouldRunForConnectorList(
+ globalState.get("connectorId"),
+ routingUtils.CONNECTOR_LISTS.INCLUDE.PAYOUT_ROUTING
+ )
+ ) {
+ shouldContinue = false;
+ outerGuardPassed = false;
+ }
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ context("Payout Priority Routing - default connector", () => {
+ before("setup payout context", () => {
+ if (outerGuardPassed) {
+ shouldContinue = true;
+ }
+ cy.ListMcaByMid(globalState);
+ });
+
+ it("add-payout-routing-config", () => {
+ const data = routingUtils.getConnectorDetails("common")["payoutRouting"];
+ // Use currentConnectorMcaId which is reliably set to the first payout connector
+ // This works regardless of which specific connector (stripe/adyen/wise) is configured
+ const routing_data = [
+ {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get("currentConnectorMcaId"),
+ },
+ ];
+ cy.addRoutingConfig(
+ fixtures.payoutRoutingConfigBody,
+ data,
+ "priority",
+ routing_data,
+ globalState
+ );
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-routing-config-test", () => {
+ const data = routingUtils.getConnectorDetails("common")["payoutRouting"];
+
+ cy.retrieveRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("activate-payout-routing-config-test", () => {
+ const data = routingUtils.getConnectorDetails("common")["payoutRouting"];
+
+ cy.activateRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("payout-routing-test", () => {
+ const payoutData = payoutUtils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["sepa_bank_transfer"]["Fulfill"];
+
+ if (!payoutUtils.should_continue_further(payoutData)) {
+ cy.log(
+ "Skipping payout creation for " + globalState.get("connectorId")
+ );
+ shouldContinue = false;
+ return;
+ }
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ payoutData,
+ true,
+ true,
+ globalState
+ );
+
+ cy.verifyPayoutRoutingConnector(globalState);
+
+ if (shouldContinue)
+ shouldContinue = payoutUtils.should_continue_further(payoutData);
+ });
+
+ it("retrieve-payout-call-test", () => {
+ if (!shouldContinue) {
+ return;
+ }
+ cy.retrievePayoutCallTest(globalState);
+ });
+ });
+
+ context("Payout Priority Routing - single connector alternate config", () => {
+ // Context for testing a second payout routing configuration
+ // Tests that multiple routing configs can coexist with different priorities
+
+ before("setup alternate payout context", () => {
+ if (outerGuardPassed) {
+ shouldContinue = true;
+ }
+ cy.ListMcaByMid(globalState);
+ });
+
+ it("add-payout-routing-config-alternate", () => {
+ const data = routingUtils.getConnectorDetails("common")["payoutRouting"];
+ // Create an alternate configuration with same connector to validate
+ // that multiple payout routing configs can be managed independently
+ const routing_data = [
+ {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get("currentConnectorMcaId"),
+ },
+ ];
+
+ cy.addRoutingConfig(
+ fixtures.payoutRoutingConfigBody,
+ data,
+ "priority",
+ routing_data,
+ globalState
+ );
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-routing-config-alternate-test", () => {
+ const data = routingUtils.getConnectorDetails("common")["payoutRouting"];
+
+ cy.retrieveRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("activate-payout-routing-config-alternate-test", () => {
+ const data = routingUtils.getConnectorDetails("common")["payoutRouting"];
+
+ cy.activateRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("payout-routing-alternate-test", () => {
+ const payoutData = payoutUtils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["sepa_bank_transfer"]["Fulfill"];
+
+ if (!payoutUtils.should_continue_further(payoutData)) {
+ cy.log(
+ "Skipping payout creation for " + globalState.get("connectorId")
+ );
+ shouldContinue = false;
+ return;
+ }
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ payoutData,
+ true,
+ true,
+ globalState
+ );
+
+ cy.verifyPayoutRoutingConnector(globalState);
+
+ if (shouldContinue)
+ shouldContinue = payoutUtils.should_continue_further(payoutData);
+ });
+
+ it("retrieve-payout-alternate-call-test", () => {
+ if (!shouldContinue) {
+ return;
+ }
+ cy.retrievePayoutCallTest(globalState);
+ });
+ });
+
+ context("Payout Volume Based Routing", () => {
+ before("setup volume routing context", () => {
+ if (outerGuardPassed) {
+ shouldContinue = true;
+ }
+ cy.ListMcaByMid(globalState);
+ });
+
+ it("add-payout-volume-routing-config", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")["payoutVolumeRouting"];
+ const routing_data = [
+ {
+ connector: {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get("currentConnectorMcaId"),
+ },
+ split: 100,
+ },
+ ];
+ cy.addRoutingConfig(
+ fixtures.payoutRoutingConfigBody,
+ data,
+ "volume_split",
+ routing_data,
+ globalState
+ );
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-volume-routing-config-test", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")["payoutVolumeRouting"];
+
+ cy.retrieveRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("activate-payout-volume-routing-config-test", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")["payoutVolumeRouting"];
+
+ cy.activateRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("payout-volume-routing-test", () => {
+ const payoutData = payoutUtils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["sepa_bank_transfer"]["Fulfill"];
+
+ if (!payoutUtils.should_continue_further(payoutData)) {
+ cy.log(
+ "Skipping payout creation for " + globalState.get("connectorId")
+ );
+ shouldContinue = false;
+ return;
+ }
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ payoutData,
+ true,
+ true,
+ globalState
+ );
+
+ cy.verifyPayoutRoutingConnector(globalState);
+
+ if (shouldContinue)
+ shouldContinue = payoutUtils.should_continue_further(payoutData);
+ });
+
+ it("retrieve-payout-volume-call-test", () => {
+ if (!shouldContinue) {
+ return;
+ }
+ cy.retrievePayoutCallTest(globalState);
+ });
+ });
+
+ context("Payout Rule Based Routing", () => {
+ before("setup rule routing context", () => {
+ if (outerGuardPassed) {
+ shouldContinue = true;
+ }
+ cy.ListMcaByMid(globalState);
+ });
+
+ it("add-payout-rule-routing-config", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")["payoutRuleBasedRouting"];
+ // Rule matches payout_type = "bank", routes to current connector
+ const routing_data = {
+ defaultSelection: {
+ type: "priority",
+ data: [
+ {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get("currentConnectorMcaId"),
+ },
+ ],
+ },
+ metadata: {},
+ rules: [
+ {
+ name: "payout_rule_1",
+ connectorSelection: {
+ type: "priority",
+ data: [
+ {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get(
+ "currentConnectorMcaId"
+ ),
+ },
+ ],
+ },
+ statements: [
+ {
+ condition: [
+ {
+ lhs: "payout_type",
+ comparison: "equal",
+ value: { type: "enum_variant", value: "bank" },
+ metadata: {},
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ cy.addRoutingConfig(
+ fixtures.payoutRoutingConfigBody,
+ data,
+ "advanced",
+ routing_data,
+ globalState
+ );
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-rule-routing-config-test", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")["payoutRuleBasedRouting"];
+
+ cy.retrieveRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("activate-payout-rule-routing-config-test", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")["payoutRuleBasedRouting"];
+
+ cy.activateRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("payout-rule-routing-test", () => {
+ const payoutData = payoutUtils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["sepa_bank_transfer"]["Fulfill"];
+
+ if (!payoutUtils.should_continue_further(payoutData)) {
+ cy.log(
+ "Skipping payout creation for " + globalState.get("connectorId")
+ );
+ shouldContinue = false;
+ return;
+ }
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ payoutData,
+ true,
+ true,
+ globalState
+ );
+
+ cy.verifyPayoutRoutingConnector(globalState);
+
+ if (shouldContinue)
+ shouldContinue = payoutUtils.should_continue_further(payoutData);
+ });
+
+ it("retrieve-payout-rule-call-test", () => {
+ if (!shouldContinue) {
+ return;
+ }
+ cy.retrievePayoutCallTest(globalState);
+ });
+ });
+
+ context("Payout Default Fallback Routing", () => {
+ before("setup default fallback routing context", () => {
+ if (outerGuardPassed) {
+ shouldContinue = true;
+ }
+ cy.ListMcaByMid(globalState);
+ });
+
+ it("add-payout-default-fallback-routing-config", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")[
+ "payoutDefaultFallbackRouting"
+ ];
+ // Rule amount > 999999 will never match for a test payout
+ // defaultSelection routes to current connector as the fallback
+ const routing_data = {
+ defaultSelection: {
+ type: "priority",
+ data: [
+ {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get("currentConnectorMcaId"),
+ },
+ ],
+ },
+ metadata: {},
+ rules: [
+ {
+ name: "payout_fallback_rule",
+ connectorSelection: {
+ type: "priority",
+ data: [
+ {
+ connector: globalState.get("connectorId"),
+ merchant_connector_id: globalState.get(
+ "currentConnectorMcaId"
+ ),
+ },
+ ],
+ },
+ statements: [
+ {
+ condition: [
+ {
+ lhs: "amount",
+ comparison: "greater_than",
+ value: { type: "number", value: 999999 },
+ metadata: {},
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ cy.addRoutingConfig(
+ fixtures.payoutRoutingConfigBody,
+ data,
+ "advanced",
+ routing_data,
+ globalState
+ );
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-default-fallback-routing-config-test", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")[
+ "payoutDefaultFallbackRouting"
+ ];
+
+ cy.retrieveRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ it("activate-payout-default-fallback-routing-config-test", () => {
+ const data =
+ routingUtils.getConnectorDetails("common")[
+ "payoutDefaultFallbackRouting"
+ ];
+
+ cy.activateRoutingConfig(data, globalState);
+ if (shouldContinue)
+ shouldContinue = routingUtils.should_continue_further(data);
+ });
+
+ // amount does NOT match rule (amount > 999999), routed to current connector via defaultSelection
+ it("payout-default-fallback-routing-test", () => {
+ const payoutData = payoutUtils.getConnectorDetails(
+ globalState.get("connectorId")
+ )["bank_transfer_pm"]["sepa_bank_transfer"]["Fulfill"];
+
+ if (!payoutUtils.should_continue_further(payoutData)) {
+ cy.log(
+ "Skipping payout creation for " + globalState.get("connectorId")
+ );
+ shouldContinue = false;
+ return;
+ }
+
+ cy.createConfirmPayoutTest(
+ fixtures.createPayoutBody,
+ payoutData,
+ true,
+ true,
+ globalState
+ );
+
+ cy.verifyPayoutRoutingConnector(globalState);
+
+ if (shouldContinue)
+ shouldContinue = payoutUtils.should_continue_further(payoutData);
+ });
+
+ it("retrieve-payout-default-fallback-call-test", () => {
+ if (!shouldContinue) {
+ return;
+ }
+ cy.retrievePayoutCallTest(globalState);
+ });
+ });
+});
diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.js
index 4b913d373d..61d3d815da 100644
--- a/cypress-tests/cypress/fixtures/imports.js
+++ b/cypress-tests/cypress/fixtures/imports.js
@@ -10,6 +10,7 @@ import citConfirmBody from "./create-mandate-cit.json";
import mitConfirmBody from "./create-mandate-mit.json";
import createPaymentBody from "./create-payment-body.json";
import createPayoutBody from "./create-payout-confirm-body.json";
+import payoutRoutingConfigBody from "./payout-routing-config-body.json";
import pmIdConfirmBody from "./create-pm-id-mit.json";
import gsmBody from "./gsm-body.json";
import listRefundCall from "./list-refund-call-body.json";
@@ -62,6 +63,7 @@ export {
merchantUpdateBody,
mitConfirmBody,
ntidConfirmBody,
+ payoutRoutingConfigBody,
pmIdConfirmBody,
refundBody,
routingConfigBody,
diff --git a/cypress-tests/cypress/fixtures/payout-routing-config-body.json b/cypress-tests/cypress/fixtures/payout-routing-config-body.json
new file mode 100644
index 0000000000..6fa2f5103a
--- /dev/null
+++ b/cypress-tests/cypress/fixtures/payout-routing-config-body.json
@@ -0,0 +1,5 @@
+{
+ "name": "payout routing config",
+ "description": "Payout priority routing config",
+ "algorithm": {}
+}
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 92def1854f..355a1db9f1 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -5122,18 +5122,56 @@ Cypress.Commands.add("ListMcaByMid", (globalState) => {
}).then((response) => {
logRequestId(response.headers["x-request-id"]);
- cy.wrap(response).then(() => {
- expect(response.headers["content-type"]).to.include("application/json");
+ expect(response.headers["content-type"]).to.include("application/json");
+
+ if (Array.isArray(response.body) && response.body.length > 0) {
+ let payoutMcaId = null;
+ let payoutProfileId = null;
+
+ response.body.forEach((connector) => {
+ const connectorName = connector.connector_name;
+ if (connectorName) {
+ globalState.set(
+ `${connectorName}McaId`,
+ connector.merchant_connector_id
+ );
+ }
+ if (connector.connector_type === "payout_processor" && !payoutMcaId) {
+ payoutMcaId = connector.merchant_connector_id;
+ payoutProfileId = connector.profile_id;
+ }
+ });
+
+ globalState.set(
+ "currentConnectorMcaId",
+ payoutMcaId || response.body[0].merchant_connector_id
+ );
+ // profileId always tracks the first connector's profile (payment profile),
+ // so payment routing tests are unaffected when a payout connector is present.
+ // payoutProfileId is stored separately and used only for payout routing configs.
globalState.set("profileId", response.body[0].profile_id);
- globalState.set("stripeMcaId", response.body[0].merchant_connector_id);
- globalState.set("adyenMcaId", response.body[1].merchant_connector_id);
- if (response.body[3]) {
- globalState.set(
- "bluesnapMcaId",
- response.body[3].merchant_connector_id
- );
+ if (payoutProfileId) {
+ globalState.set("payoutProfileId", payoutProfileId);
}
- });
+ }
+ });
+});
+
+// Verifies that a payout was routed to the expected connector and MCA
+Cypress.Commands.add("verifyPayoutRoutingConnector", (globalState) => {
+ cy.request({
+ method: "GET",
+ url: `${globalState.get("baseUrl")}/payouts/${globalState.get("payoutID")}`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("apiKey"),
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ expect(response.body.connector).to.equal(globalState.get("connectorId"));
+ expect(response.body.merchant_connector_id).to.equal(
+ globalState.get("currentConnectorMcaId")
+ );
});
});
@@ -5142,13 +5180,24 @@ Cypress.Commands.add(
(routingBody, data, type, routing_data, globalState) => {
const { Request: reqData, Response: resData } = data || {};
+ // clone to avoid mutating the shared fixture object across tests
+ const body = JSON.parse(JSON.stringify(routingBody));
+
for (const key in reqData) {
- routingBody[key] = reqData[key];
+ body[key] = reqData[key];
}
- // set profile id from env
- routingBody.profile_id = globalState.get("profileId");
- routingBody.algorithm.type = type;
- routingBody.algorithm.data = routing_data;
+ // use payout profile for payout routing configs, otherwise use payment profile
+ if (
+ reqData &&
+ reqData.transaction_type === "payout" &&
+ globalState.get("payoutProfileId")
+ ) {
+ body.profile_id = globalState.get("payoutProfileId");
+ } else {
+ body.profile_id = globalState.get("profileId");
+ }
+ body.algorithm.type = type;
+ body.algorithm.data = routing_data;
cy.request({
method: "POST",
@@ -5158,7 +5207,7 @@ Cypress.Commands.add(
"Content-Type": "application/json",
},
failOnStatusCode: false,
- body: routingBody,
+ body: body,
}).then((response) => {
logRequestId(response.headers["x-request-id"]);
@@ -5180,8 +5229,12 @@ Cypress.Commands.add(
);
Cypress.Commands.add("activateRoutingConfig", (data, globalState) => {
- const { Response: resData } = data || {};
+ const { Request: reqData, Response: resData } = data || {};
const routing_config_id = globalState.get("routingConfigId");
+ const body = {};
+ if (reqData && reqData.transaction_type) {
+ body.transaction_type = reqData.transaction_type;
+ }
cy.request({
method: "POST",
@@ -5190,7 +5243,7 @@ Cypress.Commands.add("activateRoutingConfig", (data, globalState) => {
"api-key": globalState.get("apiKey"),
"Content-Type": "application/json",
},
- body: {},
+ body: body,
failOnStatusCode: false,
}).then((response) => {
logRequestId(response.headers["x-request-id"]);