export type CreateApiV1PaymentsPaymentIdCaptureArgs = {paymentId: string}; export type CreateApiV1PaymentsPaymentIdCaptureOptions = {baseUrl?: string | undefined, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Capture payment * * POST /v1/payments/{paymentId}/capture */ export const createApiV1PaymentsPaymentIdCapture = async (args: CreateApiV1PaymentsPaymentIdCaptureArgs, options?: CreateApiV1PaymentsPaymentIdCaptureOptions) => { const {baseUrl = "https://publicapi.payments.service.gov.uk", fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/v1/payments/${encodeURIComponent(String(args.paymentId))}/capture${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 };