export type CreateApiV102PaybylinkQrcodeArgs = {body: {payment: {identifier?: string | undefined, amount?: {value: number, currency: string} | undefined, shipping?: ({value: number, currency?: string | undefined}) | undefined, lang?: string | undefined, expirationDate?: string | undefined, successUrl?: string | undefined, failUrl?: string | undefined, backUrl?: string | undefined}, products?: (Array<{sku?: string | undefined, name?: string | undefined, value: number, quantity?: number | undefined, tax?: number | undefined, discount?: number | undefined, description?: string | undefined}>) | undefined, customer?: ({notify?: boolean | undefined, email?: string | undefined, nome?: string | undefined}) | undefined}}; export type CreateApiV102PaybylinkQrcodeOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * PayByLink QR Code * * POST /v1.02/paybylink/qrcode */ export const createApiV102PaybylinkQrcode = async (args: CreateApiV102PaybylinkQrcodeArgs, options?: CreateApiV102PaybylinkQrcodeOptions) => { const {baseUrl = "https://sandbox.eupago.pt/api", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/v1.02/paybylink/qrcode${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 res.text() };