export type DeleteApiV2InvoicingInvoicesInvoiceIdRefundsTransactionIdArgs = {invoice_id: string, transaction_id?: string | undefined}; export type DeleteApiV2InvoicingInvoicesInvoiceIdRefundsTransactionIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete external refund * * DELETE /v2/invoicing/invoices/{invoice_id}/refunds/{transaction_id} */ export const deleteApiV2InvoicingInvoicesInvoiceIdRefundsTransactionId = async (args: DeleteApiV2InvoicingInvoicesInvoiceIdRefundsTransactionIdArgs, options?: DeleteApiV2InvoicingInvoicesInvoiceIdRefundsTransactionIdOptions) => { const {baseUrl = "https://api-m.paypal.com", fetch: fetchFn = fetch, Oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.transaction_id != null) query.append("transaction_id", String(args.transaction_id)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/invoicing/invoices/${encodeURIComponent(String(args.invoice_id))}/refunds/${encodeURIComponent(String(args.transaction_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };