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 manual payment update coverage for stripe (#12126)

HS-QUALIBOT52302ffa944c
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 89ad040063..dafab3127a 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -2950,6 +2950,30 @@ export const connectorDetails = {
currency: "USD",
},
}),
+ ManualPaymentUpdate: getCustomExchange({
+ Request: {
+ attempt_status: "pending",
+ error_code: "TEST_ERROR",
+ error_message: "Manual test error message",
+ },
+ Response: {
+ status: 200,
+ body: {
+ attempt_status: "pending",
+ },
+ },
+ }),
+ ManualPaymentUpdateStatusOnly: getCustomExchange({
+ Request: {
+ attempt_status: "pending",
+ },
+ Response: {
+ status: 200,
+ body: {
+ attempt_status: "pending",
+ },
+ },
+ }),
OrderDetails: getCustomExchange({
Request: {
payment_method: "card",
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 4838564a81..bb6ceff1d0 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -591,6 +591,7 @@ export const CONNECTOR_LISTS = {
CARD_TESTING_GUARD: ["bankofamerica"],
L2L3DATA: ["checkout", "nuvei", "worldpayvantiv"],
REFUND_MANUAL_UPDATE: ["bankofamerica", "cybersource"],
+ MANUAL_PAYMENT_UPDATE: ["stripe"],
STEP_UP_RETRY: [
"cybersource",
"checkout",
diff --git a/cypress-tests/cypress/e2e/spec/Payment/47-ManualPaymentUpdate.cy.js b/cypress-tests/cypress/e2e/spec/Payment/47-ManualPaymentUpdate.cy.js
new file mode 100644
index 0000000000..dac2cdc64f
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/47-ManualPaymentUpdate.cy.js
@@ -0,0 +1,257 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let connector;
+let globalState;
+
+describe("Payment Manual Update Tests", () => {
+ before(function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ connector = globalState.get("connectorId");
+
+ if (
+ utils.shouldIncludeConnector(
+ connector,
+ utils.CONNECTOR_LISTS.INCLUDE.MANUAL_PAYMENT_UPDATE
+ )
+ ) {
+ skip = true;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ this.skip();
+ }
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Manual Payment Update - Happy Path", () => {
+ it("Create Payment Intent -> Manual Update -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent with Manual Capture", () => {
+ 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("Manual Update Payment Attempt", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Manual Update Payment Attempt");
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualPaymentUpdate"];
+
+ cy.manualPaymentStatusUpdateTest(globalState, data);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment to Verify Manual Update", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Payment to Verify Manual Update"
+ );
+ return;
+ }
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ },
+ unconfirmedPayment: true,
+ });
+ });
+ });
+ });
+
+ context("Manual Payment Update - Status Only", () => {
+ it("Create Payment Intent -> Manual Update Status Only -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent with Manual Capture", () => {
+ 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("Manual Update Payment Status Only", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update Payment Status Only"
+ );
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualPaymentUpdateStatusOnly"];
+
+ cy.manualPaymentStatusUpdateTest(globalState, data);
+ });
+
+ cy.step("Retrieve Payment to Verify Status Update", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Payment to Verify Status Update"
+ );
+ return;
+ }
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ },
+ unconfirmedPayment: true,
+ });
+ });
+ });
+ });
+
+ context("Manual Payment Update - Negative Cases", () => {
+ it("Create Payment Intent -> Manual Update with Invalid Attempt ID", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent with Manual Capture", () => {
+ 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("Manual Update with Invalid Attempt ID", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update with Invalid Attempt ID"
+ );
+ return;
+ }
+
+ cy.manualPaymentUpdateNegativeTest(globalState, "invalid_attempt_id");
+ });
+ });
+ });
+
+ context("Manual Payment Update - Edge Cases", () => {
+ it("Create Payment Intent -> Manual Update with Custom Error -> Verify Persistence", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent with Manual Capture", () => {
+ 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("Manual Update with Custom Error Code and Message", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Manual Update with Custom Error Code and Message"
+ );
+ return;
+ }
+
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["ManualPaymentUpdate"];
+
+ cy.manualPaymentStatusUpdateTest(globalState, data);
+
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Retrieve Payment to Verify Persistence", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Retrieve Payment to Verify Persistence"
+ );
+ return;
+ }
+
+ cy.retrievePaymentCallTest({
+ globalState,
+ data: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ },
+ unconfirmedPayment: true,
+ });
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 9d3326b306..95a4ea1cef 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -3782,6 +3782,7 @@ Cypress.Commands.add(
attempt = 1,
expectedIntentStatus,
connectedMerchantId,
+ unconfirmedPayment = false,
}) => {
const { Configs: configs = {} } = data || {};
@@ -3800,9 +3801,13 @@ Cypress.Commands.add(
headers["x-connected-merchant-id"] = connectedMerchantId;
}
+ const queryParams = unconfirmedPayment
+ ? "expand_attempts=true"
+ : "force_sync=true&expand_attempts=true";
+
cy.request({
method: "GET",
- url: `${globalState.get("baseUrl")}/payments/${payment_id}?force_sync=true&expand_attempts=true`,
+ url: `${globalState.get("baseUrl")}/payments/${payment_id}?${queryParams}`,
headers: headers,
failOnStatusCode: false,
}).then((response) => {
@@ -3832,6 +3837,7 @@ Cypress.Commands.add(
}
if (
+ !unconfirmedPayment &&
["succeeded", "processing", "requires_customer_action"].includes(
response.body.status
)
@@ -6730,14 +6736,92 @@ Cypress.Commands.add("diffCheckResult", (globalState) => {
});
});
+Cypress.Commands.add("manualPaymentStatusUpdateTest", (globalState, data) => {
+ const requestData = data.Request || data;
+ const responseData = data.Response || { status: 200, body: {} };
+
+ const merchantId = globalState.get("merchantId");
+ const paymentId = globalState.get("paymentID");
+ const completeUrl = `${Cypress.env("BASEURL")}/payments/${paymentId}/manual-update`;
+ const adminApiKey = globalState.get("adminApiKey");
+
+ const manualUpdateBody = {
+ merchant_id: merchantId,
+ attempt_id: `${paymentId}_1`,
+ attempt_status: requestData.attempt_status,
+ };
+
+ if (requestData.error_code) {
+ manualUpdateBody.error_code = requestData.error_code;
+ }
+
+ if (requestData.error_message) {
+ manualUpdateBody.error_message = requestData.error_message;
+ }
+
+ cy.request({
+ method: "PUT",
+ url: completeUrl,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": adminApiKey,
+ "X-Merchant-Id": merchantId,
+ },
+ body: manualUpdateBody,
+ failOnStatusCode: false,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+
+ const expectedStatus = responseData.status || 200;
+ expect(response.status).to.eq(expectedStatus);
+
+ if (response.status === 200) {
+ expect(response.body.payment_id).to.equal(paymentId);
+ expect(response.body.merchant_id).to.equal(merchantId);
+
+ if (responseData.body && responseData.body.attempt_status) {
+ expect(response.body.attempt_status).to.equal(
+ responseData.body.attempt_status
+ );
+ }
+
+ if (responseData.body && responseData.body.error_code) {
+ expect(response.body.error_code).to.equal(
+ responseData.body.error_code
+ );
+ }
+
+ if (responseData.body && responseData.body.error_message) {
+ expect(response.body.error_message).to.equal(
+ responseData.body.error_message
+ );
+ }
+ } else {
+ throw new Error(
+ `Payment Update Call Failed with error code "${response.body.error.code}" error message "${response.body.error.message}"`
+ );
+ }
+ });
+ });
+});
+
Cypress.Commands.add(
- "manualPaymentStatusUpdateTest",
- (globalState, PaymentsManualUpdateRequestBody) => {
+ "manualPaymentUpdateNegativeTest",
+ (globalState, invalidAttemptId) => {
const merchantId = globalState.get("merchantId");
const paymentId = globalState.get("paymentID");
const completeUrl = `${Cypress.env("BASEURL")}/payments/${paymentId}/manual-update`;
const adminApiKey = globalState.get("adminApiKey");
+ const manualUpdateBody = {
+ merchant_id: merchantId,
+ attempt_id: invalidAttemptId,
+ attempt_status: "pending",
+ };
+
cy.request({
method: "PUT",
url: completeUrl,
@@ -6746,90 +6830,47 @@ Cypress.Commands.add(
"api-key": adminApiKey,
"X-Merchant-Id": merchantId,
},
- body: PaymentsManualUpdateRequestBody,
+ body: manualUpdateBody,
failOnStatusCode: false,
}).then((response) => {
- logRequestId(response.headers["x-request-id"]);
-
- cy.wrap(response).then(() => {
- expect(response.headers["content-type"]).to.include("application/json");
- if (response.status === 200) {
- expect(response.status).to.eq(200);
- expect(response.body.payment_id).to.equal(paymentId);
- expect(response.body.merchant_id).to.equal(merchantId);
- expect(response.body.attempt_status).to.equal(
- PaymentsManualUpdateRequestBody.attempt_status
- );
- } else {
- throw new Error(
- `Payment Update Call Failed with error code "${response.body.error.code}" error message "${response.body.error.message}"`
- );
- }
- });
+ expect(response.status).to.be.oneOf([400, 404]);
});
}
);
-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;
- }
-
- const merchantId = globalState.get("merchantId");
- const refundId = globalState.get("refundId");
- const completeUrl = `${Cypress.env("BASEURL")}/refunds/${refundId}/manual-update`;
- const adminApiKey = globalState.get("adminApiKey");
-
- execConfig(validateConfig(configs));
+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");
- 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.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"]);
- cy.wrap(response).then(() => {
- if (response.status === 200) {
- if (resData) {
- expect(response.status).to.eq(resData?.status || 200);
- } else {
+ cy.wrap(response).then(() => {
+ if (response.status === 200) {
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",