diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts index b056949150..e1c30be41b 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts @@ -660,18 +660,31 @@ export class InvoiceNinja implements INodeType { if (resource === 'payment') { if (operation === 'create') { const additionalFields = this.getNodeParameter('additionalFields', i); - const invoice = this.getNodeParameter('invoice', i) as number; + const invoice = this.getNodeParameter('invoice', i) as number | string; const client = ( await invoiceNinjaApiRequest.call(this, 'GET', `/invoices/${invoice}`, {}, qs) ).data?.client_id as string; const amount = this.getNodeParameter('amount', i) as number; const body: IPayment = { - invoice_id: invoice, amount, client_id: client, }; + if (apiVersion === 'v4') { + body.invoice_id = invoice as number; + } else if (apiVersion === 'v5') { + body.invoices = [ + { + invoice_id: invoice as string, + amount, + }, + ]; + } if (additionalFields.paymentType) { - body.payment_type_id = additionalFields.paymentType as number; + if (apiVersion === 'v4') { + body.payment_type_id = additionalFields.paymentType as number; + } else if (apiVersion == 'v5') { + body.type_id = additionalFields.paymentType as number; + } } if (additionalFields.transferReference) { body.transaction_reference = additionalFields.transferReference as string; diff --git a/packages/nodes-base/nodes/InvoiceNinja/PaymentInterface.ts b/packages/nodes-base/nodes/InvoiceNinja/PaymentInterface.ts index 6b0d04fad9..c7df748950 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/PaymentInterface.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/PaymentInterface.ts @@ -2,7 +2,14 @@ export interface IPayment { invoice_id?: number; amount?: number; payment_type_id?: number; + type_id?: number; transaction_reference?: string; private_notes?: string; client_id?: string; + invoices?: IInvoice[]; +} + +export interface IInvoice { + invoice_id: string; + amount: number; }