export type FailPendingTransactionRequest = {id: string, type: 'FailPendingTransaction', attributes: {transactionId?: string | undefined, reason?: ('Canceled' | 'HardDecline' | 'SoftDecline' | 'Expired' | 'InsufficientFunds' | 'Reversed' | 'Unknown') | undefined}}; export type CreateApiApiV1SimulationWalletsWalletIdFailTransactionArgs = {walletId: string, 'Client-ID': string, Authorization: string, body: {data?: FailPendingTransactionRequest | undefined}}; export type CreateApiApiV1SimulationWalletsWalletIdFailTransactionOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fail Pending Transaction * * POST /api/v1/simulation/wallets/{walletId}/fail-transaction */ export const createApiApiV1SimulationWalletsWalletIdFailTransaction = async (args: CreateApiApiV1SimulationWalletsWalletIdFailTransactionArgs, options?: CreateApiApiV1SimulationWalletsWalletIdFailTransactionOptions) => { const {baseUrl = "https://merchant-api.accruesavings.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") if (args['Client-ID'] != null) headers.set("Client-ID", String(args['Client-ID'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/simulation/wallets/${encodeURIComponent(String(args.walletId))}/fail-transaction${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };