export type UUID = string; export type PaymentAmount = number; export type SubmerchantUUID = string; export type SubmerchantAmount = number; export type PlatformFeeAmount = number; export type Submerchant = {submerchant_id: SubmerchantUUID, amount: SubmerchantAmount, platform_fee: PlatformFeeAmount}; export type PlatformDetails = {submerchants: Array, processing_merchant_id?: UUID | undefined}; export type CreateRefundRequestRequest = {amount: PaymentAmount, customer_name: string, bank_name: string, bank_code?: string | undefined, branch_name?: string | undefined, branch_number: string, account_type: 'normal' | 'checking' | 'savings', account_number: number, include_payment_method_fee: boolean, description?: string | undefined, platform_details?: PlatformDetails | undefined}; export type CreateApiPaymentsIdRefundRequestArgs = {id: UUID, body: CreateRefundRequestRequest}; export type CreateApiPaymentsIdRefundRequestOptions = {baseUrl?: string | undefined, apiKey?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Payment: Refund Request * * POST /payments/{id}/refund_request */ export const createApiPaymentsIdRefundRequest = async (args: CreateApiPaymentsIdRefundRequestArgs, options?: CreateApiPaymentsIdRefundRequestOptions) => { const {baseUrl = "https://komoju.com/api/v1", 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', `Basic ${btoa(`${apiKey.username}:${apiKey.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/payments/${encodeURIComponent(String(args.id))}/refund_request${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 };