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
ci(cypress): added payment webhook fixtures (#11612)
Vasanth5aa2452ca212
diff --git a/cypress-tests/cypress.config.js b/cypress-tests/cypress.config.jsindex 1c80ca3f51..887fa768f8 100644--- a/cypress-tests/cypress.config.js+++ b/cypress-tests/cypress.config.js@@ -1,3 +1,4 @@+import crypto from "node:crypto";import { defineConfig } from "cypress";import mochawesome from "cypress-mochawesome-reporter/plugin.js";import fs from "fs";@@ -32,6 +33,10 @@ export default defineConfig({console.log(message);return null;},+ hmac_sha256: ({ secret, message }) => {+ const key = Buffer.from(secret, "hex");+ return crypto.createHmac("sha256", key).update(message).digest("hex");+ },});on("after:spec", (spec, results) => {// Clean up resources after each specdiff --git a/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js b/cypress-tests/cypress/e2e/configs/Payment/Airwallex.jsindex 21dc165cd5..42b676f6e0 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Airwallex.js@@ -910,4 +910,10 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ path: "sourceId",+ type: "string",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Finix.js b/cypress-tests/cypress/e2e/configs/Payment/Finix.jsindex c0463b56a6..30d76118b9 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Finix.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Finix.js@@ -707,4 +707,12 @@ export const connectorDetails = {pmListDynamicFieldWithEmail: requiredFields,},},+ webhook: {+ TransactionIdConfig: {+ // Defines how to locate and parse the payment reference ID from connector-specific webhook payloads+ path: "_embedded.authorizations.0.id",+ // Type of payment reference ID+ type: "string",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js b/cypress-tests/cypress/e2e/configs/Payment/Fiuu.jsindex 8a9f5b9e3e..ef73ee8bc4 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Fiuu.js@@ -973,4 +973,14 @@ export const connectorDetails = {pmListDynamicFieldWithEmail: requiredFields,},},+ webhook: {+ TransactionIdConfig: {+ // Defines how to locate and parse the payment reference ID from connector-specific webhook payloads+ path: "orderid",+ // Type of payment reference ID+ type: "string",+ // Fiuu webhook handler uses PaymentAttemptId for lookup, not ConnectorTransactionId+ source: "paymentAttemptID",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Mollie.js b/cypress-tests/cypress/e2e/configs/Payment/Mollie.jsindex 6ff3bd144d..5a6e4d900d 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Mollie.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Mollie.js@@ -829,4 +829,14 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ // Defines how to locate and parse the payment reference ID from connector-specific webhook payloads+ path: "id",+ // Type of payment reference ID+ type: "string",+ },+ // Mollie webhook handler uses serde_qs (form-encoded), not JSON+ contentType: "application/x-www-form-urlencoded",+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Nmi.js b/cypress-tests/cypress/e2e/configs/Payment/Nmi.jsindex 586a63aeec..2115ab9dc5 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Nmi.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Nmi.js@@ -643,4 +643,14 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ // Defines how to locate and parse the payment reference ID from connector-specific webhook payloads+ path: "event_body.order_id",+ // Type of payment reference ID+ type: "string",+ // NMI webhook handler uses PaymentAttemptId for lookup, not ConnectorTransactionId+ source: "paymentAttemptID",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Novalnet.js b/cypress-tests/cypress/e2e/configs/Payment/Novalnet.jsindex a730d418eb..6a4ed47508 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Novalnet.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Novalnet.js@@ -756,4 +756,12 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ // Defines how to locate and parse the payment reference ID from connector-specific webhook payloads+ path: "event.tid",+ // Type of payment reference ID+ type: "number",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Payload.js b/cypress-tests/cypress/e2e/configs/Payment/Payload.jsindex e50a0200a1..647a2d4569 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Payload.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Payload.js@@ -686,4 +686,10 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ path: "triggered_on.id",+ type: "string",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Paypal.js b/cypress-tests/cypress/e2e/configs/Payment/Paypal.jsindex 9a77079c6c..b70b55983f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Paypal.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Paypal.js@@ -903,4 +903,10 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ path: "resource.supplementary_data.related_ids.order_id",+ type: "string",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js b/cypress-tests/cypress/e2e/configs/Payment/Trustpay.jsindex 8706f5d092..f5120198e9 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js@@ -826,4 +826,11 @@ export const connectorDetails = {commonConnectorDetails.bank_transfer_pm.InstantBankTransferPoland),},+ webhook: {+ TransactionIdConfig: {+ path: "PaymentInformation.References.MerchantReference",+ type: "string",+ source: "paymentAttemptID",+ },+ },};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex eb5432efd4..2cfad737c0 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -483,7 +483,21 @@ export const CONNECTOR_LISTS = {"worldpayvantiv","worldpayxml",],- PAYMENTS_WEBHOOK: ["noon", "stripe", "authorizedotnet"],+ PAYMENTS_WEBHOOK: [+ "noon",+ "stripe",+ "authorizedotnet",+ "airwallex",+ "finix",+ "fiuu",+ "mollie",+ "nmi",+ "novalnet",+ "payload",+ "paypal",+ "trustpay",+ "worldpay",+ ],CARD_INSTALLMENTS: ["adyen"],// Add more inclusion lists},diff --git a/cypress-tests/cypress/e2e/configs/Payment/WorldPay.js b/cypress-tests/cypress/e2e/configs/Payment/WorldPay.jsindex 6eb0fb7a20..1438a6947e 100644--- a/cypress-tests/cypress/e2e/configs/Payment/WorldPay.js+++ b/cypress-tests/cypress/e2e/configs/Payment/WorldPay.js@@ -1085,4 +1085,21 @@ export const connectorDetails = {},},},+ webhook: {+ TransactionIdConfig: {+ // Defines how to locate and parse the payment reference ID from connector-specific webhook payloads+ path: "eventDetails.transactionReference",+ // Type of payment reference ID+ type: "string",+ // WorldPay webhook handler uses PaymentAttemptId for lookup, not ConnectorTransactionId+ source: "paymentAttemptID",+ },+ // WorldPay requires mandatory HMAC-SHA256 webhook signature verification.+ // This hex secret is used both during connector creation (connector_webhook_details)+ // and to compute the Event-Signature header when sending test webhooks.+ webhookSecret:+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",+ signatureHeader: "Event-Signature",+ signaturePrefix: "mac/sha256/",+ },};diff --git a/cypress-tests/cypress/e2e/spec/Payment/00041-PaymentWebhookFixture.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00041-PaymentWebhook.cy.jssimilarity index 81%rename from cypress-tests/cypress/e2e/spec/Payment/00041-PaymentWebhookFixture.cy.jsrename to cypress-tests/cypress/e2e/spec/Payment/00041-PaymentWebhook.cy.jsindex 9270aa52c6..d415eda2e5 100644--- a/cypress-tests/cypress/e2e/spec/Payment/00041-PaymentWebhookFixture.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/00041-PaymentWebhook.cy.js@@ -45,9 +45,22 @@ describe("Payment Webhook Tests", () => {});it("Create merchant connector account", () => {+ const connectorBody = structuredClone(fixtures.createConnectorBody);++ // If connector requires webhook signature verification (e.g. WorldPay),+ // set connector_webhook_details with the test secret during connector creation+ const webhookConfig = getConnectorDetails(globalState.get("connectorId"))[+ "webhook"+ ];+ if (webhookConfig?.webhookSecret) {+ connectorBody.connector_webhook_details = {+ merchant_secret: webhookConfig.webhookSecret,+ };+ }+cy.createConnectorCallTest("payment_processor",- fixtures.createConnectorBody,+ connectorBody,payment_methods_enabled,globalState);@@ -115,19 +128,10 @@ describe("Payment Webhook Tests", () => {fixtures.IncomingWebhookBody.webhookBodies[connector]["payment"]);- // Extract webhook reference ID configuration for the specified connector- // This config defines how to locate and parse the payment reference ID from connector-specific webhook payloads- const data =- getConnectorDetails(connector)["webhook"]["TransactionIdConfig"];-- // Normalize transaction ID- utils.setNormalizedValue(- webhookBody,- data,- globalState.get("connectorTransactionID")- );+ // Extract webhook configuration for the specified connector+ const webhookConfig = getConnectorDetails(connector)["webhook"];- cy.IncomingWebhookTest(globalState, webhookBody);+ cy.IncomingWebhookTest(globalState, webhookBody, webhookConfig);});it("Retrieve Payment Call Test", () => {diff --git a/cypress-tests/cypress/fixtures/webhooks/airwallex_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/airwallex_payment_webhook.jsonnew file mode 100644index 0000000000..775df42a98--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/airwallex_payment_webhook.json@@ -0,0 +1,7 @@+{+ "name": "payment_attempt.authorized",+ "sourceId": "{{connector_transaction_id}}",+ "data": {+ "object": {}+ }+}diff --git a/cypress-tests/cypress/fixtures/webhooks/finix_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/finix_payment_webhook.jsonnew file mode 100644index 0000000000..c6ff1531a7--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/finix_payment_webhook.json@@ -0,0 +1,22 @@+{+ "id": "event_cgGzzdKrV3fbsd74ugymaX",+ "type": "created",+ "entity": "authorization",+ "occurred_at": "2025-12-22T05:19:03.022174",+ "_embedded": {+ "authorizations": [+ {+ "id": "{{connector_transaction_id}}",+ "amount": 6000,+ "state": "SUCCEEDED",+ "currency": "USD",+ "transfer": null,+ "void_state": "UNATTEMPTED",+ "trace_id": "FNXtrace123456",+ "created_at": "2025-12-22T05:19:03.437Z",+ "updated_at": "2025-12-22T05:19:03.437Z",+ "tags": {}+ }+ ]+ }+}diff --git a/cypress-tests/cypress/fixtures/webhooks/fiuu_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/fiuu_payment_webhook.jsonnew file mode 100644index 0000000000..9388c32591--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/fiuu_payment_webhook.json@@ -0,0 +1,16 @@+{+ "skey": "dGVzdF9zaWduYXR1cmU=",+ "status": "00",+ "orderid": "{{connector_transaction_id}}",+ "tranID": "25061512000000",+ "nbcb": "2",+ "amount": "60.00",+ "currency": "MYR",+ "domain": "test.merchant.com",+ "appcode": "test_appcode",+ "paydate": "2024-06-15 12:00:00",+ "channel": "credit",+ "error_desc": null,+ "error_code": null,+ "extraP": null+}diff --git a/cypress-tests/cypress/fixtures/webhooks/import.js b/cypress-tests/cypress/fixtures/webhooks/import.jsindex 59f5114e1f..4fa6ec7b3c 100644--- a/cypress-tests/cypress/fixtures/webhooks/import.js+++ b/cypress-tests/cypress/fixtures/webhooks/import.js@@ -1,6 +1,16 @@import stripePayment from "./stripe_payment_webhook.json";import noonPayment from "./noon_payment_webhook.json";import authorizedotnetPayment from "./authorizedotnet_payment_webhook.json";+import airwallexPayment from "./airwallex_payment_webhook.json";+import finixPayment from "./finix_payment_webhook.json";+import fiuuPayment from "./fiuu_payment_webhook.json";+import molliePayment from "./mollie_payment_webhook.json";+import nmiPayment from "./nmi_payment_webhook.json";+import novalnetPayment from "./novalnet_payment_webhook.json";+import payloadPayment from "./payload_payment_webhook.json";+import paypalPayment from "./paypal_payment_webhook.json";+import trustpayPayment from "./trustpay_payment_webhook.json";+import worldpayPayment from "./worldpay_payment_webhook.json";export const webhookBodies = {stripe: {@@ -12,4 +22,34 @@ export const webhookBodies = {authorizedotnet: {payment: authorizedotnetPayment,},+ airwallex: {+ payment: airwallexPayment,+ },+ finix: {+ payment: finixPayment,+ },+ fiuu: {+ payment: fiuuPayment,+ },+ mollie: {+ payment: molliePayment,+ },+ nmi: {+ payment: nmiPayment,+ },+ novalnet: {+ payment: novalnetPayment,+ },+ payload: {+ payment: payloadPayment,+ },+ paypal: {+ payment: paypalPayment,+ },+ trustpay: {+ payment: trustpayPayment,+ },+ worldpay: {+ payment: worldpayPayment,+ },};diff --git a/cypress-tests/cypress/fixtures/webhooks/mollie_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/mollie_payment_webhook.jsonnew file mode 100644index 0000000000..aa78718f44--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/mollie_payment_webhook.json@@ -0,0 +1,3 @@+{+ "id": "tr_WDqYK6vllg"+}diff --git a/cypress-tests/cypress/fixtures/webhooks/nmi_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/nmi_payment_webhook.jsonnew file mode 100644index 0000000000..4e649cc57a--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/nmi_payment_webhook.json@@ -0,0 +1,11 @@+{+ "event_type": "transaction.sale.success",+ "event_body": {+ "transaction_id": "123456789",+ "order_id": "{{connector_transaction_id}}",+ "condition": "success",+ "action": {+ "action_type": "sale"+ }+ }+}diff --git a/cypress-tests/cypress/fixtures/webhooks/novalnet_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/novalnet_payment_webhook.jsonnew file mode 100644index 0000000000..7c17b50a96--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/novalnet_payment_webhook.json@@ -0,0 +1,23 @@+{+ "event": {+ "checksum": "dGVzdF9jaGVja3N1bQ==",+ "tid": "{{connector_transaction_id}}",+ "parent_tid": null,+ "type": "PAYMENT"+ },+ "result": {+ "status": "SUCCESS",+ "status_code": 100,+ "status_text": "Successful"+ },+ "transaction": {+ "amount": 6000,+ "currency": "EUR",+ "order_no": null,+ "payment_type": "CREDITCARD",+ "status": "CONFIRMED",+ "status_code": 100,+ "test_mode": 1,+ "tid": 12345678+ }+}diff --git a/cypress-tests/cypress/fixtures/webhooks/payload_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/payload_payment_webhook.jsonnew file mode 100644index 0000000000..ca5c26f35a--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/payload_payment_webhook.json@@ -0,0 +1,11 @@+{+ "object": "transaction",+ "trigger": "processed",+ "webhook_id": "webhook_test_001",+ "triggered_at": "2026-03-24T12:00:00Z",+ "triggered_on": {+ "id": "{{connector_transaction_id}}",+ "object": "transaction"+ },+ "url": "https://webhook.example.com/callback"+}diff --git a/cypress-tests/cypress/fixtures/webhooks/paypal_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/paypal_payment_webhook.jsonnew file mode 100644index 0000000000..f6d28762c9--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/paypal_payment_webhook.json@@ -0,0 +1,14 @@+{+ "event_type": "PAYMENT.CAPTURE.COMPLETED",+ "resource": {+ "supplementary_data": {+ "related_ids": {+ "order_id": "{{connector_transaction_id}}"+ }+ },+ "amount": {+ "currency_code": "USD",+ "value": "60.00"+ }+ }+}diff --git a/cypress-tests/cypress/fixtures/webhooks/trustpay_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/trustpay_payment_webhook.jsonnew file mode 100644index 0000000000..cc64dffd78--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/trustpay_payment_webhook.json@@ -0,0 +1,14 @@+{+ "PaymentInformation": {+ "CreditDebitIndicator": "CRDT",+ "References": {+ "MerchantReference": "{{connector_transaction_id}}"+ },+ "Status": "Paid",+ "Amount": {+ "Amount": 60.0,+ "Currency": "USD"+ }+ },+ "Signature": "dummysignature"+}diff --git a/cypress-tests/cypress/fixtures/webhooks/worldpay_payment_webhook.json b/cypress-tests/cypress/fixtures/webhooks/worldpay_payment_webhook.jsonnew file mode 100644index 0000000000..177a5b73b2--- /dev/null+++ b/cypress-tests/cypress/fixtures/webhooks/worldpay_payment_webhook.json@@ -0,0 +1,8 @@+{+ "eventId": "evt_worldpay_001",+ "eventTimestamp": "2024-06-15T12:00:00.000Z",+ "eventDetails": {+ "type": "sentForSettlement",+ "transactionReference": "{{connector_transaction_id}}"+ }+}diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 5b8c270b69..2cf557cdc0 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -29,6 +29,7 @@ import {extractIntegerAtEnd,getOriginalConnectorName,getValueByKey,+ setNormalizedValue,} from "../e2e/configs/Payment/Utils";import { execConfig, validateConfig } from "../utils/featureFlags";import * as RequestBodyUtils from "../utils/RequestBodyUtils";@@ -5403,33 +5404,78 @@ Cypress.Commands.add(});-Cypress.Commands.add("IncomingWebhookTest", (globalState, webhookPayload) => {- const connector = globalState.get("connectorId");- const merchantId = globalState.get("merchantId");- const completeUrl = `${Cypress.env("BASEURL")}/webhooks/${merchantId}/${connector}`;+Cypress.Commands.add(+ "IncomingWebhookTest",+ (globalState, webhookBody, webhookConfig) => {+ const connector = globalState.get("connectorId");+ const merchantId = globalState.get("merchantId");+ const completeUrl = `${Cypress.env("BASEURL")}/webhooks/${merchantId}/${connector}`;- // Send webhook POST request- return cy- .request({- method: "POST",- url: completeUrl,- headers: { "Content-Type": "application/json" },- body: webhookPayload,- failOnStatusCode: false,- })- .then((response) => {- logRequestId(response.headers["x-request-id"]);+ // Normalize transaction ID+ const txnConfig = webhookConfig.TransactionIdConfig;+ const txnId =+ txnConfig.source === "paymentAttemptID"+ ? `${globalState.get("paymentID")}_1`+ : globalState.get("connectorTransactionID");- return cy.wrap(response).then(() => {- // Throw for failed status- if (response.status !== 200) {- throw new Error(- `Webhook failed with error code "${response.body.error.code}" error message "${response.body.error.message}"`- );- }- });- });-});+ setNormalizedValue(webhookBody, txnConfig, txnId);++ const contentType = webhookConfig.contentType || "application/json";++ let body =+ contentType === "application/x-www-form-urlencoded"+ ? Object.entries(webhookBody)+ .map(+ ([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`+ )+ .join("&")+ : webhookBody;++ const headers = {+ "Content-Type": contentType,+ };++ const sendRequest = () =>+ cy+ .request({+ method: "POST",+ url: completeUrl,+ headers,+ body,+ failOnStatusCode: false,+ })+ .then((response) => {+ logRequestId(response.headers["x-request-id"]);++ if (response.status !== 200) {+ throw new Error(+ `Webhook failed with error code "${response.body?.error?.code}" error message "${response.body?.error?.message}"`+ );+ }++ return cy.wrap(response);+ });++ // If signature required+ if (webhookConfig.webhookSecret) {+ const bodyString = JSON.stringify(webhookBody);+ body = bodyString;++ return cy+ .task("hmac_sha256", {+ secret: webhookConfig.webhookSecret,+ message: bodyString,+ })+ .then((signature) => {+ headers[webhookConfig.signatureHeader] =+ `${webhookConfig.signaturePrefix}${signature}`;+ })+ .then(() => sendRequest());+ }++ return sendRequest();+ }+);Cypress.Commands.add("customerCreateCall",