import type { ID } from "./types.js"; import type { FeePolicy } from "./interfaces.js"; export declare function newId(): ID; /** * Apply integer HALF_UP rounding to a floating-point intermediate result. * All final amounts must be integers in minor units; this helper is used * only when computing FX-converted amounts or fee percentages. */ export declare function roundHalfUp(value: number): number; export declare function roundHalfDown(value: number): number; export declare function roundFloor(value: number): number; export declare function roundCeiling(value: number): number; /** * Register custom currency decimal-place definitions. * Called by `createPayClient` when the `currencies` config option is provided. */ export declare function registerCurrencies(currencies: Array<{ code: string; decimalPlaces: number; }>): void; /** * Return ISO 4217 minor unit exponent for a currency code. * * Checks the custom registry (populated via `registerCurrencies`) first, * then falls back to Intl.NumberFormat, then to 2. * * Examples: * - USD -> 2 * - JPY -> 0 * - KWD -> 3 * * Falls back to 2 when unknown. */ export declare function getCurrencyExponent(currency: string): number; export declare function minorToMajor(amountMinor: number, currency: string): number; export declare function majorToMinor(amountMajor: number, currency: string, roundingMode?: string): number; export declare function applyRounding(value: number, mode?: string): number; /** * Convert an amount from one currency to another using a string rate. * Returns an integer in the target currency's minor units. * * Uses decimal.js for all intermediate arithmetic per ยง30 precision mandate. */ /** * Normalise incoming HTTP headers to lowercase keys with string values. * Multi-value headers (Express arrays) are joined with a comma. * Use this before passing headers to `verifyWebhook` or `verifyPayoutWebhook`. * * @example * const headers = normalizeHeaders(req.headers); * await adapter.verifyWebhook({ rawBody, headers, secret }); */ export declare function normalizeHeaders(headers: Record): Record; export declare function convertAmount(amountMinor: number, rate: string, roundingMode?: string, options?: { fromCurrency?: string; toCurrency?: string; }): number; export interface PayoutFeePolicyConfig { /** * Flat fee in minor units added to every withdrawal. * Use 0 to disable. */ flat?: number; /** * Percentage fee as a plain number (e.g. `1.5` = 1.5%). * Computed from the withdrawal amount and added on top of the flat fee. * Use 0 to disable. */ percent?: number; /** * Maximum total fee in minor units. When non-zero, the combined flat + percent * fee is capped at this value. * Use 0 for no cap. */ cap?: number; } /** * Returns a `FeePolicy` that applies a flat fee, a percentage fee, or both, * with an optional cap. The policy only fires for `withdrawal` operations; * all other operation types receive `null` (no fee). * * @example * const pay = createPayClient({ * feePolicy: createPayoutFeePolicy({ flat: 0, percent: 1.5, cap: 50000 }), * // ... * }); */ export declare function createPayoutFeePolicy(config: PayoutFeePolicyConfig): FeePolicy; //# sourceMappingURL=utils.d.ts.map