export type GetApiTransactionsArgs = {'Company-Id'?: string | undefined, Mid?: string | undefined, offset?: number | undefined, limit?: number | undefined, filter?: string | undefined, start_date?: string | undefined, end_date?: string | undefined, order_id?: string | undefined, status?: ('executed' | 'settled' | 'cancelled' | 'pending' | 'expired' | 'success' | 'blocked' | 'declined' | 'error' | 'tds_pending' | 'tds_expired' | 'tds_failed' | 'tds_error' | 'tds_failed' | 'tds_error' | 'server_error') | undefined, currency?: ('AED' | 'AUD' | 'CAD' | 'CHF' | 'CNY' | 'DKK' | 'EUR' | 'GBP' | 'HKD' | 'JPY' | 'MXN' | 'SEK' | 'USD' | 'ZAR') | undefined, reason?: ('6012_data' | 'above_max_amount' | 'above_max_refund_amount' | 'above_max_transactions' | 'acs_technical_issue' | 'bad_gateway' | 'below_min_amount' | 'below_min_refund_amount' | 'bin_bank' | 'bin_country' | 'bin_level' | 'bin_product' | 'bin_scheme' | 'blocklist_bin' | 'blocklist_card' | 'blocklist_email' | 'blocklist_ip' | 'blocklist_phone' | 'card_authentication_failed' | 'card_not_active' | 'cardholder_cancellation' | 'cardholder_cancelled' | 'challenge_failed' | 'challenge_limit_exceeded' | 'challenge_not_completed' | 'challenge_time_out' | 'closed_account' | 'exceeds_authentication_frequency_limit' | 'exceeds_max_amount' | 'exceeds_max_refund_amount' | 'exceeds_max_transactions' | 'expired_card' | 'fraud_scoring' | 'fraud_scoring_error' | 'generic_decline' | 'insufficient_funds' | 'invalid_avs' | 'invalid_card_number' | 'invalid_cvv' | 'invalid_pin' | 'invalid_transaction' | 'low_confidence' | 'lost_or_stolen' | 'max_amount_day' | 'max_amount_month' | 'max_card_attempts' | 'max_card_success' | 'max_daily_refunds_amount' | 'max_daily_refunds_count' | 'max_email_day' | 'max_email_month' | 'max_ip_day' | 'max_ip_month' | 'max_monthly_refunds_amount' | 'max_monthly_refunds_count' | 'max_phone_day' | 'max_phone_month' | 'max_post_day' | 'max_post_month' | 'max_refunds_count' | 'medium_confidence' | 'no_card_record' | 'restricted_card' | 'scheme_status_reason' | 'security_failure' | 'suspected_fraud' | 'transaction_disputed' | 'transaction_fraud' | 'transaction_not_permitted_to_cardholder') | undefined, payment_method?: ('card' | 'apple_pay' | 'google_pay' | 'pay_by_bank' | 'direct_debit' | 'faster_payment_receive' | 'faster_payment_send' | 'bacs_receive') | undefined, transaction_type?: ('authorisation' | 'sale' | 'refund' | 'void' | 'capture' | 'account_to_account') | undefined, recurring_type?: ('store_card' | 'recurring' | 'returning') | undefined, charge_date?: string | undefined, acquirer_reference_number?: string | undefined}; export type GetApiTransactionsOptions = {baseUrl?: string | undefined, token?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all transactions * * GET /transactions */ export const getApiTransactions = async (args: GetApiTransactionsArgs, options?: GetApiTransactionsOptions) => { const {baseUrl = "https://test-api.acquired.com/v1", fetch: fetchFn = fetch, token} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Company-Id'] != null) headers.set("Company-Id", String(args['Company-Id'])) if (args.Mid != null) headers.set("Mid", String(args.Mid)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.filter != null) query.append("filter", String(args.filter)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.order_id != null) query.append("order_id", String(args.order_id)) if (args.status != null) query.append("status", String(args.status)) if (args.currency != null) query.append("currency", String(args.currency)) if (args.reason != null) query.append("reason", String(args.reason)) if (args.payment_method != null) query.append("payment_method", String(args.payment_method)) if (args.transaction_type != null) query.append("transaction_type", String(args.transaction_type)) if (args.recurring_type != null) query.append("recurring_type", String(args.recurring_type)) if (args.charge_date != null) query.append("charge_date", String(args.charge_date)) if (args.acquirer_reference_number != null) query.append("acquirer_reference_number", String(args.acquirer_reference_number)) if (token !== undefined) headers.set('authorization', `Bearer ${token}`) const url = `${baseUrl.replace(/\/+$/, '')}/transactions${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 (await res.json()) as unknown };