import { PoolClient } from '@evershop/postgres-query-builder'; import type { OrderRow } from '../../../types/db/index.js'; /** * Mark an order placed and emit `order_placed`, once per order. * * A payment method calls it at its own moment of success: when the gateway * accepts the payment (authorized or captured; for PayPal, also a capture * that is pending review), or when the order is created (an offline method * such as Cash on Delivery). It sets `order.placed_at` and emits * `order_placed` with the order row as it is now, in one transaction. The * first call wins; every later call, at the same time or not, changes * nothing, emits nothing and returns `null`. So a return page, a webhook and * a cron job can all call it for the same order. * * Call it after the payment status is updated, so the event carries the new * status. Pass `connection` to run inside your open transaction, started with * `startTransaction` (the event then exists only if your transaction * commits); any other connection is refused. Omit it to run in a transaction * of its own, but never while your own open transaction has updated or locked * the order: the call would wait for that transaction, which waits for the * call. * * @returns The placed order, or `null` when it was already placed or does not * exist. */ export declare function markOrderPlaced(orderId: number, connection?: PoolClient): Promise;