import { H as PaymentDriver, I as PaymentEngineOptions, J as PaymentEngine, L as PaymentEngineState, i as VerificationConfig, P as PaymentProviderId, j as VerificationResponse, b as PaymentValidationError } from './errors-Bkzdj0lJ.js'; export { D as DEFAULT_ERROR_PATTERNS, d as EnvironmentWarningMessages, E as ErrorMessageResolver, A as ErrorPattern, R as Logger, G as ParseErrorOptions, N as PaymentDriverContext, M as PaymentDriverHandlers, c as PaymentMessageOverrides, a as PaymentProvider, V as ValidationErrorCode, O as VerifyPayloadInput, Q as createLogger, z as createParsedError, x as generateMockTransactionId, T as logSandboxMode, y as parseError, S as validateKeyEnvironment } from './errors-Bkzdj0lJ.js'; /** * Creates a framework-agnostic payment flow controller for a given provider * driver. Handles script loading, validation, mock simulation, the optional * `onBeforePayment` hook, backend verification and standardized analytics — * identically for every provider that implements `PaymentDriver`. * * This has no dependency on React: `subscribe`/`getState` can be wired into * any UI layer. `usePaymentEngine` is the thin React binding used internally * by `useFedaPay` / `useKkiaPay`. */ declare function createPaymentEngine(driver: PaymentDriver, getOptions: () => PaymentEngineOptions): PaymentEngine; /** * React binding for `createPaymentEngine`. Owns one engine instance per * hook call (recreated only if the driver or mock-mode flag changes), * subscribes to its state, and starts its background lifecycle * (script loading, persistent SDK listeners) for the component's lifetime. * * `getOptions` is called fresh on every render, so callbacks and config * values it returns are always up to date without needing to be listed in * any dependency array. */ declare function usePaymentEngine(driver: PaymentDriver, getOptions: () => PaymentEngineOptions): [PaymentEngineState, (config: TConfig) => void]; /** * Loads an external JavaScript script dynamically. * * Checks if a script with the given ID already exists to prevent duplicates. * Scripts are loaded asynchronously to avoid blocking page rendering. * * @param src - The URL of the script to load * @param id - Unique ID for the script element (used for deduplication) * @returns Promise that resolves to `true` when loaded, or rejects on error * * @example * ```ts * await loadScript("https://cdn.example.com/sdk.js", "example-sdk"); * // SDK is now available on window * ``` */ declare function loadScript(src: string, id: string): Promise; /** * Payload sent to the verification endpoint. */ interface VerifyPayload { /** Transaction ID from the payment provider */ transactionId: string; /** Amount that was charged */ amount: number; /** Payment provider used — `"fedapay"` / `"kkiapay"`, or a custom driver's identifier */ provider: PaymentProviderId; /** Additional metadata */ metadata?: Record; } /** * Thrown when backend verification fails. `isBackendMessage` tells callers * whether `message` is text your own `verifyUrl` endpoint returned (and * should therefore be shown to the user exactly as written) or a generic * fallback/network message that's safe to run through further translation. */ declare class VerificationError extends Error { readonly isBackendMessage: boolean; constructor(message: string, isBackendMessage: boolean); } /** * Verifies a transaction with the backend. * * @param config - Verification configuration * @param payload - Transaction data to verify * @returns Verification response from the backend * @throws {VerificationError} if verification fails or network error occurs * * @example * ```ts * const result = await verifyTransaction( * { verifyUrl: "/api/verify", verifyMethod: "POST" }, * { transactionId: "tx_123", amount: 5000, provider: "fedapay" } * ); * ``` */ declare function verifyTransaction(config: VerificationConfig, payload: VerifyPayload): Promise; /** * The most common `PaymentDriver.validate` shape: a required public key * (unless in mock mode) and a positive amount. Both built-in drivers * (FedaPay, KKiaPay) use this — reach for it in a custom driver too instead * of re-implementing the same two checks. * * @example * ```ts * validate: (config, { isMockMode }) => * validatePublicKeyAndAmount(config.apiKey, config.amount, isMockMode), * ``` */ declare function validatePublicKeyAndAmount(publicKey: string | undefined, amount: number | undefined, isMockMode: boolean): PaymentValidationError | null; export { PaymentDriver, PaymentEngine, PaymentEngineOptions, PaymentEngineState, PaymentProviderId, PaymentValidationError, VerificationError, type VerifyPayload, createPaymentEngine, loadScript, usePaymentEngine, validatePublicKeyAndAmount, verifyTransaction };