0

Get a vendor payment

by
Published Oct 17, 2025

Get the details of a vendor payment.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Get a vendor payment
7
 * Get the details of a vendor payment.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  payment_id: string,
12
  organization_id: string | undefined,
13
  fetchTaxInfo: string | undefined,
14
  fetchstatementlineinfo: string | undefined,
15
  print: string | undefined,
16
  is_bill_payment_id: string | undefined,
17
) {
18
  const url = new URL(
19
    `https://www.zohoapis.com/books/v3/vendorpayments/${payment_id}`,
20
  );
21
  for (const [k, v] of [
22
    ["organization_id", organization_id],
23
    ["fetchTaxInfo", fetchTaxInfo],
24
    ["fetchstatementlineinfo", fetchstatementlineinfo],
25
    ["print", print],
26
    ["is_bill_payment_id", is_bill_payment_id],
27
  ]) {
28
    if (v !== undefined && v !== "" && k !== undefined) {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      Authorization: "Zoho-oauthtoken " + auth.token,
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45