export type CreateApi10KbAccountsAccountIdInvoicePaymentsArgs = {accountId: string, paymentMethodId?: string | undefined, externalPayment?: boolean | undefined, paymentAmount?: number | undefined, targetDate?: string | undefined, pluginProperty?: Array | undefined, 'X-Killbill-CreatedBy': string, 'X-Killbill-Reason'?: string | undefined, 'X-Killbill-Comment'?: string | undefined}; export type CreateApi10KbAccountsAccountIdInvoicePaymentsOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Trigger a payment for all unpaid invoices * * POST /1.0/kb/accounts/{accountId}/invoicePayments * * Also accepts auth: Killbill_Api_Key, Killbill_Api_Secret */ export const createApi10KbAccountsAccountIdInvoicePayments = async (args: CreateApi10KbAccountsAccountIdInvoicePaymentsArgs, options: CreateApi10KbAccountsAccountIdInvoicePaymentsOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.paymentMethodId != null) query.append("paymentMethodId", String(args.paymentMethodId)) if (args.externalPayment != null) query.append("externalPayment", String(args.externalPayment)) if (args.paymentAmount != null) query.append("paymentAmount", String(args.paymentAmount)) if (args.targetDate != null) query.append("targetDate", String(args.targetDate)) for (const item of args.pluginProperty ?? []) query.append("pluginProperty", String(item)) if (args['X-Killbill-CreatedBy'] != null) headers.set("X-Killbill-CreatedBy", String(args['X-Killbill-CreatedBy'])) if (args['X-Killbill-Reason'] != null) headers.set("X-Killbill-Reason", String(args['X-Killbill-Reason'])) if (args['X-Killbill-Comment'] != null) headers.set("X-Killbill-Comment", String(args['X-Killbill-Comment'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/1.0/kb/accounts/${encodeURIComponent(String(args.accountId))}/invoicePayments${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 };