import type { StorageAdapter, PaymentProviderAdapter, RateProvider, FeePolicy, Authorizer, PayLogger, PayHooks, RecipientResolver, TransferWithConversionHooks, FinalityPolicy, EffectiveAtPolicy } from "./interfaces.js"; import type { RoundingMode } from "./types.js"; import { type WalletsDomain } from "./domains/wallets.js"; import { type OperationsDomain } from "./domains/operations.js"; import { type WebhooksDomain } from "./domains/webhooks.js"; import { type PaymentPagesDomain } from "./domains/payment-pages.js"; import { type VerificationDomain } from "./domains/verification.js"; import { type TransfersDomain } from "./domains/transfers.js"; import { type PayoutsDomain } from "./domains/payouts.js"; import { type BanksDomain } from "./domains/banks.js"; import { type TreasuryDomain } from "./domains/treasury.js"; export interface PayClientConfig { /** * Identifies the tenant. All entities created by this client will carry this id. */ tenantId: string; /** * Required: the storage backend (Prisma, Mongoose, in-memory, etc.) */ storage: StorageAdapter; /** * Register one or more payment provider adapters by name. * e.g. [paystackAdapter, flutterwaveAdapter] */ providers?: PaymentProviderAdapter[]; /** * Optional cron parser function. When provided, core uses it to auto-compute * `nextFireAt` from a schedule's `cronExpression` at creation and after each firing. * * If omitted, callers must supply `nextFireAt` explicitly on `createSchedule()` * and call `updateSchedule({ nextFireAt })` after each execution. * * @example * ```ts * import { parseExpression } from "cron-parser"; * createPayClient({ * cronParser: (expression, after) => * parseExpression(expression, { currentDate: after }).next().toDate(), * }); * ``` */ cronParser?: (expression: string, after: Date) => Date; /** * Optional FX rate source for conversion operations. */ rateProvider?: RateProvider; /** * Configures automatic FX metadata attachment on operations. * Defaults: enabled=true, baseCurrency="USD", strict=false. */ fxMetadata?: { enabled?: boolean; baseCurrency?: string; strict?: boolean; }; /** * Optional fee policy — called before each operation to compute fees. */ feePolicy?: FeePolicy; /** * Optional authorizer — called before operations to enforce business rules. */ authorizer?: Authorizer; /** * Optional logger — receives structured log events from the client. */ logger?: PayLogger; /** * Optional lifecycle hooks — fired after key state transitions. */ hooks?: PayHooks; /** * Optional composite lifecycle hooks for transferWithConversion operations. */ transferHooks?: TransferWithConversionHooks; /** * Optional pluggable resolver for recipient identity lookups (email, username, paytag). * When omitted, callers must supply toWalletId or a pre-resolved owner tuple. */ recipientResolver?: RecipientResolver; /** * Global policy defaults for cross-user transfers. */ transfersPolicy?: { /** Auto-create destination wallet when missing. Defaults to false. */ autoCreateDestinationWallet?: boolean; /** Auto-create sender bridge wallet in transferWithConversion. Defaults to false. */ autoCreateBridgeWallet?: boolean; /** Default atomicity mode for transferWithConversion. Defaults to 'strict'. */ atomicityMode?: "strict" | "best-effort"; }; /** * Rounding mode used for FX and fee calculations. Defaults to HALF_UP. */ roundingMode?: RoundingMode; /** * Currency codes treated as crypto (shorter quote TTL — 90s vs 15min). */ cryptoCurrencies?: string[]; /** * Default checkout session TTL in milliseconds. Defaults to 24h. */ defaultSessionTtlMs?: number; /** * Register custom (non-ISO) currency codes with their decimal places. * e.g. [{ code: 'ACME', decimalPlaces: 4 }] * These supplement the built-in Intl.NumberFormat currency table. */ currencies?: Array<{ code: string; decimalPlaces: number; }>; /** * Optional per-operation-type finality policy. Controls reversal windows * and hard vs. soft finality modes for each operation type. */ finalityPolicy?: FinalityPolicy; /** * Controls how far in the past or future an entry's effectiveAt may be set * relative to the current wall-clock time (§15). Defaults: 7 days past, 0 ms future. * Violations throw InvalidEffectiveAtError. */ effectiveAtPolicy?: EffectiveAtPolicy; } /** * Compliance exports and audit API namespace (§35). * * **Status: designed, not implemented (Tier 2).** * All methods on this namespace throw {@link OperationNotSupportedError} until shipped. * * @example * ```ts * try { * await pay.exports.getStatement({ from: new Date('2026-01-01') }); * } catch (err) { * // err instanceof OperationNotSupportedError * // err.code === 'OPERATION_NOT_SUPPORTED' * // err.context.method === 'pay.exports.getStatement' * } * ``` * * @alpha */ export interface ExportsDomain { /** * @alpha Designed but not yet implemented — throws `OperationNotSupportedError`. */ [method: string]: (...args: unknown[]) => Promise; } /** * A fully configured pay client scoped to a single tenant. * * Obtain an instance via {@link createPayClient}. */ export interface PayClient { /** The tenant this client is scoped to. All operations are isolated to this tenant. */ readonly tenantId: string; /** Wallet management — create, inspect, update, and archive wallets. */ readonly wallets: WalletsDomain; /** Ledger operations — deposits, withdrawals, transfers, conversions, and lifecycle transitions. */ readonly operations: OperationsDomain; /** Cross-user and cross-currency transfers. */ readonly transfers: TransfersDomain; /** Inbound webhook processing — verify provider callbacks and settle operations automatically. */ readonly webhooks: WebhooksDomain; /** Hosted payment pages and checkout sessions. */ readonly paymentPages: PaymentPagesDomain; /** Active transaction verification against provider APIs. */ readonly verification: VerificationDomain; /** Payouts — dispatch bank transfers to registered recipients. */ readonly payouts: PayoutsDomain; /** Bank utilities — list/search banks and get transfer limits per provider. */ readonly banks: BanksDomain; /** Treasury — provider wallet balances, wallet management, transfer status and history. */ readonly treasury: TreasuryDomain; /** * Compliance exports and audit APIs (§35). * * **Status: designed, not implemented (Tier 2).** * Calling any method throws {@link OperationNotSupportedError}. * * @alpha */ readonly exports: ExportsDomain; } /** * Create a scoped pay client for a given tenant. * * ```ts * const pay = createPayClient({ * tenantId: "tenant_01", * storage: new PrismaStorageAdapter(prisma), * providers: [paystackAdapter], * logger: myLogger, * }); * * const wallet = await pay.wallets.create({ currency: "NGN", ownerId: userId, ownerType: "user" }); * const op = await pay.operations.deposit({ walletId: wallet.id, amountMinor: 10000, currency: "NGN" }); * ``` */ export declare function createPayClient(config: PayClientConfig): PayClient; //# sourceMappingURL=client.d.ts.map