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 Helcim refunds and mandates coverage (#13157)

venkatakarthikm-maker0a068c9a87be
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js b/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js
index 1c38aac82a..931b2a2204 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js
@@ -448,6 +448,9 @@ export const connectorDetails = {
},
},
MITWithoutBillingAddress: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
Request: {
billing: null,
},
@@ -461,6 +464,9 @@ export const connectorDetails = {
},
},
MITManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
Request: {},
Response: {
status: 200,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Helcim.js b/cypress-tests/cypress/e2e/configs/Payment/Helcim.js
index a3de554d0b..a37082d024 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Helcim.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Helcim.js
@@ -1,5 +1,10 @@
import { getCustomExchange } from "./Modifiers";
import { stampPaymentMethodType } from "./Utils";
+import {
+ customerAcceptance,
+ singleUseMandateData,
+ multiUseMandateData,
+} from "./Commons";
// Disable Cypress retries for Helcim because the connector enforces strict
// idempotency rules: it identifies transactions by card number, cardholder
@@ -18,6 +23,20 @@ const successfulNo3DSCardDetails = {
card_cvc: "999",
};
+const cardMandateBaseRequest = {
+ payment_method: "card",
+ payment_method_data: { card: successfulNo3DSCardDetails },
+ currency: "USD",
+};
+
+// Helcim's sandbox can't refund (transactions never settle into a closed
+// card batch) — a sandbox limitation, not a code bug.
+const helcimRefundFailureBody = {
+ status: "failed",
+ error_code: "No error code",
+ error_message: "Card Transaction cannot be refunded",
+};
+
const failedNo3DSCardDetails = {
card_number: "4000000000000002",
card_exp_month: "08",
@@ -148,6 +167,222 @@ const card_pm = {
},
},
}),
+ SyncRefund: getCustomExchange({
+ Response: {
+ status: 200,
+ body: helcimRefundFailureBody,
+ },
+ }),
+ Refund: getCustomExchange({
+ Request: { amount: 6000 },
+ Response: {
+ status: 200,
+ body: helcimRefundFailureBody,
+ },
+ }),
+ PartialRefund: getCustomExchange({
+ Request: { amount: 2000 },
+ Response: {
+ status: 200,
+ body: helcimRefundFailureBody,
+ },
+ }),
+ manualPaymentRefund: getCustomExchange({
+ Request: { amount: 6000 },
+ Response: {
+ status: 200,
+ body: helcimRefundFailureBody,
+ },
+ }),
+ manualPaymentPartialRefund: getCustomExchange({
+ Request: { amount: 2000 },
+ Response: {
+ status: 200,
+ body: helcimRefundFailureBody,
+ },
+ }),
+ // Helcim's SetupMandate flow returns 501 NotImplemented.
+ ZeroAuthPaymentIntent: getCustomExchange({
+ Request: {
+ amount: 0,
+ setup_future_usage: "off_session",
+ currency: "USD",
+ payment_type: "setup_mandate",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ ZeroAuthConfirmPayment: getCustomExchange({
+ Request: {
+ payment_type: "setup_mandate",
+ payment_method: "card",
+ payment_method_data: { card: successfulNo3DSCardDetails },
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Setup Mandate flow for Helcim is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ }),
+ ZeroAuthMandate: {
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Setup Mandate flow for Helcim is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ },
+ // Helcim doesn't support mandates, so the router silently downgrades
+ // off_session to on_session (after validation) and CIT succeeds for
+ // real — don't override setup_future_usage here, just leave it unset.
+ // MIT/list-mandate skip themselves at runtime (see commands.js) once
+ // they see no real mandate was created.
+ MandateSingleUseNo3DSAutoCapture: {
+ Request: {
+ ...cardMandateBaseRequest,
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: { status: "succeeded" },
+ },
+ },
+ MandateSingleUseNo3DSManualCapture: {
+ Request: {
+ ...cardMandateBaseRequest,
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: { status: "requires_capture" },
+ },
+ },
+ PaymentMethodIdMandateNo3DSAutoCapture: {
+ Request: {
+ ...cardMandateBaseRequest,
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSManualCapture: {
+ Request: {
+ ...cardMandateBaseRequest,
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ // Helcim declares three_ds: FeatureStatus::NotSupported (helcim.rs),
+ // so the router rejects the request before it ever reaches the
+ // connector. Kept skipped since there's no real 3DS flow to exercise,
+ // but the Response documents the actual confirmed error.
+ PaymentMethodIdMandate3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {},
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_19",
+ reason: "Cards 3DS is not supported by Helcim",
+ },
+ },
+ },
+ },
+ PaymentMethodIdMandate3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {},
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_19",
+ reason: "Cards 3DS is not supported by Helcim",
+ },
+ },
+ },
+ },
+ // Helcim never creates a real mandate to reuse for MIT (same reason as
+ // above), so these stay skipped via the standard TRIGGER_SKIP config,
+ // same as Fiuu.js's MITAutoCapture.
+ MITAutoCapture: {
+ Configs: { TRIGGER_SKIP: true },
+ Request: {},
+ Response: {
+ status: 200,
+ body: { status: "succeeded" },
+ },
+ },
+ MITManualCapture: {
+ Configs: { TRIGGER_SKIP: true },
+ Request: {},
+ Response: {
+ status: 200,
+ body: { status: "requires_capture" },
+ },
+ },
+ MITWithoutBillingAddress: {
+ Configs: { TRIGGER_SKIP: true },
+ Request: { billing: null },
+ Response: {
+ status: 200,
+ body: { status: "succeeded" },
+ },
+ },
+ MandateMultiUseNo3DSAutoCapture: {
+ Request: {
+ ...cardMandateBaseRequest,
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: { status: "succeeded" },
+ },
+ },
+ MandateMultiUseNo3DSManualCapture: {
+ Request: {
+ ...cardMandateBaseRequest,
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: { status: "requires_capture" },
+ },
+ },
};
export const connectorDetails = {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index a0e0552e79..5b80b0f43c 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -534,11 +534,13 @@ export const CONNECTOR_LISTS = {
"loonio",
"redsys",
"worldpayxml",
- "helcim",
"mifinity",
],
SAVE_CARD: ["helcim"],
// Add more exclusion lists
+ // Note: mitUsingPMId/mitForMandatesCallTest/listMandateCallTest use
+ // per-config TRIGGER_SKIP or globalState checks instead of a static
+ // list here.
},
// Inclusion lists (only run for these connectors)
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index c0a8bf6d3c..023295f50c 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -30,6 +30,7 @@ import getConnectorDetails, {
extractIntegerAtEnd,
getOriginalConnectorName,
getValueByKey,
+ injectHelcimTestCard,
setNormalizedValue,
} from "../e2e/configs/Payment/Utils";
import { execConfig, validateConfig } from "../utils/featureFlags";
@@ -552,12 +553,6 @@ function validateErrorMessage(response, resData) {
}
}
-//skip MIT using PMId if connector does not support MIT only
-export function shouldSkipMitUsingPMId(connectorId) {
- const skipConnectors = ["fiuu"];
- return skipConnectors.includes(connectorId);
-}
-
Cypress.Commands.add("healthCheck", (globalState) => {
const baseUrl = globalState.get("baseUrl");
const url = `${baseUrl}/health`;
@@ -3110,6 +3105,8 @@ Cypress.Commands.add(
confirmBody.split_payments = reqData.split_payments;
}
+ injectHelcimTestCard(confirmBody, globalState);
+
const headers = {
"Content-Type": "application/json",
"api-key": apiKey,
@@ -3908,6 +3905,8 @@ Cypress.Commands.add(
createConfirmPaymentBody.split_payments = reqData.split_payments;
}
+ injectHelcimTestCard(createConfirmPaymentBody, globalState);
+
const headers = {
"Content-Type": "application/json",
"api-key": globalState.get("apiKey"),
@@ -4821,6 +4820,8 @@ Cypress.Commands.add(
requestBody.split_payments = reqData.split_payments;
}
+ injectHelcimTestCard(requestBody, globalState);
+
globalState.set("paymentAmount", requestBody.amount);
cy.request({
@@ -4864,6 +4865,13 @@ Cypress.Commands.add(
.be.null;
}
+ // Lets mitUsingPMId know whether the connector actually supports
+ // mandates, or was silently downgraded to on_session.
+ globalState.set(
+ "mandateSetupFutureUsage",
+ response.body.setup_future_usage
+ );
+
if (requestBody.mandate_data === null) {
// For wallet mandates that return requires_customer_action, payment_method_id may be null initially.
// It will be populated after handleWalletRedirection and retrieved in subsequent retrievePaymentCallTest.
@@ -5041,6 +5049,15 @@ Cypress.Commands.add(
Cypress.Commands.add(
"mitForMandatesCallTest",
(requestBody, data, amount, confirm, capture_method, globalState) => {
+ // Skip if no mandate_id was created — the router only sets one when
+ // the connector genuinely supports mandates (payment_response.rs).
+ if (!globalState.get("mandateId")) {
+ cy.log(
+ `Skipping mitForMandatesCallTest: no mandate_id was created for connector ${globalState.get("connectorId")} (likely downgraded to on_session)`
+ );
+ return;
+ }
+
const {
Configs: configs = {},
Request: reqData,
@@ -5265,20 +5282,30 @@ Cypress.Commands.add(
globalState,
connector_agnostic_mit
) => {
- if (shouldSkipMitUsingPMId(globalState.get("connectorId"))) {
+ const {
+ Configs: configs = {},
+ Request: reqData,
+ Response: resData,
+ } = data || {};
+
+ const validatedConfigs = validateConfig(configs);
+ if (validatedConfigs?.TRIGGER_SKIP) {
cy.log(
`Skipping mitUsingPMId for connector: ${globalState.get("connectorId")}`
);
return;
}
- const {
- Configs: configs = {},
- Request: reqData,
- Response: resData,
- } = data || {};
+ // Skip if the connector was downgraded to on_session (set by
+ // citForMandatesCallTest) — no real recurring capability to test.
+ if (globalState.get("mandateSetupFutureUsage") !== "off_session") {
+ cy.log(
+ `Skipping mitUsingPMId: CIT's setup_future_usage was not "off_session" for connector ${globalState.get("connectorId")} (likely downgraded)`
+ );
+ return;
+ }
- const configInfo = execConfig(validateConfig(configs));
+ const configInfo = execConfig(validatedConfigs);
const profileId = globalState.get(`${configInfo.profilePrefix}Id`);
const apiKey = globalState.get("apiKey");
@@ -5535,6 +5562,15 @@ Cypress.Commands.add(
);
Cypress.Commands.add("listMandateCallTest", (globalState) => {
+ // Same signal as mitForMandatesCallTest — nothing to list without a
+ // real mandate_id.
+ if (!globalState.get("mandateId")) {
+ cy.log(
+ `Skipping listMandateCallTest: no mandate_id was created for connector ${globalState.get("connectorId")} (likely downgraded to on_session)`
+ );
+ return;
+ }
+
const customerId = globalState.get("customerId");
cy.request({
method: "GET",