export type GetApiCheckoutsArgs = {Authorization: string, 'Sub-Account'?: string | undefined, payment_mode?: ('bnpl' | 'ecom' | 'card_present' | 'apple_pay') | undefined, status?: ('created' | 'completed' | 'attempted' | 'expired') | undefined, payment_status?: ('succeeded' | 'failed' | 'canceled' | 'skipped' | 'pending') | undefined}; export type GetApiCheckoutsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List Checkouts * * GET /checkouts */ export const getApiCheckouts = async (args: GetApiCheckoutsArgs, options?: GetApiCheckoutsOptions) => { const {baseUrl = "https://api.justifi.ai/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['Sub-Account'] != null) headers.set("Sub-Account", String(args['Sub-Account'])) if (args.payment_mode != null) query.append("payment_mode", String(args.payment_mode)) if (args.status != null) query.append("status", String(args.status)) if (args.payment_status != null) query.append("payment_status", String(args.payment_status)) const url = `${baseUrl.replace(/\/+$/, '')}/checkouts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };