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 Zift void payment sync coverage (#14735)

HS-QUALIBOTd4e11d933a90
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 0e293b1c79..e67dfa5e1c 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -611,6 +611,7 @@ export const CONNECTOR_LISTS = {
// "stripe",
],
DDC_RACE_CONDITION: ["worldpay"],
+ VOID_PAYMENT_SYNC: ["zift"],
CONNECTOR_TESTING_DATA: ["adyen", "airwallex", "braintree", "noon"],
// ucs connectors
UCS_CONNECTORS: [
diff --git a/cypress-tests/cypress/e2e/spec/Payment/07-VoidPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/07-VoidPayment.cy.js
index 2b9442dd96..dc01563c28 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/07-VoidPayment.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/07-VoidPayment.cy.js
@@ -1,6 +1,10 @@
import * as fixtures from "../../../fixtures/imports";
import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+import {
+ CONNECTOR_LISTS,
+ shouldIncludeConnector,
+} from "../../configs/Payment/Utils";
let globalState;
@@ -232,4 +236,102 @@ describe("Card - NoThreeDS Manual payment flow test", () => {
});
});
});
+
+ context("Card - sync a voided payment", () => {
+ before("skip for connectors without void sync coverage", function () {
+ if (
+ shouldIncludeConnector(
+ globalState.get("connectorId"),
+ CONNECTOR_LISTS.INCLUDE.VOID_PAYMENT_SYNC
+ )
+ ) {
+ this.skip();
+ }
+ });
+
+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Void Payment -> Retrieve Payment after Void", () => {
+ 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",
+ "manual",
+ globalState
+ );
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Payment Methods Call", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Payment Methods Call");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Payment Intent", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSManualCapture"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Void Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Void Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["VoidAfterConfirm"];
+
+ cy.voidCallTest(fixtures.voidBody, data, globalState);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment after Void", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment after Void");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["VoidAfterConfirm"];
+
+ // `allKeysRequired: true` is needed here, not just `force_sync`: once
+ // the attempt is already terminal (Voided), Hyperswitch's own
+ // `should_call_connector` skips re-querying the connector, so a plain
+ // force-synced retrieve would be served entirely from the DB and
+ // never actually exercise Zift's `transactionType=void` sync
+ // response — the exact thing PR #14637 fixes.
+ cy.retrievePaymentCallTest({
+ globalState,
+ data,
+ expectedIntentStatus: data.Response.body.status,
+ allKeysRequired: true,
+ });
+ });
+ });
+ });
});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index abb2540676..85fa2d4a08 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -5086,6 +5086,7 @@ Cypress.Commands.add(
expectedIntentStatus,
connectedMerchantId,
unconfirmedPayment = false,
+ allKeysRequired = false,
}) => {
const { Configs: configs = {}, Response: resData = {} } = data || {};
@@ -5101,9 +5102,14 @@ Cypress.Commands.add(
headers["x-connected-merchant-id"] = connectedMerchantId;
}
+ // force_sync alone is served from the DB once the attempt is already in a
+ // terminal state, so it won't re-query the connector. all_keys_required=true
+ // forces a genuine connector round-trip regardless of terminal status.
const queryParams = unconfirmedPayment
? "expand_attempts=true"
- : "force_sync=true&expand_attempts=true";
+ : `force_sync=true&expand_attempts=true${
+ allKeysRequired ? "&all_keys_required=true" : ""
+ }`;
cy.request({
method: "GET",
@@ -5204,6 +5210,15 @@ Cypress.Commands.add(
).to.equal(expectedIntentStatus);
}
+ if (allKeysRequired) {
+ // Proves a real connector round-trip happened (not a cached DB
+ // read) — the field is only populated from a fresh connector call.
+ expect(
+ response.body.whole_connector_response,
+ "whole_connector_response"
+ ).to.be.a("string").and.to.not.be.empty;
+ }
+
if (resData?.body && "applied_offer" in resData.body) {
// Scoped to offer-engine fixtures only (identified by the
// presence of applied_offer, unique to that flow): retrieve