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 refund manual update coverage for bankofamerica (#12127)

HS-QUALIBOT133da77eefc7
diff --git a/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js b/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js
index 975f2b4b54..0aa0bd0589 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js
@@ -257,6 +257,15 @@ export const connectorDetails = {
},
},
},
+ ManualRefundUpdate: {
+ Request: {
+ status: "failed",
+ },
+ Response: {
+ status: 200,
+ body: {},
+ },
+ },
SyncRefund: {
Response: {
status: 200,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index e5f52b4371..4d5204b0d9 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -1498,6 +1498,120 @@ export const connectorDetails = {
},
},
}),
+ ManualRefundUpdate: getCustomExchange({
+ Request: {
+ status: "failed",
+ },
+ Response: {
+ status: 200,
+ body: {},
+ },
+ }),
+ ManualRefundUpdateErrorCode: getCustomExchange({
+ Request: {
+ status: "failed",
+ error_code: {
+ set: "TEST_ERROR_CODE",
+ },
+ error_message: {
+ set: "Test error message for manual update",
+ },
+ },
+ Response: {
+ status: 200,
+ body: {},
+ },
+ }),
+ ManualRefundUpdatePartialRefund: getCustomExchange({
+ Request: {
+ status: "failed",
+ error_code: {
+ set: "PARTIAL_REFUND_FAILED",
+ },
+ error_message: {
+ set: "Partial refund failed via manual update",
+ },
+ },
+ Response: {
+ status: 200,
+ body: {},
+ },
+ }),
+ ManualRefundUpdateIdempotency: getCustomExchange({
+ Request: {
+ status: "failed",
+ error_code: {
+ set: "IDEMPOTENCY_TEST",
+ },
+ error_message: {
+ set: "First manual update for idempotency test",
+ },
+ },
+ Response: {
+ status: 200,
+ body: {},
+ },
+ }),
+ ManualRefundUpdateUnset: getCustomExchange({
+ Request: {
+ error_code: {
+ unset: null,
+ },
+ error_message: {
+ unset: null,
+ },
+ },
+ Response: {
+ status: 200,
+ body: {},
+ },
+ }),
+ SyncRefundManualUpdateFailed: getCustomExchange({
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ }),
+ SyncRefundManualUpdateErrorCode: getCustomExchange({
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ error_code: "TEST_ERROR_CODE",
+ error_message: "Test error message for manual update",
+ },
+ },
+ }),
+ SyncRefundManualUpdatePartialRefund: getCustomExchange({
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ error_code: "PARTIAL_REFUND_FAILED",
+ error_message: "Partial refund failed via manual update",
+ },
+ },
+ }),
+ SyncRefundManualUpdateIdempotency: getCustomExchange({
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ error_code: "IDEMPOTENCY_TEST",
+ error_message: "First manual update for idempotency test",
+ },
+ },
+ }),
+ SyncRefundManualUpdateUnset: getCustomExchange({
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ }),
PartialRefund: getCustomExchange({
Request: {
amount: 2000,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index b702c72d04..78c4c8cdd8 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -552,6 +552,7 @@ export const CONNECTOR_LISTS = {
PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],
USE_BILLING_AS_PAYMENT_METHOD_BILLING: ["bankofamerica"],
MIT_WITH_LIMITED_CARD_DATA: ["peachpayments"],
+ REFUND_MANUAL_UPDATE: ["bankofamerica", "cybersource"],
// Add more inclusion lists
},
};
diff --git a/cypress-tests/cypress/e2e/spec/Payment/47-RefundManualUpdate.cy.js b/cypress-tests/cypress/e2e/spec/Payment/47-RefundManualUpdate.cy.js
new file mode 100644
index 0000000000..a3d4ebfcf4
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/47-RefundManualUpdate.cy.js
@@ -0,0 +1,542 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Refund Manual Update Tests", () => {
+ before(function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ const connector = globalState.get("connectorId");
+
+ if (
+ utils.shouldIncludeConnector(
+ connector,
+ utils.CONNECTOR_LISTS.INCLUDE.REFUND_MANUAL_UPDATE
+ )
+ ) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Manual Update - Status Change (pending -> failed)", () => {
+ it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update Status -> Retrieve Refund to Verify", () => {
+ 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",
+ "automatic",
+ 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 confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Create Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Create Refund");
+ return;
+ }
+ const refundData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Refund"];
+ cy.refundCallTest(fixtures.refundBody, refundData, globalState);
+ if (!utils.should_continue_further(refundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Manual Update Refund Status to Failed", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update Refund Status to Failed"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdate"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Refund to Verify Status Update", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Refund to Verify Status Update"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["SyncRefundManualUpdateFailed"];
+ cy.syncRefundCallTest(data, globalState);
+ });
+ });
+ });
+
+ context(
+ "Manual Update - Error Code and Error Message with SetOrUnset",
+ () => {
+ it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update Error Code/Message -> Retrieve Refund to Verify", () => {
+ 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",
+ "automatic",
+ 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 confirmData = getConnectorDetails(
+ globalState.get("connectorId")
+ )["card_pm"]["No3DSAutoCapture"];
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Create Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Create Refund");
+ return;
+ }
+ const refundData = getConnectorDetails(
+ globalState.get("connectorId")
+ )["card_pm"]["Refund"];
+ cy.refundCallTest(fixtures.refundBody, refundData, globalState);
+ if (!utils.should_continue_further(refundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Manual Update Error Code and Error Message", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update Error Code and Error Message"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdateErrorCode"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Refund to Verify Error Code and Message", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Refund to Verify Error Code and Message"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["SyncRefundManualUpdateErrorCode"];
+ cy.syncRefundCallTest(data, globalState);
+ });
+ });
+ }
+ );
+
+ context("Manual Update - Partial Refund Status Update", () => {
+ it("Create Payment Intent -> Confirm Payment -> Create Partial Refund -> Manual Update Status -> Retrieve Refund to Verify", () => {
+ 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",
+ "automatic",
+ 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 confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Create Partial Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Create Partial Refund");
+ return;
+ }
+ const partialRefundData = getConnectorDetails(
+ globalState.get("connectorId")
+ )["card_pm"]["PartialRefund"];
+ cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
+ if (!utils.should_continue_further(partialRefundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Manual Update Partial Refund Status to Failed", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update Partial Refund Status to Failed"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdatePartialRefund"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Partial Refund to Verify Status Update", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Partial Refund to Verify Status Update"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["SyncRefundManualUpdatePartialRefund"];
+ cy.syncRefundCallTest(data, globalState);
+ });
+ });
+ });
+
+ context("Manual Update - Idempotency Test (Multiple Updates)", () => {
+ it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update 1 -> Manual Update 2 (Same Data) -> Retrieve to Verify Idempotency", () => {
+ 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",
+ "automatic",
+ 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 confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Create Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Create Refund");
+ return;
+ }
+ const refundData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Refund"];
+ cy.refundCallTest(fixtures.refundBody, refundData, globalState);
+ if (!utils.should_continue_further(refundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Manual Update 1 - Set Error Code and Message", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update 1 - Set Error Code and Message"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdateIdempotency"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Manual Update 2 - Same Data (Idempotency Check)", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update 2 - Same Data (Idempotency Check)"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdateIdempotency"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Refund to Verify Idempotency", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Refund to Verify Idempotency"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["SyncRefundManualUpdateIdempotency"];
+ cy.syncRefundCallTest(data, globalState);
+ });
+ });
+ });
+
+ context("Manual Update - Unset Error Fields", () => {
+ it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update with Error -> Unset Error Fields -> Retrieve to Verify", () => {
+ 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",
+ "automatic",
+ 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 confirmData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["No3DSAutoCapture"];
+ cy.confirmCallTest(
+ fixtures.confirmBody,
+ confirmData,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(confirmData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Create Refund", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Create Refund");
+ return;
+ }
+ const refundData = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["Refund"];
+ cy.refundCallTest(fixtures.refundBody, refundData, globalState);
+ if (!utils.should_continue_further(refundData)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Manual Update with Error Code and Message", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update with Error Code and Message"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdateErrorCode"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Unset Error Code and Error Message", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Unset Error Code and Error Message"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualRefundUpdateUnset"];
+ cy.manualRefundStatusUpdateTest(data, globalState);
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Refund to Verify Unset Fields", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Refund to Verify Unset Fields"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["SyncRefundManualUpdateUnset"];
+ cy.syncRefundCallTest(data, globalState);
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/e2e/spec/Payment/50-RefundWebhook.cy.js b/cypress-tests/cypress/e2e/spec/Payment/50-RefundWebhook.cy.js
index 6b5610cf5a..fcb2709041 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/50-RefundWebhook.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/50-RefundWebhook.cy.js
@@ -116,8 +116,6 @@ describe("Refund Webhook Tests", () => {
connector = globalState.get("connectorId");
merchantId = globalState.get("merchantId");
- // Skip this context if connectorRefundId is not available
- // (sandbox connectors may not return it)
if (!globalState.get("connectorRefundId")) {
this.skip();
}
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index c0c3673fbb..7b40522e7b 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -6096,39 +6096,66 @@ Cypress.Commands.add(
}
);
-Cypress.Commands.add(
- "manualRefundStatusUpdateTest",
- (globalState, refundManualUpdateRequestBody) => {
- const merchantId = globalState.get("merchantId");
- const refundId = globalState.get("refundId");
- const completeUrl = `${Cypress.env("BASEURL")}/refunds/${refundId}/manual-update`;
- const adminApiKey = globalState.get("adminApiKey");
+Cypress.Commands.add("manualRefundStatusUpdateTest", (firstArg, secondArg) => {
+ let globalState;
+ let requestBody;
+ let resData = null;
+ let configs = {};
+
+ if (typeof secondArg?.get === "function") {
+ globalState = secondArg;
+ const {
+ Configs: cfg = {},
+ Request: reqData,
+ Response: rData,
+ } = firstArg || {};
+ configs = cfg;
+ resData = rData;
+ requestBody = { ...reqData, merchant_id: globalState.get("merchantId") };
+ } else {
+ globalState = firstArg;
+ requestBody = secondArg;
+ }
- cy.request({
- method: "PUT",
- url: completeUrl,
- headers: {
- "Content-Type": "application/json",
- "api-key": adminApiKey,
- "X-Merchant-Id": merchantId,
- },
- body: refundManualUpdateRequestBody,
- failOnStatusCode: false,
- }).then((response) => {
- logRequestId(response.headers["x-request-id"]);
+ const merchantId = globalState.get("merchantId");
+ const refundId = globalState.get("refundId");
+ const completeUrl = `${Cypress.env("BASEURL")}/refunds/${refundId}/manual-update`;
+ const adminApiKey = globalState.get("adminApiKey");
- cy.wrap(response).then(() => {
- if (response.status === 200) {
+ execConfig(validateConfig(configs));
+
+ cy.request({
+ method: "PUT",
+ url: completeUrl,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": adminApiKey,
+ "X-Merchant-Id": merchantId,
+ },
+ body: requestBody,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ if (response.status === 200) {
+ if (resData) {
+ expect(response.status).to.eq(resData?.status || 200);
+ } else {
expect(response.status).to.eq(200);
+ }
+ } else {
+ if (resData) {
+ defaultErrorHandler(response, resData);
} else {
throw new Error(
`Refund Manual Update Call Failed with error code "${response.body?.error?.code}" error message "${response.body?.error?.message}"`
);
}
- });
+ }
});
- }
-);
+ });
+});
Cypress.Commands.add(
"IncomingWebhookTest",