import { z } from 'zod'; import { WompiError, Result, Merchant, Transaction, VoidTransactionResult, CardToken, NequiToken, PaymentSource, PaymentLink, FinancialInstitution, BrebKeyResolution, CreatePayoutResult, PayoutPage, Payout, PayoutTransaction, PayoutBank, PayoutAccount, PayoutLimits, PayoutReportPage, PayoutHealth } from './schemas.cjs'; import 'buffer'; type WompiRequestConfig = { sandbox?: boolean; timeoutMs?: number; /** Overrides the payments base URL — used by the Payouts API, which lives on its own host. */ baseUrl?: string; /** Maps product-specific non-2xx response bodies without leaking them into the shared transport. */ errorMapper?: (statusCode: number, body: unknown) => WompiError | null; }; declare class WompiRequest { private readonly baseUrl; private readonly timeoutMs; private readonly errorMapper?; constructor(config?: WompiRequestConfig); private request; protected get(endpoint: string, schema: z.ZodType, headers?: Record): Promise>; protected post(endpoint: string, schema: z.ZodType, body?: unknown, headers?: Record): Promise>; protected patch(endpoint: string, schema: z.ZodType, body?: unknown, headers?: Record): Promise>; } declare class Merchants extends WompiRequest { private readonly publicKey; constructor(publicKey: string, sandbox?: boolean); /** * Get merchant info and the presigned acceptance token. * No authentication required (public key is used as a path parameter). */ getMerchant(): Promise>; } declare class Transactions extends WompiRequest { private readonly publicKey; private readonly privateKey; constructor(publicKey: string, privateKey: string | undefined, sandbox?: boolean); /** * Get a single transaction by ID. * No authentication required. */ getTransaction(id: string): Promise>; /** * List transactions matching filter criteria. * Requires private key (BearerPrivateKey). */ listTransactions(params?: unknown): Promise>; /** * Create a new transaction. * Requires public key (BearerPublicKey). If using payment_source_id, use private key instead. */ createTransaction(input: unknown): Promise>; /** * Void an approved CARD transaction. * Requires private key (BearerPrivateKey). * * On success the result carries the void outcome, with the voided transaction * under `.transaction`; it resolves to `undefined` for an empty `201`. */ voidTransaction(transactionId: string, input?: unknown): Promise>; private buildQueryUrl; } declare class Tokens extends WompiRequest { private readonly publicKey; constructor(publicKey: string, sandbox?: boolean); /** * Tokenize a credit card for use in transactions or payment sources. * Requires public key (BearerPublicKey). */ tokenizeCard(input: unknown): Promise>; /** * Tokenize a Nequi account for use in transactions or payment sources. * Requires public key (BearerPublicKey). */ tokenizeNequi(input: unknown): Promise>; /** * Get the status of a tokenized Nequi account. * Requires public key (BearerPublicKey). */ getNequiToken(tokenId: string): Promise>; } declare class PaymentSources extends WompiRequest { private readonly privateKey; constructor(privateKey: string | undefined, sandbox?: boolean); /** * Get a payment source by ID. * Requires private key (BearerPrivateKey). */ getPaymentSource(id: number): Promise>; /** * Create a new payment source (CARD or NEQUI). * Requires private key (BearerPrivateKey). */ createPaymentSource(input: unknown): Promise>; } declare class PaymentLinks extends WompiRequest { private readonly privateKey; constructor(privateKey: string | undefined, sandbox?: boolean); /** * Get a payment link by ID. * No authentication required. */ getPaymentLink(id: string): Promise>; /** * Create a new payment link. * Requires private key (BearerPrivateKey). */ createPaymentLink(input: unknown): Promise>; /** * Activate or deactivate a payment link. * Requires private key (BearerPrivateKey). */ updatePaymentLink(id: string, input: unknown): Promise>; } declare class PSE extends WompiRequest { private readonly publicKey; constructor(publicKey: string, sandbox?: boolean); /** * Get the list of PSE financial institutions. * Requires public key (BearerPublicKey). */ getFinancialInstitutions(): Promise>; } declare class WompiClient { /** Merchant operations (get merchant info, acceptance token). */ readonly merchants: Merchants; /** Transaction operations (create, get, list, void). */ readonly transactions: Transactions; /** Token operations (tokenize cards, Nequi accounts). */ readonly tokens: Tokens; /** Payment source operations (create, get). Requires private key. */ readonly paymentSources: PaymentSources; /** Payment link operations (create, get, update). Requires private key for write operations. */ readonly paymentLinks: PaymentLinks; /** PSE operations (list financial institutions). */ readonly pse: PSE; constructor(options: unknown); } /** * Client for Wompi's Pagos a Terceros (Payouts) API — bank account and BRE-B * key dispersions. * * This API lives on its own host and authenticates with the `x-api-key` and * `user-principal-id` headers from the Payouts developers section of the Wompi * dashboard, so it is a separate client from {@link WompiClient}. The same * credentials cover both bank batches and BRE-B key dispersions. * * @example * ```ts * const payouts = new WompiPayoutsClient({ * apiKey: process.env.WOMPI_PAYOUTS_API_KEY!, * userPrincipalId: process.env.WOMPI_PAYOUTS_USER_PRINCIPAL_ID!, * sandbox: true, * }); * * const [error, created] = await payouts.createPayout( * { * reference: "payroll-2026-07", * accountId: "account-id", * paymentType: "PAYROLL", * transactions: [ * { * legalIdType: "CC", * legalId: "1000000000", * bankId: "bank-id", * accountType: "AHORROS", * accountNumber: "12345678", * personType: "NATURAL", * name: "John Doe", * email: "john@example.com", * amount: 1_000_000, * }, * ], * }, * { idempotencyKey: "payroll-2026-07" } * ); * ``` */ declare class WompiPayoutsClient extends WompiRequest { private readonly authHeaders; private readonly sandbox; constructor(options: unknown); /** * Resolve a BRE-B key (`GET /v2/breb/keys/resolve/{keyValue}`) and get the * masked holder information before paying. Read-only: no transaction or fund * movement happens, and no idempotency key is involved. Show the holder data * to your user for confirmation before creating the payout — full holder * details are never returned through this endpoint. * * @param keyValue The BRE-B key (e.g. `@JUANPEREZ`, `juan@email.com`, `3001234567`). * @param keyType Optional; when sent, Wompi validates the key format against * it. Recommended to avoid ambiguity — a 10-digit value could be a phone * number or an identification document. */ resolveBrebKey(keyValue: string, keyType?: unknown): Promise>; /** * Create a payout batch (`POST /payouts`) with the transaction detail as JSON. * * Each transaction pays its beneficiary either into a bank account (`bankId` * + `accountType` + `accountNumber`) or through a BRE-B `key`, and both kinds * can be mixed in one batch. Bank-only batches go to `/v1/payouts`; as soon * as any transaction carries a `key`, the batch is routed to `/v2/payouts`, * the version that resolves BRE-B keys. * * Immediate by default; add `dispersionDatetime` to schedule it, and * `recurring` on top of that for recurring batches. Wompi rejects a reused * `idempotencyKey` (`EXC_022`/`EXC_032`) within 24 hours; persist the * returned payout ID and reference for retries beyond that window. */ createPayout(input: unknown, options: { idempotencyKey: string; }): Promise>; /** * Create a payout batch from a file (`POST /payouts/file`) in one of the * supported bank formats (WOMPI CSV, PAB, SAP, DISFON, BANCO_OCCIDENTE_FC, * DAVIVIENDA). Gzipped files also require `fileName` and `fileMime`. */ createPayoutFromFile(input: unknown, options: { idempotencyKey: string; }): Promise>; /** List payout batches (`GET /payouts`), optionally filtered and paginated. */ listPayouts(params?: unknown): Promise>>; /** * Get a single payout batch by ID (`GET /payouts/{payoutId}`). * * Bank batches default to `/v1`; pass `apiVersion: "v2"` for BRE-B or * mixed batches created through `/v2/payouts`. */ getPayout(payoutId: string, options?: { apiVersion?: "v1" | "v2"; }): Promise>; /** * List the transactions of a batch (`GET /payouts/{payoutId}/transactions`). * * Bank batches default to `/v1`; pass `apiVersion: "v2"` for BRE-B or * mixed batches created through `/v2/payouts`. */ listPayoutTransactions(payoutId: string, params?: unknown, options?: { apiVersion?: "v1" | "v2"; }): Promise>>; /** Get a single transaction of a batch (`GET /payouts/{payoutId}/transactions/{transactionId}`). */ getPayoutTransaction(payoutId: string, transactionId: string): Promise>; /** List a batch's transactions by the payout reference (`GET /transactions/{reference}`). */ listTransactionsByReference(payoutReference: string, params?: unknown): Promise>>; /** List the banks available as dispersion destinations (`GET /banks`). */ listBanks(): Promise>; /** * List the merchant's origin accounts with their balance (`GET /accounts`). * `balanceInCents` is expressed in cents. Pass the returned `id` as the * `accountId` of a payout batch. */ listAccounts(params?: unknown): Promise>; /** Get the dispersion limits and consumption (`GET /limits`), in cents. */ getLimits(): Promise>; /** List the generated payout reports (`GET /reports/payouts`). */ listReports(params: unknown): Promise>; /** Get a presigned URL to download a report's CSV (`GET /reports/presigned_url`). */ getReportDownloadUrl(params: unknown): Promise>; /** * Check the availability of the Payouts services (`GET /health`). * * During an outage the API may answer with an error status whose envelope * still carries the health payload; that payload is unwrapped and returned * as data so callers always observe `UNHEALTHY` instead of a request error. */ getHealth(): Promise>; /** * Recharge a test account's balance (`POST /accounts/balance-recharge`). * **Sandbox only** — the production API does not expose this endpoint. */ rechargeAccountBalance(input: unknown): Promise>; private buildQueryUrl; } export { WompiClient, WompiPayoutsClient };