export type CreateApiCheckoutDataFeesArgs = {'x-business-id': string, 'api-key': string, body: {currency: 'NGN' | 'KES' | 'GHS' | 'UGX' | 'XOF' | 'XAF', type: 'mobile_money' | 'card' | 'bank_transfer' | 'payattitude', amount: number}}; export type CreateApiCheckoutDataFeesOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Calculate Fee on Checkout * * POST /checkout/data/fees */ export const createApiCheckoutDataFees = async (args: CreateApiCheckoutDataFeesArgs, options?: CreateApiCheckoutDataFeesOptions) => { const {baseUrl = "https://sandboxapi.fincra.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-business-id'] != null) headers.set("x-business-id", String(args['x-business-id'])) if (args['api-key'] != null) headers.set("api-key", String(args['api-key'])) if (sec0 !== undefined) headers.set("api-key", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/checkout/data/fees${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 (await res.json()) as unknown };