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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
test(cypress): add Helcim card payment configurations (#12752)
HS-QUALIBOT46b62c29152a
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Helcim.js b/cypress-tests/cypress/e2e/configs/Payment/Helcim.jsnew file mode 100644index 0000000000..a3de554d0b--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payment/Helcim.js@@ -0,0 +1,157 @@+import { getCustomExchange } from "./Modifiers";+import { stampPaymentMethodType } from "./Utils";++// Disable Cypress retries for Helcim because the connector enforces strict+// idempotency rules: it identifies transactions by card number, cardholder+// name, and amount. A retried test within the 5-minute duplicate-detection+// window would be flagged as a duplicate and fail, so retries are not+// meaningful here and would only produce false negatives.+if (Cypress.env("CONNECTOR") === "helcim") {+ Cypress.config("retries", 0);+}++const successfulNo3DSCardDetails = {+ card_number: "4111111111111111",+ card_exp_month: "08",+ card_exp_year: "30",+ card_holder_name: "joseph Doe",+ card_cvc: "999",+};++const failedNo3DSCardDetails = {+ card_number: "4000000000000002",+ card_exp_month: "08",+ card_exp_year: "30",+ card_holder_name: "joseph Doe",+ card_cvc: "999",+};++const card_pm = {+ PaymentIntent: getCustomExchange({+ Request: {+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ }),+ No3DSManualCapture: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: { card: successfulNo3DSCardDetails },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_capture",+ },+ },+ }),+ No3DSAutoCapture: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: { card: successfulNo3DSCardDetails },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ }),+ PaymentIntentWithShippingCost: getCustomExchange({+ Request: {+ currency: "USD",+ shipping_cost: 50,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ shipping_cost: 50,+ amount: 6000,+ },+ },+ }),+ PaymentConfirmWithShippingCost: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: { card: successfulNo3DSCardDetails },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ shipping_cost: 50,+ amount_received: 6050,+ amount: 6000,+ net_amount: 6050,+ },+ },+ }),+ No3DSFailPayment: getCustomExchange({+ Request: {+ payment_method: "card",+ payment_method_data: { card: failedNo3DSCardDetails },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ },+ Response: {+ status: 200,+ body: {},+ },+ }),+ Capture: getCustomExchange({+ Request: { amount_to_capture: 6000 },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ amount: 6000,+ amount_capturable: 0,+ amount_received: 6000,+ },+ },+ }),+ PartialCapture: getCustomExchange({+ Request: { amount_to_capture: 2000 },+ Response: {+ status: 200,+ body: {+ status: "partially_captured",+ amount: 6000,+ amount_capturable: 0,+ amount_received: 2000,+ },+ },+ }),+ VoidAfterConfirm: getCustomExchange({+ Request: {},+ Response: {+ status: 200,+ body: {+ status: "cancelled",+ capture_method: "manual",+ },+ },+ }),+};++export const connectorDetails = {+ card_pm,+ card_credit_pm: stampPaymentMethodType(card_pm, "credit"),+ card_debit_pm: stampPaymentMethodType(card_pm, "debit"),+};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.jsindex 7eb71e380d..847a1d4649 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js@@ -17,6 +17,7 @@ function normalize(input) {cybersource: "Cybersource",datatrans: "Datatrans",facilitapay: "Facilitapay",+ helcim: "Helcim",noon: "Noon",paybox: "Paybox",paypal: "Paypal",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 6ad6362b40..d34647b662 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -39,6 +39,7 @@ import { connectorDetails as forteConnectorDetails } from "./Forte.js";import { connectorDetails as getnetConnectorDetails } from "./Getnet.js";import { connectorDetails as gigadatConnectorDetails } from "./Gigadat.js";import { connectorDetails as globalpayConnectorDetails } from "./Globalpay.js";+import { connectorDetails as helcimConnectorDetails } from "./Helcim.js";import { connectorDetails as hipayConnectorDetails } from "./Hipay.js";import { connectorDetails as iatapayConnectorDetails } from "./Iatapay.js";import { connectorDetails as itaubankConnectorDetails } from "./ItauBank.js";@@ -119,6 +120,7 @@ const connectorDetails = {getnet: getnetConnectorDetails,gigadat: gigadatConnectorDetails,globalpay: globalpayConnectorDetails,+ helcim: helcimConnectorDetails,hipay: hipayConnectorDetails,iatapay: iatapayConnectorDetails,itaubank: itaubankConnectorDetails,@@ -471,7 +473,9 @@ export const CONNECTOR_LISTS = {"loonio","redsys","worldpayxml",+ "helcim",],+ SAVE_CARD: ["helcim"],// Add more exclusion lists},@@ -737,3 +741,57 @@ function coerceValue(value, type) {return value;}}++export function stampPaymentMethodType(scenarios, paymentMethodType) {+ const cloned = JSON.parse(JSON.stringify(scenarios));+ for (const scenario of Object.values(cloned)) {+ if (scenario.Request && typeof scenario.Request === "object") {+ scenario.Request.payment_method_type = paymentMethodType;+ }+ }+ return cloned;+}++// Rotate cards to avoid Helcim's duplicate-decline window.+// Helcim has strict idempotency rules which include identifying card number,+// cardholder name, etc. If they are found in any retry within 5 minutes of a+// previous transaction it will be marked as a duplicate. Therefore we rotate+// the cards and try to deny retries.+const helcimTestCards = [+ "4111111111111111",+ "4000000000000002",+ "4242424242424242",+ "4012888888881881",+ "4000056655665556",+ "4532015112830366",+ "4000000000000127",+ "4000000000000119",+ "4111111111111129",+ "4111111111111137",+ "4111111111111145",+ "4111111111111152",+ "4000000000000259",+ "4000000000003238",+ "5555555555554444",+ "5105105105105100",+ "5200828282828210",+ "5100000000000008",+ "4111111111111160",+ "4000000000000340",+];++export function injectHelcimTestCard(body, globalState) {+ if (globalState.get("connectorId") !== "helcim") return;+ if (!body.payment_method_data?.card) return;++ const testOffset = globalState.get("helcimCardIndex") ?? 0;+ const timeOffset = Math.floor(Date.now() / 1000) % helcimTestCards.length;+ const idx = (timeOffset + testOffset) % helcimTestCards.length;+ globalState.set("helcimCardIndex", testOffset + 1);++ const ts = Date.now();+ const rnd = Math.floor(Math.random() * 100000);+ const uniqueSuffix = `${ts.toString(36)}_${rnd}`;+ body.payment_method_data.card.card_number = helcimTestCards[idx];+ body.payment_method_data.card.card_holder_name = `HelcimTest ${uniqueSuffix}`;+}diff --git a/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.jsindex 227095fb72..97a52209bd 100644--- a/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/14-SaveCardFlow.cy.js@@ -6,10 +6,27 @@ import getConnectorDetails, * as utils from "../../configs/Payment/Utils";let globalState;describe("Card - SaveCard payment flow test", () => {- before("seed global state", () => {- cy.task("getGlobalState").then((state) => {- globalState = new State(state);- });+ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ const connector = globalState.get("connectorId");+ if (+ utils.shouldExcludeConnector(+ connector,+ utils.CONNECTOR_LISTS.EXCLUDE.SAVE_CARD+ )+ ) {+ skip = true;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });});after("flush global state", () => {diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 60ab6291e8..460342fa17 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";@@ -2746,6 +2747,8 @@ Cypress.Commands.add(confirmBody.split_payments = reqData.split_payments;}+ injectHelcimTestCard(confirmBody, globalState);+const headers = {"Content-Type": "application/json","api-key": apiKey,@@ -3526,6 +3529,8 @@ Cypress.Commands.add(createConfirmPaymentBody.split_payments = reqData.split_payments;}+ injectHelcimTestCard(createConfirmPaymentBody, globalState);+const headers = {"Content-Type": "application/json","api-key": globalState.get("apiKey"),