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 Relay Operations test specs (#12144)

HS-QUALIBOTb6c75c26fafc
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 5902345cd6..0720fee7d4 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -3624,6 +3624,116 @@ export const connectorDetails = {
},
}),
},
+ relay_pm: {
+ RefundRelay: {
+ Request: {
+ type: "refund",
+ data: {
+ refund: {
+ amount: 1000,
+ currency: "USD",
+ },
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ type: "refund",
+ },
+ },
+ },
+ CaptureRelay: {
+ Request: {
+ type: "capture",
+ data: {
+ capture: {
+ authorized_amount: 2000,
+ amount_to_capture: 1500,
+ currency: "USD",
+ },
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ type: "capture",
+ },
+ },
+ },
+ RetrieveRelay: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ type: "refund",
+ },
+ },
+ },
+ RetrieveCaptureRelay: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ type: "capture",
+ },
+ },
+ },
+ MissingConnectorId: {
+ Request: {
+ connector_resource_id: "test_connector_resource_id",
+ type: "refund",
+ data: {
+ refund: {
+ amount: 1000,
+ currency: "USD",
+ },
+ },
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ message: "Json deserialize error: missing field `connector_id`",
+ code: "IR_06",
+ },
+ },
+ },
+ },
+ InvalidRelayType: {
+ Request: {
+ connector_resource_id: "test_connector_resource_id",
+ connector_id: "test_connector_id",
+ type: "invalid_type",
+ data: {
+ refund: {
+ amount: 1000,
+ currency: "USD",
+ },
+ },
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ message: "Json deserialize error: unknown variant `invalid_type`",
+ code: "IR_06",
+ },
+ },
+ },
+ },
+ RelayNotFound: {
+ Request: {},
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ code: "IR_37",
+ message: "relay not found",
+ },
+ },
+ },
+ },
+ },
step_up_auth: {
PaymentIntentOnly: getCustomExchange({
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 4f9f852891..54214e4020 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -554,6 +554,7 @@ export const CONNECTOR_LISTS = {
PARTNER_MERCHANT_IDENTIFIER: ["adyen", "checkout"],
EXTEND_AUTHORIZATION: ["adyen", "paypal"],
GIFT_CARD: ["adyen"],
+ RELAY_OPERATIONS: ["bankofamerica"],
PAY_LATER: ["klarna", "adyen", "aci", "stripe", "airwallex", "mollie"],
AUTH_SERVICE_ELIGIBILITY: ["stripe", "cybersource"],
STEP_UP_AUTH: ["cybersource"],
diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-RelayOperations.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-RelayOperations.cy.js
new file mode 100644
index 0000000000..76630b0b1d
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/52-RelayOperations.cy.js
@@ -0,0 +1,216 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, {
+ CONNECTOR_LISTS,
+ should_continue_further,
+ shouldIncludeConnector,
+} from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Relay Operations", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ const connectorId = globalState.get("connectorId");
+
+ if (
+ shouldIncludeConnector(
+ connectorId,
+ CONNECTOR_LISTS.INCLUDE.RELAY_OPERATIONS
+ )
+ ) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ cy.log(
+ `Skipping relay operation tests — connector not in RELAY_OPERATIONS list`
+ );
+ this.skip();
+ }
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Relay Refund — auto-capture payment", () => {
+ it("Create Payment → Confirm → POST /relay (refund) → GET /relay → GET /relay?force_sync", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!should_continue_further(data)) shouldContinue = false;
+ });
+
+ cy.step("Confirm Payment (no 3DS, auto-capture)", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Payment");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (!should_continue_further(data)) shouldContinue = false;
+ });
+
+ cy.step("POST /relay (refund)", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: POST /relay refund");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["RefundRelay"];
+
+ cy.relayCallTest(fixtures.relayBody, data, globalState);
+
+ if (!should_continue_further(data)) shouldContinue = false;
+ });
+
+ cy.step("GET /relay/{relay_id}", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: GET /relay");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["RetrieveRelay"];
+
+ cy.retrieveRelayCallTest(data, globalState);
+ });
+
+ cy.step("GET /relay/{relay_id}?force_sync=true", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: GET /relay force_sync");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["RetrieveRelay"];
+
+ cy.retrieveRelayCallTest(data, globalState, true);
+ });
+ });
+ });
+
+ context("Relay Capture — manual capture payment", () => {
+ it("Create Payment (manual) → Confirm → POST /relay (capture) → GET /relay", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent (manual capture)", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "manual",
+ globalState
+ );
+
+ if (!should_continue_further(data)) shouldContinue = false;
+ });
+
+ cy.step("Confirm Payment (no 3DS, manual capture)", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Payment");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSManualCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (!should_continue_further(data)) shouldContinue = false;
+ });
+
+ cy.step("POST /relay (capture)", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: POST /relay capture");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["CaptureRelay"];
+
+ cy.relayCallTest(fixtures.relayBody, data, globalState);
+
+ if (!should_continue_further(data)) shouldContinue = false;
+ });
+
+ cy.step("GET /relay/{relay_id}", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: GET /relay");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["RetrieveCaptureRelay"];
+
+ cy.retrieveRelayCallTest(data, globalState);
+ });
+ });
+ });
+
+ context("Relay Error — invalid request validation", () => {
+ it("POST /relay without connector_id → 400 IR_06", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["MissingConnectorId"];
+
+ cy.relayCallTest({}, data, globalState, true);
+ });
+
+ it("POST /relay with invalid relay type → 400 IR_06", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["InvalidRelayType"];
+
+ cy.relayCallTest({}, data, globalState, true);
+ });
+
+ it("GET /relay with non-existent relay_id → 400 IR_37", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "relay_pm"
+ ]["RelayNotFound"];
+
+ cy.retrieveRelayCallTest(
+ data,
+ globalState,
+ false,
+ "relay_InvalidIdForTesting123"
+ );
+ });
+ });
+});
diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.js
index 9e0ef19894..9f658bd42d 100644
--- a/cypress-tests/cypress/fixtures/imports.js
+++ b/cypress-tests/cypress/fixtures/imports.js
@@ -30,6 +30,7 @@ import disputeEvidenceBody from "./dispute-evidence-body.json";
import cardLimitedDataMITBody from "./create-card-limited-data-mit.json";
import eligibilityCheckBody from "./eligibility-check-body.json";
import extendAuthBody from "./extend-auth-body.json";
+import relayBody from "./relay-body.json";
import threeDSAuthenticationBody from "./three-ds-authentication-body.json";
import * as IncomingWebhookBody from "./webhooks/import";
import customerCreate from "./modularPmService/modularPmServiceCustomerCreate.json";
@@ -68,6 +69,7 @@ export {
payoutRoutingConfigBody,
pmIdConfirmBody,
refundBody,
+ relayBody,
routingConfigBody,
saveCardConfirmBody,
sessionTokenBody,
diff --git a/cypress-tests/cypress/fixtures/relay-body.json b/cypress-tests/cypress/fixtures/relay-body.json
new file mode 100644
index 0000000000..0dce74baef
--- /dev/null
+++ b/cypress-tests/cypress/fixtures/relay-body.json
@@ -0,0 +1,6 @@
+{
+ "connector_resource_id": "",
+ "connector_id": "",
+ "type": "refund",
+ "data": {}
+}
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 356e1d8d9e..ede8288b4b 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -8259,3 +8259,101 @@ Cypress.Commands.add("updateCardIssuer", (id, body, globalState) => {
});
});
});
+
+Cypress.Commands.add(
+ "relayCallTest",
+ (requestBody, data, globalState, isErrorTest = false) => {
+ const {
+ Configs: configs = {},
+ Request: reqData,
+ Response: resData,
+ } = data || {};
+
+ const configInfo = execConfig(validateConfig(configs));
+ const profileId = globalState.get(`${configInfo.profilePrefix}Id`);
+
+ let body;
+ if (isErrorTest) {
+ body = reqData || {};
+ } else {
+ requestBody.connector_resource_id = globalState.get(
+ "connectorTransactionID"
+ );
+ requestBody.connector_id = globalState.get("merchantConnectorId");
+
+ for (const key in reqData) {
+ requestBody[key] = reqData[key];
+ }
+ body = requestBody;
+ }
+
+ cy.request({
+ method: "POST",
+ url: `${globalState.get("baseUrl")}/relay`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("apiKey"),
+ "X-Profile-Id": profileId,
+ "X-Idempotency-Key": isErrorTest
+ ? `relay_err_${Date.now()}`
+ : `relay_${Date.now()}`,
+ },
+ failOnStatusCode: false,
+ body,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+ if (isErrorTest) {
+ defaultErrorHandler(response, resData);
+ } else if (response.status === 200) {
+ globalState.set("relayId", response.body.id);
+ for (const key in resData.body) {
+ expect(resData.body[key], key).to.deep.equal(response.body[key]);
+ }
+ } else {
+ defaultErrorHandler(response, resData);
+ }
+ });
+ });
+ }
+);
+
+Cypress.Commands.add(
+ "retrieveRelayCallTest",
+ (data, globalState, forceSync = false, relayIdOverride = null) => {
+ const { Configs: configs = {}, Response: resData } = data || {};
+
+ const configInfo = execConfig(validateConfig(configs));
+ const profileId = globalState.get(`${configInfo.profilePrefix}Id`);
+ const relayId = relayIdOverride || globalState.get("relayId");
+
+ const url = forceSync
+ ? `${globalState.get("baseUrl")}/relay/${relayId}?force_sync=true`
+ : `${globalState.get("baseUrl")}/relay/${relayId}`;
+
+ cy.request({
+ method: "GET",
+ url,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("apiKey"),
+ "X-Profile-Id": profileId,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+ if (response.status === 200) {
+ expect(response.body.id).to.equal(relayId);
+ for (const key in resData.body) {
+ expect(resData.body[key], key).to.deep.equal(response.body[key]);
+ }
+ } else {
+ defaultErrorHandler(response, resData);
+ }
+ });
+ });
+ }
+);