export type CreateApiPaymentsBrPaymentAuthorizationsPaymentAuthorizationIdCancelArgs = {'X-Belvo-API-Resource-Version'?: 'Payments-BR.V2' | undefined, payment_authorization_id: string}; export type CreateApiPaymentsBrPaymentAuthorizationsPaymentAuthorizationIdCancelOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Cancel a Payment Authorization * * POST /payments/br/payment-authorizations/{payment_authorization_id}/cancel/ */ export const createApiPaymentsBrPaymentAuthorizationsPaymentAuthorizationIdCancel = async (args: CreateApiPaymentsBrPaymentAuthorizationsPaymentAuthorizationIdCancelArgs, options?: CreateApiPaymentsBrPaymentAuthorizationsPaymentAuthorizationIdCancelOptions) => { const {baseUrl = "https://sandbox.belvo.com", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Belvo-API-Resource-Version'] != null) headers.set("X-Belvo-API-Resource-Version", String(args['X-Belvo-API-Resource-Version'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/payments/br/payment-authorizations/${encodeURIComponent(String(args.payment_authorization_id))}/cancel/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };