import { PoolClient } from '@evershop/postgres-query-builder'; import { OrderRow } from '../../../types/db/index.js'; export interface RecordRefundParams { order: OrderRow; /** The gateway's refund transaction id — recording key + idempotency. */ transactionId: string; /** The refunded amount, in major currency units. */ amount: number; /** Defaults to the order's currency. */ currency?: string; /** Offline method (COD): record the transaction as offline. */ offline?: boolean; /** Raw gateway response, stored on `additional_information` for audit. */ raw?: unknown; } export interface RecordRefundResult { status: string; isFullRefund: boolean; alreadyRecorded: boolean; } /** * The core refund recorder — the guaranteed home of the `order_refunded` event. * * Records the refund `payment_transaction` idempotently (an admin refund and its * gateway webhook echo dedupe on `transactionId`), computes full-vs-partial * against the captured amount, sets the payment status, logs, and emits * `order_refunded` exactly once. Every payment method routes refunds through * here, so no gateway has to remember to emit or to record. * * Pass `conn` to enroll in a caller's transaction (a webhook already holding one); * omit it to run standalone. */ export declare function recordRefund(params: RecordRefundParams, conn?: PoolClient): Promise;