export type CreateApiPaymentNew2Args = {body: {currency: string, country: string, amount: unknown, clientName: string, clientEmail: string, clientPhone: string, clientDocumentType?: string | undefined, clientDocument: string, paymentMethod: string, bankCode?: string | undefined, urlConfirmation: string, urlFinal: string, urlRejected: string, order: unknown, theme?: string | undefined, sign: string, wallet_uid?: string | undefined, qr_only?: string | undefined, accountType?: string | undefined, branchCode?: string | undefined, accountNumber?: string | undefined, city?: string | undefined, codePostal?: string | undefined, addressLine1?: string | undefined, ttl_minutes?: string | undefined}}; export type CreateApiPaymentNew2Options = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Crear un nuevo pago - Argentina, Brasil, Chile, Ecuador, México y Perú * * POST /payment/new-2 */ export const createApiPaymentNew2 = async (args: CreateApiPaymentNew2Args, options?: CreateApiPaymentNew2Options) => { const {baseUrl = "https://sandbox.prontopaga.com/api", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/payment/new-2${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 };