export type GetApiV2PaymentsTokenArgs = {token: unknown}; export type GetApiV2PaymentsTokenOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get order details * * GET /v2/payments/{token} */ export const getApiV2PaymentsToken = async (args: GetApiV2PaymentsTokenArgs, options?: GetApiV2PaymentsTokenOptions) => { const {baseUrl = "https://integration.api.scalapay.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v2/payments/${encodeURIComponent(String(args.token))}${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 };