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

ci(cypress): Add FRM (Fraud Risk Management) test cases (#12632)

Gnanasundari24a786fd2fb43f
diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml
index a607c0300d..8a74e12576 100644
--- a/.github/workflows/cypress-tests-runner.yml
+++ b/.github/workflows/cypress-tests-runner.yml
@@ -954,7 +954,7 @@ jobs:
# replay store finds them at cypress-tests/mitm-proxy/captures/{connector}/.
# We accept tarballs created either way (with or without a leading
# {connector}/ component) and normalise the on-disk layout here so
- # a misformed tarball doesn't silently produce zero cassettes.
+ # a malformed tarball doesn't silently produce zero cassettes.
set -euo pipefail
mkdir -p "cypress-tests/mitm-proxy/captures"
diff --git a/crates/hyperswitch_connectors/src/connectors/signifyd.rs b/crates/hyperswitch_connectors/src/connectors/signifyd.rs
index 1baa723f60..beddb78767 100644
--- a/crates/hyperswitch_connectors/src/connectors/signifyd.rs
+++ b/crates/hyperswitch_connectors/src/connectors/signifyd.rs
@@ -136,7 +136,7 @@ impl ConnectorCommon for Signifyd {
.change_context(ConnectorError::FailedToObtainAuthType)?;
let auth_api_key = format!(
"Basic {}",
- consts::BASE64_ENGINE.encode(auth.api_key.peek())
+ consts::BASE64_ENGINE.encode(format!("{}:", auth.api_key.peek()))
);
Ok(vec![(
diff --git a/crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api.rs b/crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api.rs
index 5ca8f75321..d9409008e6 100644
--- a/crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api.rs
+++ b/crates/hyperswitch_connectors/src/connectors/signifyd/transformers/api.rs
@@ -506,7 +506,7 @@ impl From<SignifydPaymentStatus> for FraudCheckStatus {
pub struct SignifydPaymentsResponse {
signifyd_id: i64,
order_id: String,
- decision: Decision,
+ decision: Option<Decision>,
}
impl<F, T> TryFrom<ResponseRouterData<F, SignifydPaymentsResponse, T, FraudCheckResponseData>>
@@ -516,17 +516,23 @@ impl<F, T> TryFrom<ResponseRouterData<F, SignifydPaymentsResponse, T, FraudCheck
fn try_from(
item: ResponseRouterData<F, SignifydPaymentsResponse, T, FraudCheckResponseData>,
) -> Result<Self, Self::Error> {
+ let (status, score, reason) = match item.response.decision {
+ Some(decision) => (
+ FraudCheckStatus::from(decision.checkpoint_action),
+ decision.score.and_then(|data| data.to_i32()),
+ decision
+ .checkpoint_action_reason
+ .map(serde_json::Value::from),
+ ),
+ None => (FraudCheckStatus::Legit, None, None),
+ };
Ok(Self {
response: Ok(FraudCheckResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(item.response.order_id),
- status: FraudCheckStatus::from(item.response.decision.checkpoint_action),
+ status,
connector_metadata: None,
- score: item.response.decision.score.and_then(|data| data.to_i32()),
- reason: item
- .response
- .decision
- .checkpoint_action_reason
- .map(serde_json::Value::from),
+ score,
+ reason,
}),
..item.data
})
diff --git a/cypress-tests/cypress/e2e/configs/FRM/Signifyd.js b/cypress-tests/cypress/e2e/configs/FRM/Signifyd.js
new file mode 100644
index 0000000000..3ff9e49e55
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/FRM/Signifyd.js
@@ -0,0 +1,49 @@
+import { getCustomExchange } from "../Payment/Modifiers";
+import {
+ successfulNo3DSCardDetails,
+ standardBillingAddress,
+} from "../Payment/Commons";
+
+// SIGNIFYD SANDBOX LIMITATION:
+// Signifyd sandbox always returns "Accept" decision regardless of test emails.
+// All FRM scenarios (Approve/Decline/Hold) return status "succeeded".
+// To test actual decline/hold behavior, configure Signifyd production credentials.
+
+const orderDetails = [
+ {
+ product_name: "Test Product",
+ quantity: 1,
+ amount: 6000,
+ },
+];
+
+const frmMetadata = {
+ order_channel: "web",
+};
+
+export const connectorDetails = {
+ card_pm: {
+ FRMApprove: getCustomExchange({
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ email: "[email protected]",
+ frm_metadata: frmMetadata,
+ order_details: orderDetails,
+ shipping: standardBillingAddress,
+ billing: standardBillingAddress,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ }),
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index de652ca42c..25bce311cb 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -93,7 +93,7 @@ export const cardCreditEnabled = [
},
];
-const successfulNo3DSCardDetails = {
+export const successfulNo3DSCardDetails = {
card_number: "4111111111111111",
card_exp_month: "08",
card_exp_year: "30",
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index ef51d596af..5b50ec1059 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -67,6 +67,7 @@ import { connectorDetails as powertranzConnectorDetails } from "./PowerTranz.js"
import { connectorDetails as rapydConnectorDetails } from "./Rapyd.js";
import { connectorDetails as redsysConnectorDetails } from "./Redsys.js";
import { connectorDetails as shift4ConnectorDetails } from "./Shift4.js";
+import { connectorDetails as signifydConnectorDetails } from "../FRM/Signifyd.js";
import { connectorDetails as silverflowConnectorDetails } from "./Silverflow.js";
import { connectorDetails as squareConnectorDetails } from "./Square.js";
import { connectorDetails as staxConnectorDetails } from "./Stax.js";
@@ -147,6 +148,7 @@ const connectorDetails = {
rapyd: rapydConnectorDetails,
redsys: redsysConnectorDetails,
shift4: shift4ConnectorDetails,
+ signifyd: signifydConnectorDetails,
silverflow: silverflowConnectorDetails,
square: squareConnectorDetails,
stax: staxConnectorDetails,
@@ -737,6 +739,7 @@ export const CONNECTOR_LISTS = {
"worldpayvantiv",
],
POLL_CONFIG: ["stripe"],
+ FRM: ["stripe"],
PAYOUT_PRIORITY: ["adyenplatform"],
DELAYED_SESSION_TOKEN: ["trustpay", "payme"],
CLIENT_SESSION_VALIDATION: ["stripe"],
diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-FRM.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-FRM.cy.js
new file mode 100644
index 0000000000..97e9423a43
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/52-FRM.cy.js
@@ -0,0 +1,109 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+import {
+ shouldIncludeConnector,
+ CONNECTOR_LISTS,
+} from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("FRM - Fraud Risk Management Tests", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ const connector = globalState.get("connectorId");
+
+ if (shouldIncludeConnector(connector, CONNECTOR_LISTS.INCLUDE.FRM)) {
+ skip = true;
+ return;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ })
+ .then(() => {
+ if (skip) return;
+ cy.setFrmRoutingAlgorithm(
+ fixtures.frmRoutingAlgorithmBody,
+ globalState
+ );
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("FRM with Signifyd - Create FRM Connector + Payment", () => {
+ it("create-frm-connector-signifyd-and-approve-payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create FRM Connector (Signifyd)", () => {
+ cy.createNamedConnectorCallTest(
+ "payment_vas",
+ fixtures.createConnectorBody,
+ {},
+ globalState,
+ "signifyd",
+ "signifyd_frm",
+ "profile",
+ "frmConnector"
+ );
+
+ if (
+ !utils.should_continue_further({
+ Response: { status: 200, body: {} },
+ })
+ ) {
+ shouldContinue = false;
+ }
+ cy.screenshot("frm-connector-creation");
+ });
+
+ cy.step("Create and Confirm Payment with FRM (Approve)", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Create and Confirm Payment with FRM"
+ );
+ return;
+ }
+
+ const data = getConnectorDetails("signifyd")["card_pm"]["FRMApprove"];
+
+ cy.createConfirmPaymentTest(
+ fixtures.createConfirmPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ cy.screenshot("frm-approve-payment");
+ });
+
+ cy.step("Retrieve Payment to Verify Status", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+
+ cy.retrievePaymentCallTest({ globalState });
+ cy.screenshot("frm-approve-payment-status");
+ });
+ });
+
+ afterEach("Delete FRM connector", () => {
+ cy.deleteFrmConnector(globalState);
+ });
+ });
+});
diff --git a/cypress-tests/cypress/fixtures/frm-routing-algorithm-body.json b/cypress-tests/cypress/fixtures/frm-routing-algorithm-body.json
new file mode 100644
index 0000000000..93955ab707
--- /dev/null
+++ b/cypress-tests/cypress/fixtures/frm-routing-algorithm-body.json
@@ -0,0 +1,6 @@
+{
+ "frm_routing_algorithm": {
+ "data": "signifyd",
+ "type": "single"
+ }
+}
diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.js
index e14229d2e8..d5395ba289 100644
--- a/cypress-tests/cypress/fixtures/imports.js
+++ b/cypress-tests/cypress/fixtures/imports.js
@@ -32,6 +32,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 frmRoutingAlgorithmBody from "./frm-routing-algorithm-body.json";
import relayBody from "./relay-body.json";
import threeDSAuthenticationBody from "./three-ds-authentication-body.json";
import * as IncomingWebhookBody from "./webhooks/import";
@@ -62,6 +63,7 @@ export {
disputeEvidenceBody,
eligibilityCheckBody,
extendAuthBody,
+ frmRoutingAlgorithmBody,
threeDSAuthenticationBody,
gsmBody,
listRefundCall,
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index a7a93cd23d..bf3b52d666 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -1246,7 +1246,25 @@ Cypress.Commands.add(
createConnectorBody.connector_name =
getOriginalConnectorName(connectorName);
createConnectorBody.connector_label = connectorLabel;
- createConnectorBody.payment_methods_enabled = paymentMethodsEnabled;
+
+ // For payment_vas (FRM) connectors, use frm_configs with payment_methods array inside
+ if (connectorType === "payment_vas") {
+ createConnectorBody.frm_configs = [
+ {
+ gateway: getOriginalConnectorName(globalState.get("connectorId")),
+ payment_methods: [
+ {
+ payment_method: "card",
+ flow: "pre",
+ },
+ ],
+ },
+ ];
+ delete createConnectorBody.payment_methods_enabled;
+ } else {
+ createConnectorBody.payment_methods_enabled = paymentMethodsEnabled;
+ }
+
// readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature
// it is best to use then() to handle the response within the same block of code
cy.readFile(globalState.get("connectorAuthFilePath")).then(
@@ -1255,6 +1273,11 @@ Cypress.Commands.add(
JSON.stringify(jsonContent),
connectorName
);
+ if (!authDetails) {
+ throw new Error(
+ `No credentials found for ${connectorName} in creds.json — skipping connector creation`
+ );
+ }
createConnectorBody.connector_account_details =
authDetails.connector_account_details;
cy.request({
@@ -1823,6 +1846,69 @@ Cypress.Commands.add("connectorDeleteCall", (globalState) => {
});
});
+Cypress.Commands.add("setFrmRoutingAlgorithm", (body, globalState) => {
+ const merchantId = globalState.get("merchantId");
+ const adminApiKey = globalState.get("adminApiKey");
+ const baseUrl = globalState.get("baseUrl");
+
+ body.merchant_id = merchantId;
+
+ cy.request({
+ method: "POST",
+ url: `${baseUrl}/accounts/${merchantId}`,
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "api-key": adminApiKey,
+ },
+ body: body,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.task(
+ "cli_log",
+ "Set frm_routing_algorithm status: " +
+ response.status +
+ " body: " +
+ JSON.stringify(response.body)
+ );
+ expect(
+ [200, 400],
+ "frm_routing_algorithm update should return 200 (success) or 400 (already set)"
+ ).to.include(response.status);
+ });
+});
+
+Cypress.Commands.add("deleteFrmConnector", (globalState) => {
+ const frmMcaId = globalState.get("frmConnectorId");
+
+ if (!frmMcaId) {
+ cy.task("cli_log", "No frmConnectorId found, skipping delete");
+ return;
+ }
+
+ const merchantId = globalState.get("merchantId");
+ const baseUrl = globalState.get("baseUrl");
+ const adminApiKey = globalState.get("adminApiKey");
+
+ cy.request({
+ method: "DELETE",
+ url: `${baseUrl}/account/${merchantId}/connectors/${frmMcaId}`,
+ headers: {
+ Accept: "application/json",
+ "api-key": adminApiKey,
+ },
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+ cy.task(
+ "cli_log",
+ "FRM Signifyd connector delete status: " + response.status
+ );
+ });
+});
+
Cypress.Commands.add(
"connectorUpdateCall",
(connectorType, updateConnectorBody, globalState) => {