export type PaymentCaptureRequest = {description?: string | undefined, sourceAmount?: number | undefined}; export type CreateApiPaymentsTransactionsIdCaptureArgs = {'X-Idempotency-Key'?: string | undefined, 'Meld-Passthrough-Reference'?: string | undefined, 'Meld-Passthrough-Key-Id'?: string | undefined, 'Meld-Passthrough-Key-Public'?: string | undefined, 'Meld-Passthrough-Key-Private'?: string | undefined, 'Meld-Passthrough-Oauth'?: string | undefined, id: string, body: PaymentCaptureRequest}; export type CreateApiPaymentsTransactionsIdCaptureOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Capture a payment transaction * * POST /payments/transactions/{id}/capture */ export const createApiPaymentsTransactionsIdCapture = async (args: CreateApiPaymentsTransactionsIdCaptureArgs, options?: CreateApiPaymentsTransactionsIdCaptureOptions) => { const {baseUrl = "https://api-sb.meld.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args['X-Idempotency-Key'] != null) headers.set("X-Idempotency-Key", String(args['X-Idempotency-Key'])) if (args['Meld-Passthrough-Reference'] != null) headers.set("Meld-Passthrough-Reference", String(args['Meld-Passthrough-Reference'])) if (args['Meld-Passthrough-Key-Id'] != null) headers.set("Meld-Passthrough-Key-Id", String(args['Meld-Passthrough-Key-Id'])) if (args['Meld-Passthrough-Key-Public'] != null) headers.set("Meld-Passthrough-Key-Public", String(args['Meld-Passthrough-Key-Public'])) if (args['Meld-Passthrough-Key-Private'] != null) headers.set("Meld-Passthrough-Key-Private", String(args['Meld-Passthrough-Key-Private'])) if (args['Meld-Passthrough-Oauth'] != null) headers.set("Meld-Passthrough-Oauth", String(args['Meld-Passthrough-Oauth'])) if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/payments/transactions/${encodeURIComponent(String(args.id))}/capture${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.blob() };