@cfxlabsinc/b2b-services
    Preparing search index...
    Index
    instance: (...args: []) => WithdrawalWorkflowService = ...

    The process default: retries start on the queue the temporal namespace names.

    • Starts the top-level cancelLedgerAccountWithdrawalWorkflow which voids the redemption (skipped for batched ACH-credit), undoes any virtual account sweep, and refunds the user's ledger account to flip the withdrawal to RETURNED. skipReturn marks the withdrawal FAILED instead and sends the funds to refundLedgerAccountId when given; skipSweepUndo leaves a performed virtual account sweep in place. Uses a distinct workflow id (cancel-<id>) so it doesn't collide with the still-pending initiate workflow handle that owns <id>.

      Parameters

      • __namedParameters: Pick<
            {
                createdAt: Date;
                customerId: string;
                data: {
                    achTraceId?: string;
                    addenda?: string;
                    companyEntryDescription?: string;
                    companyId?: string;
                    companyName?: string;
                    effectiveEntryDate?: string;
                    imad?: string;
                    methodTransactionId?: string;
                    omad?: string;
                    originatorName?: string;
                    routeFusionTransferId?: string;
                    secCode?: string;
                    settlementDate?: string;
                    signedTransaction?: string;
                    victorTraceId?: string;
                    victorTransactionId?: string;
                };
                entityId: string;
                entityType: "IDENTITY"
                | "ORGANIZATION";
                feeSweepTxId: string | null;
                feeSweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                history: WithdrawalStatusUpdateHistory[];
                id: string;
                quote: {
                    createdAt: Date;
                    customerId: string;
                    deviceIpAddress: string | null;
                    deviceLocation: { lat: number; long: number; source: "ip" } | null;
                    entityId: string;
                    expiresAt: Date;
                    fees: (
                        {
                            amount: BigNumber;
                            receiver: "CUSTOMER"
                            | "PROVIDER"
                            | "CFX";
                            type: "FIXED" | "VARIABLE";
                        } & { currency: string }
                    )[];
                    id: string;
                    metadata: {
                        brand?: string;
                        marketing?: {
                            fbp?: string;
                            gclid?: string;
                            sub1?: string;
                            sub2?: string;
                            sub3?: string;
                            userAgent?: string;
                            utmCampaign?: string;
                            utmContent?: string;
                            utmMedium?: string;
                            utmSource?: string;
                        };
                    };
                    methodData: | {
                        achBatchId?: string;
                        bankId?: string;
                        sourceLedgerAccountId?: string;
                        speed?: "same-day"
                        | "next-day";
                        type: "ACH_CREDIT";
                        vendorId?: string;
                    }
                    | {
                        achId: string;
                        bankId?: string;
                        sourceLedgerAccountId?: string;
                        type: "ACH_DEBIT";
                        vendorId?: string;
                    }
                    | {
                        bankId?: string;
                        beneficiaryReference?: string;
                        purpose: WireWithdrawalPurpose;
                        senderMessage?: string;
                        sourceLedgerAccountId: string;
                        type: "SWIFT_WIRE"
                        | "US_WIRE";
                        vendorId?: string;
                        wireBatchId?: string;
                    }
                    | {
                        country: string;
                        sourceLedgerAccountId?: string;
                        type: "AF_WITHDRAWAL";
                        withdrawalType: "bank"
                        | "momo";
                    }
                    | {
                        asset?: {
                            decimals: number;
                            mint: string;
                            symbol: string;
                            tokenProgram: string;
                        };
                        sourceLedgerAccountId: string;
                        type: "BLOCKCHAIN";
                    }
                    | {
                        bankId?: string;
                        sourceLedgerAccountId?: string;
                        type: "US_INSTANT";
                        vendorId?: string;
                    }
                    | {
                        bankId?: string;
                        drawdownId: string;
                        sourceAccountId: string;
                        type: "US_WIRE_DRAWDOWN";
                        vendorId?: string;
                    }
                    | null;
                    methodId: | "ACH_CREDIT"
                    | "ACH_DEBIT"
                    | "BLOCKCHAIN"
                    | "MX_SPEI"
                    | "US_WIRE_DRAWDOWN"
                    | "US_INSTANT"
                    | "SWIFT_WIRE"
                    | "US_WIRE"
                    | "AF_WITHDRAWAL";
                    paymentInstrumentId: string;
                    productQuoteId: string;
                    providerQuoteId: string
                    | null;
                    sourceAmount: BigNumber;
                    sourceAmountAfterFees: BigNumber;
                    sourceCurrency: string;
                    status: "ACTIVE" | "ACCEPTED" | "REJECTED" | "EXPIRED";
                    targetAmount: BigNumber;
                    targetAmountAfterFees: BigNumber;
                    targetCurrency: string;
                    unsignedWithdrawalTransaction: string | null;
                    updatedAt: Date;
                    walletAddress: Address;
                    walletBlockchain: string;
                };
                receiptId: string
                | null;
                receiptType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                returnReceiptId: string | null;
                status: "PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED";
                statusDescription: string;
                sweepTxId: string | null;
                sweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                type:
                    | "ACH_CREDIT"
                    | "ACH_DEBIT"
                    | "BLOCKCHAIN"
                    | "MX_SPEI"
                    | "US_WIRE_DRAWDOWN"
                    | "US_INSTANT"
                    | "SWIFT_WIRE"
                    | "US_WIRE"
                    | "AF_WITHDRAWAL";
                updatedAt: Date;
            },
            "id",
        > & {
            reason?: string;
            refundLedgerAccountId?: string;
            skipReturn?: boolean;
            skipSweepUndo?: boolean;
        }
        • Optionalreason?: string

          Operator-entered reason, recorded on the FAILED/RETURNED transition.

        • OptionalrefundLedgerAccountId?: string

          With skipReturn, the ledger account the funds go to instead.

        • OptionalskipReturn?: boolean
        • OptionalskipSweepUndo?: boolean

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

    • Re-kicks the rail-appropriate initiate*WithdrawalWorkflow for a stuck withdrawal, refusing one already COMPLETED, FAILED or RETURNED. Idempotent: skips the start if the existing workflow handle (workflowId = withdrawalId) is still RUNNING, mirroring LedgerAccountTransferWorkflowService.create.

      Parameters

      Returns Promise<
          | { ok: true; value: void }
          | {
              error:
                  | ServiceError<"WITHDRAWAL_NOT_FOUND", { id: string }>
                  | ServiceError<
                      "WITHDRAWAL_RETRY_UNSUPPORTED",
                      {
                          methodId: | "ACH_CREDIT"
                          | "ACH_DEBIT"
                          | "BLOCKCHAIN"
                          | "MX_SPEI"
                          | "US_WIRE_DRAWDOWN"
                          | "US_INSTANT"
                          | "SWIFT_WIRE"
                          | "US_WIRE"
                          | "AF_WITHDRAWAL";
                      },
                  >
                  | ServiceError<
                      "WITHDRAWAL_NOT_RETRYABLE",
                      {
                          status: | "PENDING"
                          | "FAILED"
                          | "PROCESSING"
                          | "COMPLETED"
                          | "RETURNED";
                      },
                  >;
              ok: false;
          },
      >