Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

xero-node fetch all payments for retrieved invoices

Started by Dovetail Admin -   in Wrapper libraries

Hi there!

We are trying to capture the foreign invoice and payments over the past 24 months for our clients, so we can run some analytics on that data.

I have been able to fetch all invoices over the past 24 months no problem with pagination, but I was wondering if it's possible to get the payment details for all of those invoices without having to make individual calls to the payment API.

I was trying to follow the Payment API docs, and filter the payments by Invoice.InvoiceID (https://developer.xero.com/documentation/api/payments#optimised-parameters) but I keep running into a "The resource you're looking for cannot be found" error.

Here's an example of my code snippet:

```
const tenantId = '722d105a-375a-4025-b5cb-ba3f85a0e73c'
const where = 'InvoiceID==225c45f56a-12ca-4fdd-abf8-4780d9e78819 OR InvoiceID==2248e6671a-e8be-401e-a729-bb8eb374454b'

const { body } = await xeroClient.accountingApi.getPayments(tenantId, undefined, where, 'Date', 1);
```

I tried multiple different combinations of the where format. Using `Invoice.InvoiceId`, or `guid("`, based on the docs, but wasn't able to get passed the error.

P.S.

The API docs for Payments are a bit inconsistent in their docs and examples, so was a bit confusing and frustrating to follow. There seems to be inconsistencies on if you need to use single equals or double equals (=/==) as query params, and whether the query param for type is "Type" or "PaymentType". It would be super helpful to future developers if those were tidied up.
Hi Dovetail,

A good question. Sorry the following resources don't yet show that example API call flow for getting all payments from a specific invoices.

If you can log an issue in the xero-node sample app repo, or put in more details about what you would want to see for 'advanced usage' filtering / where / sorting examples in the xero-node repo, we can definitely work on that sample code soon. As for the docs I appreciate your input. They are a continual work in progress so can only expect them to get better over time :)


Sample App:
https://github.com/XeroAPI/xero-node-oauth2-app/blob/master/src/app.ts#L1743

Docs:
https://xeroapi.github.io/xero-node/accounting/index.html#api-Accounting-getPayments
 

Christopher Knight (Xero Staff)