0

List Customer Payments

by
Published Oct 17, 2025

List all the payments made by your customer.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * List Customer Payments
7
 * List all the payments made by your customer.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  customer_name: string | undefined,
13
  reference_number: string | undefined,
14
  date: string | undefined,
15
  amount: string | undefined,
16
  notes: string | undefined,
17
  payment_mode: string | undefined,
18
  filter_by: string | undefined,
19
  sort_column: string | undefined,
20
  search_text: string | undefined,
21
) {
22
  const url = new URL(`https://www.zohoapis.com/inventory/v1/customerpayments`);
23
  for (const [k, v] of [
24
    ["organization_id", organization_id],
25
    ["customer_name", customer_name],
26
    ["reference_number", reference_number],
27
    ["date", date],
28
    ["amount", amount],
29
    ["notes", notes],
30
    ["payment_mode", payment_mode],
31
    ["filter_by", filter_by],
32
    ["sort_column", sort_column],
33
    ["search_text", search_text],
34
  ]) {
35
    if (v !== undefined && v !== "" && k !== undefined) {
36
      url.searchParams.append(k, v);
37
    }
38
  }
39
  const response = await fetch(url, {
40
    method: "GET",
41
    headers: {
42
      Authorization: "Zoho-oauthtoken " + auth.token,
43
    },
44
    body: undefined,
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52