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

5.7 KB
Raw Blame
import * as fixtures from "../../../fixtures/imports";
import State from "../../../utils/State";
import * as utils from "../../configs/Payout/Utils";

let globalState;
let payoutBody;

describe("[Payout] Wallet Payout", () => {
  let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

  before("seed global state", () => {
    cy.task("getGlobalState").then((state) => {
      globalState = new State(state);

      if (!globalState.get("payoutsExecution")) {
        shouldContinue = false;
      }

      if (
        !utils.CONNECTOR_LISTS.INCLUDE.WALLET_PAYOUT.includes(
          globalState.get("connectorId")
        )
      ) {
        shouldContinue = false;
      }
    });
  });

  after("flush global state", () => {
    cy.task("setGlobalState", globalState.data);
  });

  beforeEach(function () {
    if (!shouldContinue) {
      this.skip();
    }
    payoutBody = Cypress._.cloneDeep(fixtures.createPayoutBody);
  });

  context("[Payout] Wallet Payout with Manual Fulfill", () => {
    let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

    beforeEach(function () {
      if (!shouldContinue) {
        this.skip();
      }
    });

    it("create-payout-call-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["Create"];

      cy.createConfirmPayoutTest(payoutBody, data, false, false, globalState);
      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });

    it("confirm-payout-call-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["Confirm"];

      cy.confirmPayoutCallTest({}, data, false, globalState);
      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });

    it("fulfill-payout-call-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["Fulfill"];

      cy.fulfillPayoutCallTest({}, data, globalState);
    });

    it("retrieve-payout-after-fulfill-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["RetrieveAfterFulfill"];

      cy.retrievePayoutCallTest(globalState, data);
    });
  });

  context("[Payout] Wallet Payout with Venmo Receiver", () => {
    let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

    beforeEach(function () {
      if (!shouldContinue) {
        this.skip();
      }
    });

    it("create-venmo-wallet-payout-call-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["CreateVenmo"];

      cy.createConfirmPayoutTest(payoutBody, data, false, false, globalState);
      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });

    it("confirm-venmo-wallet-payout-call-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["ConfirmVenmo"];

      cy.confirmPayoutCallTest({}, data, false, globalState);
      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });

    // Expected-skip gate for connectors listed in
    // CONNECTOR_LISTS.EXCLUDE.VENMO_WALLET_FULFILL (Payout/Utils.js).
    // PayPal sandbox does not support Venmo recipient wallets: the fulfill
    // call is hard-rejected with HTTP 400 IR_41 / unified_code UE_9000
    // "Recipient wallet not supported in sandbox." (deterministic across
    // retries — verified in the CLA-440 pipeline runs). The FulfillVenmo
    // config key encodes the production behaviour (200 / "pending") and
    // stays untouched, so this step is gated as a documented expected-skip
    // instead of a deterministic failure. Venmo create/confirm/retrieve
    // coverage is unaffected. Remove the connector from the exclusion list
    // once its sandbox supports Venmo recipient wallets.
    it("fulfill-venmo-wallet-payout-call-test", function () {
      if (
        utils.shouldExcludeConnector(
          globalState.get("connectorId"),
          utils.CONNECTOR_LISTS.EXCLUDE.VENMO_WALLET_FULFILL
        )
      ) {
        this.skip();
      }

      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["FulfillVenmo"];

      cy.fulfillPayoutCallTest({}, data, globalState);
    });

    it("retrieve-venmo-wallet-payout-after-fulfill-test", () => {
      cy.retrievePayoutCallTest(globalState);
    });
  });

  context("[Payout] Wallet Payout Fulfill with Missing Receiver Data", () => {
    let shouldContinue = true; // variable that will be used to skip tests if a previous test fails

    beforeEach(function () {
      if (!shouldContinue) {
        this.skip();
      }
    });

    it("create-confirm-payout-with-missing-receiver-data-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["MissingReceiverDataConfirm"];

      cy.createConfirmPayoutTest(payoutBody, data, true, false, globalState);
      if (shouldContinue) shouldContinue = utils.should_continue_further(data);
    });

    it("fulfill-payout-with-missing-receiver-data-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["MissingReceiverDataFulfill"];

      cy.fulfillPayoutCallTest({}, data, globalState);
    });

    it("retrieve-payout-after-failed-fulfill-test", () => {
      const data = utils.getConnectorDetails(globalState.get("connectorId"))[
        "wallet_pm"
      ]["MissingReceiverDataRetrieveAfterFulfill"];

      cy.retrievePayoutCallTest(globalState, data);
    });
  });
});