export type DeleteApiV2PaymentsPaymentIdRefundsRefundIdArgs = {testmode?: boolean | undefined, 'idempotency-key'?: string | undefined}; export type DeleteApiV2PaymentsPaymentIdRefundsRefundIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cancel payment refund * * DELETE /v2/payments/{paymentId}/refunds/{refundId} * * Also accepts auth: advancedAccessToken, oAuth */ export const deleteApiV2PaymentsPaymentIdRefundsRefundId = async (args: DeleteApiV2PaymentsPaymentIdRefundsRefundIdArgs, options?: DeleteApiV2PaymentsPaymentIdRefundsRefundIdOptions) => { const {baseUrl = "https://api.mollie.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.testmode != null) query.append("testmode", String(args.testmode)) if (args['idempotency-key'] != null) headers.set("idempotency-key", String(args['idempotency-key'])) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/payments/${encodeURIComponent(String(args.paymentId))}/refunds/${encodeURIComponent(String(args.refundId))}${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 };