@cfxlabsinc/b2b-services
    Preparing search index...

    Service responsible for handling withdrawal reconciliation operations.

    Only use this if the withdrawal method maps 1:1 with a bank transaction.

    Index
    instance: (...args: []) => AchDebitWithdrawalReconciliationService = ...

    The process service, starting workflows on the temporal namespace's queue.

    • Create a pending ACH debit authorization for an inbound debit against a virtual account.

      Parameters

      • args: {
            accountNumber: string;
            achId: string;
            amount: string;
            originatorName: string | null;
            settled?: true;
        }
        • accountNumber: string
        • achId: string
        • amount: string
        • originatorName: string | null
        • Optionalsettled?: true

          The debit has already posted: quote it as CFX's own request with limits off, since refusing it cannot return the money. Unset for positive pay.

      Returns Promise<
          | { withdrawalId: string }
          | { refused: { code: string; message: string } }
          | null,
      >

    • Parameters

      • args: { bankTransactionId: string; withdrawalId: string }

      Returns Promise<
          | { ok: true; value: void }
          | {
              error:
                  | ServiceError<"REDEMPTION_NOT_FOUND", { redemptionId: string }>
                  | ServiceError<"REDEMPTION_NOT_PENDING", { redemptionId: string }>
                  | ServiceError<"INVALID_BANK_TX", { bankTransactionId: string }>
                  | ServiceError<
                      "AMOUNT_MISMATCH",
                      { bankTransactionAmount: string; expectedAmount: string },
                  >
                  | ServiceError<
                      "WITHDRAWAL_NOT_FOUND",
                      { redemptionId: string; withdrawalId: string },
                  >
                  | ServiceError<"WITHDRAWAL_NOT_FOUND", { withdrawalId: string }>
                  | ServiceError<"INVALID_BANK_TX", { bankTransactionId: string }>
                  | ServiceError<
                      "WITHDRAWAL_ALREADY_RECONCILED",
                      { existingWithdrawalId: string; withdrawalId: string },
                  >
                  | ServiceError<
                      "AMOUNT_MISMATCH",
                      { bankTransactionAmount: string; withdrawalAmount: string },
                  >
                  | ServiceError<"REDEMPTION_NOT_FOUND", { withdrawalId: string }>;
              ok: false;
          },
      >

    • Find a pending ACH_DEBIT withdrawal by achId and reconcile it with the given bank transaction.

      When no authorization exists the debit has still settled, so this creates the same one the Pending webhook would have. That webhook is the only thing that normally opens the authorization, and a dropped delivery used to leave the bank transaction unreconciled and skip the FBO -> vacct sweep, which runs inside the withdrawal workflow and is keyed on the withdrawal. Callers must therefore only reach here for debits they have already established are real (see isAllZeroAchTrace on the webhook path).

      Parameters

      • args: {
            accountNumber: string;
            achId: string;
            amount: string;
            bankTransactionId: string;
            originatorName: string | null;
        }

      Returns Promise<
          | { ok: true; value: void }
          | {
              error:
                  | ServiceError<"REDEMPTION_NOT_FOUND", { redemptionId: string }>
                  | ServiceError<"REDEMPTION_NOT_PENDING", { redemptionId: string }>
                  | ServiceError<"INVALID_BANK_TX", { bankTransactionId: string }>
                  | ServiceError<
                      "AMOUNT_MISMATCH",
                      { bankTransactionAmount: string; expectedAmount: string },
                  >
                  | ServiceError<
                      "WITHDRAWAL_NOT_FOUND",
                      { redemptionId: string; withdrawalId: string },
                  >
                  | ServiceError<"WITHDRAWAL_NOT_FOUND", { withdrawalId: string }>
                  | ServiceError<"INVALID_BANK_TX", { bankTransactionId: string }>
                  | ServiceError<
                      "WITHDRAWAL_ALREADY_RECONCILED",
                      { existingWithdrawalId: string; withdrawalId: string },
                  >
                  | ServiceError<
                      "AMOUNT_MISMATCH",
                      { bankTransactionAmount: string; withdrawalAmount: string },
                  >
                  | ServiceError<"REDEMPTION_NOT_FOUND", { withdrawalId: string }>
                  | ServiceError<
                      "WITHDRAWAL_STILL_PENDING",
                      { achId: string; withdrawalId: string },
                  >;
              ok: false;
          },
      >

    • Cancels a denied debit's withdrawal and returns what it set aside. A run still open at the withdrawal id can yet fund it, and a cancel beside it would miss that, so this answers WITHDRAWAL_INITIATE_RUNNING until it closes.

      Parameters

      • args: { withdrawalId: string }

      Returns Promise<
          | { ok: true; value: void }
          | {
              error:
                  | ServiceError<"WITHDRAWAL_NOT_FOUND", { withdrawalId: string }>
                  | ServiceError<"WITHDRAWAL_INITIATE_RUNNING", { withdrawalId: string }>;
              ok: false;
          },
      >