Repository: juspay/hyperswitch
File: cypress-tests/cypress/e2e/spec/Payment/00029-IncrementalAuth.cy.js (JavaScript)

Code before:
        "card_pm"
      ]["SaveCardUseNo3DSManualCaptureOffSession"];

      cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);

      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });
    it("[Payment] Incremental Authorization", () => {
      const data = getConnectorDetails(globalState.get("connectorId"))[
        "card_pm"
      ]["IncrementalAuth"];
      cy.incrementalAuth(globalState, data);

      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });
    it("[Payment] Capture Payment Intent", () => {
      const data = getConnectorDetails(globalState.get("connectorId"))[
        "card_pm"
      ]["Capture"];

      const newData = {
        ...data,
        Request: { amount_to_capture: data.Request.amount_to_capture + 1000 },
      };

      cy.captureCallTest(fixtures.captureBody, newData, globalState);

      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });
  });

  context("[Payment] [Saved Card] Incremental Pre-Auth", () => {
    let shouldContinue = true;

    beforeEach(function () {
      if (!shouldContinue || connector !== "cybersource") {
        this.skip();
      }
    });

    it("[Payment] List customer payment methods", () => {
      cy.listCustomerPMCallTest(globalState);
    });
    it("[Payment] Create Payment Intent", () => {
      const data = getConnectorDetails(globalState.get("connectorId"))[
        "card_pm"
      ]["PaymentIntentOffSession"];

      cy.createPaymentIntentTest(
        fixtures.createPaymentBody,
        data,

Review comment (security):
It was capturing the `previously_authorized_amount`, which resulted the terminal payment status to be `partially_captured`. Therefore, there were two options, either add a custom response assertion in the `Capture` config of the connector, or just update the value in the cypress test case itself, because it will be only the case for Incremental Auth only. So, found it more relevant to do it over here. However, the increased amount has been hard-coded to 1000.

Code after:
        "card_pm"
      ]["SaveCardUseNo3DSManualCaptureOffSession"];

      cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);

      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });
    it("[Payment] Incremental Authorization", () => {
      const data = getConnectorDetails(globalState.get("connectorId"))[
        "card_pm"
      ]["IncrementalAuth"];
      cy.incrementalAuth(globalState, data);

      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });
    it("[Payment] Capture Payment Intent", () => {
      const data = getConnectorDetails(globalState.get("connectorId"))[
        "card_pm"
      ]["Capture"];

      const newData = {
        ...data,
        Request: { amount_to_capture: data.Request.amount_to_capture + 2000 },
      };

      cy.captureCallTest(fixtures.captureBody, newData, globalState);

      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });
  });

  context("[Payment] [Saved Card] Incremental Pre-Auth", () => {
    let shouldContinue = true;

    beforeEach(function () {
      if (!shouldContinue || connector !== "cybersource") {
        this.skip();
      }
    });

    it("[Payment] List customer payment methods", () => {
      cy.listCustomerPMCallTest(globalState);
    });
    it("[Payment] Create Payment Intent", () => {
      const data = getConnectorDetails(globalState.get("connectorId"))[
        "card_pm"
      ]["PaymentIntentOffSession"];

      cy.createPaymentIntentTest(
        fixtures.createPaymentBody,
        data,