export type MerchantConnectorDetails = {connector_account_details?: (Record | null) | undefined, metadata?: (Record | null) | undefined}; export type MerchantConnectorDetailsWrap = {creds_identifier: string, encoded_data?: (MerchantConnectorDetails | null) | undefined}; export type PaymentsCancelRequest = {cancellation_reason?: (string | null) | undefined, merchant_connector_details?: (MerchantConnectorDetailsWrap | null) | undefined, all_keys_required?: (boolean | null) | undefined}; export type CreateApiPaymentsPaymentIdCancelArgs = {payment_id: string, body: PaymentsCancelRequest}; export type CreateApiPaymentsPaymentIdCancelOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Payments - Cancel * * POST /payments/{payment_id}/cancel */ export const createApiPaymentsPaymentIdCancel = async (args: CreateApiPaymentsPaymentIdCancelArgs, options: CreateApiPaymentsPaymentIdCancelOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/payments/${encodeURIComponent(String(args.payment_id))}/cancel${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 undefined };