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 platform refund list and filter coverage (#14533)
HS-QUALIBOT15e707e770e9
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 2b2afcdb6e..4ea971c52f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -1062,6 +1062,62 @@ export const payment_methods_enabled = [},];+// Shared expected responses for the platform refund list and filter APIs.+// These assertions are connector-agnostic (identical for every connector),+// so they are centralized here instead of being inlined in the spec.++// Auth negative: connected-merchant api key (or platform key with the+// x-connected-merchant-id header) on a platform-level refunds endpoint+export const platformRefundsConnectedAccountOperationError = {+ status: 400,+ error: {+ type: "invalid_request",+ code: "IR_49",+ message: "API does not support connected account operation",+ },+};++// Auth negative: standard merchant key or missing api key on a+// platform-level refunds endpoint+export const platformRefundsInvalidApiKeyError = {+ status: 401,+ error: {+ type: "invalid_request",+ code: "IR_01",+ message: "API key not provided or invalid API key used",+ },+};++// Query validation negatives for the platform refund list+export const platformRefundsListLimitZeroError = {+ status: 400,+ rawError:+ "Query deserialize error: list limit 0 is invalid, it must be between 1 and 100",+};++export const platformRefundsListLimitAboveMaxError = {+ status: 400,+ rawError:+ "Query deserialize error: list limit 1000 is invalid, it must be between 1 and 100",+};++export const platformRefundsListInvalidOffsetError = {+ status: 400,+ rawError:+ "Query deserialize error: list offset 999999 is invalid, it must be at most 20000",+};++// Maps the refund object status (RefundResponse.status:+// succeeded/failed/pending/review) to the platform refund list filter+// variant (the refund_status query param and the list item's refund_status+// field: success/failure/pending/manual_review)+export const refundStatusFilterMap = {+ succeeded: "success",+ failed: "failure",+ pending: "pending",+ review: "manual_review",+};+export const connectorDetails = {customer: {CreateInvalidPhoneCountryCode: {diff --git a/cypress-tests/cypress/e2e/spec/Platform/00013-PlatformRefundList.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00013-PlatformRefundList.cy.jsnew file mode 100644index 0000000000..125267a66f--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00013-PlatformRefundList.cy.js@@ -0,0 +1,604 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";+import {+ platformRefundsConnectedAccountOperationError,+ platformRefundsInvalidApiKeyError,+ platformRefundsListInvalidOffsetError,+ platformRefundsListLimitAboveMaxError,+ platformRefundsListLimitZeroError,+ refundStatusFilterMap,+} from "../../configs/Payment/Commons";++let globalState;++describe("Platform - Refund List and Filter flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("CM1 Creates Customer for Seed Payments", () => {+ let savedApiKey, savedMerchantId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedMerchantId = globalState.get("merchantId");+ globalState.set("apiKey", globalState.get("apiKeyCm1"));+ globalState.set("merchantId", globalState.get("connectedMerchantId1"));+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("merchantId", savedMerchantId);+ });++ it("cm1-creates-customer-for-seed-payments", () => {+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);+ });+ });++ context(+ "Platform acts on behalf of Connected Merchant 2 - Create payment and refund for platform refund list",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm2"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm2")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create and Confirm Payment -> Partial Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create and Confirm Payment for CM2 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId2")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment for CM2 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Partial Refund Payment for CM2");+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["PartialRefund"];+ const newPartialRefundData = {+ ...partialRefundData,+ Response:+ partialRefundData.ResponseCustom || partialRefundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newPartialRefundData,+ globalState,+ globalState.get("connectedMerchantId2")+ );+ });+ });+ }+ );++ context(+ "Platform acts on behalf of Connected Merchant 1 - Create payment and refund for platform refund list",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Refund Payment");+ return;+ }+ const refundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Refund"];+ const newRefundData = {+ ...refundData,+ Response: refundData.ResponseCustom || refundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context("Platform Refund List", () => {+ let savedApiKey;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("platformApiKey"));+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ });++ it("list-platform-refunds-without-filters-test", () => {+ cy.platformRefundListCallTest(+ {},+ { contains: { refund_id: globalState.get("refundId") } },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-refund-id-test", () => {+ const refundId = globalState.get("refundId");+ cy.platformRefundListCallTest(+ { refund_id: refundId },+ {+ count: 1,+ totalCount: 1,+ match: { refund_id: refundId },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-payment-id-test", () => {+ const paymentId = globalState.get("paymentID");+ cy.platformRefundListCallTest(+ { payment_id: paymentId },+ { match: { payment_id: paymentId } },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-processor-merchant-id-cm1-test", () => {+ const connectedMerchantId1 = globalState.get("connectedMerchantId1");+ cy.platformRefundListCallTest(+ { processor_merchant_id: connectedMerchantId1 },+ {+ match: { processor_merchant_id: connectedMerchantId1 },+ contains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-processor-merchant-id-cm2-test", () => {+ const connectedMerchantId2 = globalState.get("connectedMerchantId2");+ cy.platformRefundListCallTest(+ { processor_merchant_id: connectedMerchantId2 },+ {+ nonEmpty: true,+ match: { processor_merchant_id: connectedMerchantId2 },+ notContains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-profile-id-test", () => {+ const profileIdCm1 = globalState.get("profileIdCm1");+ cy.platformRefundListCallTest(+ { profile_id: profileIdCm1 },+ {+ match: { profile_id: profileIdCm1 },+ contains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-currency-test", () => {+ const currency = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"].Request.currency;+ cy.platformRefundListCallTest(+ { currency: currency },+ {+ match: { currency: currency },+ contains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-connector-test", () => {+ const connector = globalState.get("connectorId");+ cy.platformRefundListCallTest(+ { connector: connector },+ {+ match: { connector: connector },+ contains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-refund-status-test", () => {+ // The refund object status (RefundResponse.status) uses+ // succeeded/failed/pending/review, while the refund_status query+ // param and the list item's refund_status field use the filter+ // variants success/failure/pending/manual_review — map between the+ // two so the filter value is valid for every connector+ const refundStatus =+ refundStatusFilterMap[+ getConnectorDetails(globalState.get("connectorId"))["card_pm"][+ "Refund"+ ].Response.body.status+ ];+ cy.platformRefundListCallTest(+ { refund_status: refundStatus },+ {+ match: { refund_status: refundStatus },+ contains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-start-amount-test", () => {+ const refundAmount =+ getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]+ .Request?.amount ?? fixtures.refundBody.amount;+ cy.platformRefundListCallTest(+ { start_amount: refundAmount },+ {+ minRefundAmount: refundAmount,+ contains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-end-amount-test", () => {+ const refundAmount =+ getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]+ .Request?.amount ?? fixtures.refundBody.amount;+ cy.platformRefundListCallTest(+ { end_amount: refundAmount - 1 },+ {+ nonEmpty: true,+ maxRefundAmount: refundAmount - 1,+ notContains: { refund_id: globalState.get("refundId") },+ },+ globalState+ );+ });++ it("list-platform-refunds-with-empty-amount-range-test", () => {+ const refundAmount =+ getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Refund"]+ .Request?.amount ?? fixtures.refundBody.amount;+ cy.platformRefundListCallTest(+ { start_amount: refundAmount + 1, end_amount: refundAmount + 999 },+ { empty: true },+ globalState+ );+ });++ it("list-platform-refunds-filtered-by-creation-time-range-test", () => {+ const startTime = new Date(Date.now() - 60 * 60 * 1000).toISOString();+ const endTime = new Date(Date.now() + 60 * 60 * 1000).toISOString();+ cy.platformRefundListCallTest(+ { start_time: startTime, end_time: endTime },+ { contains: { refund_id: globalState.get("refundId") } },+ globalState+ );+ });++ it("list-platform-refunds-with-future-time-range-test", () => {+ const startTime = new Date(Date.now() + 60 * 60 * 1000).toISOString();+ const endTime = new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString();+ cy.platformRefundListCallTest(+ { start_time: startTime, end_time: endTime },+ { empty: true },+ globalState+ );+ });++ it("list-platform-refunds-with-end-time-only-test", () => {+ // end_time without start_time is silently ignored — no validation+ // error is raised and the unfiltered list is returned+ const endTime = new Date(Date.now() + 60 * 60 * 1000).toISOString();+ cy.platformRefundListCallTest(+ { end_time: endTime },+ { contains: { refund_id: globalState.get("refundId") } },+ globalState+ );+ });++ it("list-platform-refunds-with-unknown-payment-id-test", () => {+ cy.platformRefundListCallTest(+ { payment_id: "pay_unknown_payment_id_platform_refund_list" },+ { empty: true },+ globalState+ );+ });++ it("list-platform-refunds-with-limit-test", () => {+ cy.platformRefundListCallTest(+ { limit: 1 },+ { count: 1, contains: { refund_id: globalState.get("refundId") } },+ globalState+ );+ });++ it("list-platform-refunds-with-limit-and-offset-test", () => {+ cy.platformRefundListCallTest(+ { limit: 1, offset: 1 },+ { count: 1, notContains: { refund_id: globalState.get("refundId") } },+ globalState+ );+ });++ it("list-platform-refunds-with-invalid-limit-zero-test", () => {+ cy.platformRefundListCallTest(+ { limit: 0 },+ platformRefundsListLimitZeroError,+ globalState+ );+ });++ it("list-platform-refunds-with-invalid-limit-above-max-test", () => {+ cy.platformRefundListCallTest(+ { limit: 1000 },+ platformRefundsListLimitAboveMaxError,+ globalState+ );+ });++ it("list-platform-refunds-with-invalid-offset-test", () => {+ cy.platformRefundListCallTest(+ { offset: 999999 },+ platformRefundsListInvalidOffsetError,+ globalState+ );+ });+ });++ context("Platform Refund Filters", () => {+ let savedApiKey;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("platformApiKey"));+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ });++ it("retrieve-platform-refund-filters-test", () => {+ cy.platformRefundFilterCallTest({}, globalState);+ });+ });++ context("Platform Refund List and Filter Authorization", () => {+ it("connected-merchant-key-cannot-list-platform-refunds-test", () => {+ const savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("apiKeyCm1"));++ cy.platformRefundListCallTest(+ {},+ platformRefundsConnectedAccountOperationError,+ globalState+ );++ cy.then(() => {+ globalState.set("apiKey", savedApiKey);+ });+ });++ it("platform-key-with-connected-merchant-header-cannot-list-platform-refunds-test", () => {+ const savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("platformApiKey"));++ cy.platformRefundListCallTest(+ {},+ platformRefundsConnectedAccountOperationError,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ cy.then(() => {+ globalState.set("apiKey", savedApiKey);+ });+ });++ it("standard-merchant-key-cannot-list-platform-refunds-test", () => {+ const savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("apiKeySm"));++ cy.platformRefundListCallTest(+ {},+ platformRefundsInvalidApiKeyError,+ globalState+ );++ cy.then(() => {+ globalState.set("apiKey", savedApiKey);+ });+ });++ it("missing-api-key-cannot-list-platform-refunds-test", () => {+ cy.platformRefundListCallTest(+ {},+ { ...platformRefundsInvalidApiKeyError, omitApiKey: true },+ globalState+ );+ });++ it("connected-merchant-key-cannot-retrieve-platform-refund-filters-test", () => {+ const savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("apiKeyCm1"));++ cy.platformRefundFilterCallTest(+ platformRefundsConnectedAccountOperationError,+ globalState+ );++ cy.then(() => {+ globalState.set("apiKey", savedApiKey);+ });+ });++ it("platform-key-with-connected-merchant-header-cannot-retrieve-platform-refund-filters-test", () => {+ const savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("platformApiKey"));++ cy.platformRefundFilterCallTest(+ platformRefundsConnectedAccountOperationError,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ cy.then(() => {+ globalState.set("apiKey", savedApiKey);+ });+ });++ it("standard-merchant-key-cannot-retrieve-platform-refund-filters-test", () => {+ const savedApiKey = globalState.get("apiKey");+ globalState.set("apiKey", globalState.get("apiKeySm"));++ cy.platformRefundFilterCallTest(+ platformRefundsInvalidApiKeyError,+ globalState+ );++ cy.then(() => {+ globalState.set("apiKey", savedApiKey);+ });+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 5ecee3d071..77bb57222e 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -7274,6 +7274,268 @@ Cypress.Commands.add(});+// Platform-level refund list — GET /refunds/platform/list+// queryParams: query parameters for the list call (e.g. { refund_id, limit })+// expected: {+// status: expected HTTP status (default 200),+// error: { type, code, message } — JSON error body assertions (IR_49 / IR_01),+// rawError: exact message for plain-text query-deserialize 400s,+// count / totalCount: exact count / total_count assertions,+// empty: expect count=0, total_count=0 and data=[],+// nonEmpty: expect at least one refund in data,+// match: { field: value } — every returned refund must match,+// contains: { field: value } — at least one returned refund must match,+// notContains: { field: value } — no returned refund may match,+// minRefundAmount / maxRefundAmount: refund_amount range assertions,+// omitApiKey: send the request without the api-key header,+// }+Cypress.Commands.add(+ "platformRefundListCallTest",+ (queryParams, expected, globalState, connectedMerchantId) => {+ const {+ status: expectedStatus = 200,+ error: expectedError,+ rawError: expectedRawError,+ count: expectedCount,+ totalCount: expectedTotalCount,+ empty: expectEmpty = false,+ nonEmpty: expectNonEmpty = false,+ match: expectedMatch,+ contains: expectedContains,+ notContains: expectedNotContains,+ minRefundAmount,+ maxRefundAmount,+ omitApiKey = false,+ } = expected || {};++ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ if (omitApiKey) {+ delete headers["api-key"];+ }++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/refunds/platform/list`,+ headers,+ qs: queryParams,+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.status).to.equal(expectedStatus);++ if (expectedRawError) {+ // Pagination validation failures fail query deserialization+ // before auth and return a plain-text body+ expect(response.body).to.be.a("string");+ expect(response.body).to.equal(expectedRawError);+ return;+ }++ if (expectedStatus !== 200) {+ expect(response.body.error.type).to.equal(expectedError.type);+ expect(response.body.error.code).to.equal(expectedError.code);+ expect(response.body.error.message).to.equal(expectedError.message);+ return;+ }++ expect(response.headers["content-type"]).to.include("application/json");+ expect(response.body.count).to.be.a("number");+ expect(response.body.total_count).to.be.a("number");+ expect(response.body.data).to.be.an("array");+ expect(response.body.data).to.have.lengthOf(response.body.count);++ if (expectEmpty) {+ expect(response.body.count).to.equal(0);+ expect(response.body.total_count).to.equal(0);+ expect(response.body.data).to.be.empty;+ return;+ }++ if (expectNonEmpty) {+ expect(response.body.count).to.be.at.least(1);+ expect(response.body.data).to.not.be.empty;+ }++ // Platform attribution: every refund in the platform list is+ // attributed to the platform merchant, including refunds initiated+ // by connected merchants with their own api keys+ const platformMerchantId = globalState.get("platformMerchantId");+ response.body.data.forEach((refund, index) => {+ expect(refund.merchant_id, `merchant_id at index ${index}`).to.equal(+ platformMerchantId+ );+ });++ if (expectedMatch) {+ for (const key in expectedMatch) {+ response.body.data.forEach((refund, index) => {+ expect(refund[key], `${key} at index ${index}`).to.equal(+ expectedMatch[key]+ );+ });+ }+ }++ if (expectedContains) {+ for (const key in expectedContains) {+ const isPresent = response.body.data.some(+ (refund) => refund[key] === expectedContains[key]+ );+ expect(+ isPresent,+ `at least one refund with ${key} = ${expectedContains[key]}`+ ).to.be.true;+ }+ }++ if (expectedNotContains) {+ for (const key in expectedNotContains) {+ const isPresent = response.body.data.some(+ (refund) => refund[key] === expectedNotContains[key]+ );+ expect(+ isPresent,+ `no refund with ${key} = ${expectedNotContains[key]}`+ ).to.be.false;+ }+ }++ if (minRefundAmount !== undefined) {+ response.body.data.forEach((refund, index) => {+ expect(+ refund.refund_amount,+ `refund_amount at index ${index}`+ ).to.be.at.least(minRefundAmount);+ });+ }++ if (maxRefundAmount !== undefined) {+ response.body.data.forEach((refund, index) => {+ expect(+ refund.refund_amount,+ `refund_amount at index ${index}`+ ).to.be.at.most(maxRefundAmount);+ });+ }++ if (expectedCount !== undefined) {+ expect(response.body.count).to.equal(expectedCount);+ }++ if (expectedTotalCount !== undefined) {+ expect(response.body.total_count).to.equal(expectedTotalCount);+ }++ // Results are ordered by modified_at descending+ for (let i = 1; i < response.body.data.length; i++) {+ expect(+ new Date(response.body.data[i - 1].modified_at).getTime(),+ "modified_at ordering (descending)"+ ).to.be.at.least(+ new Date(response.body.data[i].modified_at).getTime()+ );+ }+ });+ });+ }+);++// Platform-level refund filters — GET /refunds/platform/filter+// expected: {+// status: expected HTTP status (default 200),+// error: { type, code, message } — JSON error body assertions (IR_49 / IR_01),+// }+Cypress.Commands.add(+ "platformRefundFilterCallTest",+ (expected, globalState, connectedMerchantId) => {+ const { status: expectedStatus = 200, error: expectedError } =+ expected || {};++ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/refunds/platform/filter`,+ headers,+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.status).to.equal(expectedStatus);++ if (expectedStatus !== 200) {+ expect(response.body.error.type).to.equal(expectedError.type);+ expect(response.body.error.code).to.equal(expectedError.code);+ expect(response.body.error.message).to.equal(expectedError.message);+ return;+ }++ expect(response.headers["content-type"]).to.include("application/json");++ // The connector map is keyed by connector name and lists the+ // labeled connector accounts configured under the platform's+ // connected merchants+ const connectorName = globalState.get("connectorId");+ expect(response.body.connector).to.be.an("object");+ expect(response.body.connector).to.have.property(connectorName);++ const connectorAccounts = response.body.connector[connectorName];+ expect(connectorAccounts).to.be.an("array").and.not.empty;++ const merchantConnectorIds = connectorAccounts.map(+ (connectorAccount) => connectorAccount.merchant_connector_id+ );+ expect(merchantConnectorIds).to.include(+ globalState.get("connectorIdCm1")+ );+ expect(merchantConnectorIds).to.include(+ globalState.get("connectorIdCm2")+ );+ // The standard merchant's connector is out of platform scope+ expect(merchantConnectorIds).to.not.include(+ globalState.get("connectorIdSm")+ );++ connectorAccounts.forEach((connectorAccount, index) => {+ expect(+ connectorAccount.connector_type,+ `connector_type at index ${index}`+ ).to.equal("payment_processor");+ });++ // Currency and refund_status filter enums+ expect(response.body.currency).to.be.an("array").and.not.empty;+ expect(response.body.currency).to.include("USD");+ expect(response.body.refund_status).to.deep.equal([+ "failure",+ "manual_review",+ "pending",+ "success",+ "transaction_failure",+ ]);+ });+ });+ }+);+Cypress.Commands.add("createConfirmPayoutTest",(createConfirmPayoutBody, data, confirm, auto_fulfill, globalState) => {