export type CreateApiApiV4EcommerceIntegrationKeyUnicoApplicationArgs = {'key-unico': string, 'x-auth-token': string, body: {orderId: string, requestedAmount: number, productDescription: string, customerName: string, customerEmail: string, customerPhone: string, successUrl?: string | undefined, failureUrl?: string | undefined}}; export type CreateApiApiV4EcommerceIntegrationKeyUnicoApplicationOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * 6. Generar nueva orden de compra * * POST /api/v4/ecommerce/integration/{key-unico}/application */ export const createApiApiV4EcommerceIntegrationKeyUnicoApplication = async (args: CreateApiApiV4EcommerceIntegrationKeyUnicoApplicationArgs, options?: CreateApiApiV4EcommerceIntegrationKeyUnicoApplicationOptions) => { const {baseUrl = "https://api-sandbox.atratopago.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-auth-token'] != null) headers.set("x-auth-token", String(args['x-auth-token'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v4/ecommerce/integration/${encodeURIComponent(String(args['key-unico']))}/application${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 };