0

Create a vendor payment

by
Published Oct 17, 2025

Create a payment made to your vendor and you can also apply them to bills either partially or fully.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Create a vendor payment
7
 * Create a payment made to your vendor and you can also apply them to bills either partially or fully.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    vendor_id?: string;
14
    bills?: {
15
      bill_payment_id?: string;
16
      bill_id?: string;
17
      amount_applied?: number;
18
      tax_amount_withheld?: number;
19
    }[];
20
    date?: string;
21
    exchange_rate?: number;
22
    amount: number;
23
    paid_through_account_id?: string;
24
    payment_mode?: string;
25
    description?: string;
26
    reference_number?: string;
27
    check_details?: string[];
28
    is_paid_via_print_check?: false | true;
29
    location_id?: string;
30
    custom_fields?: { index?: number; value?: string }[];
31
  },
32
) {
33
  const url = new URL(`https://www.zohoapis.com/books/v3/vendorpayments`);
34
  for (const [k, v] of [["organization_id", organization_id]]) {
35
    if (v !== undefined && v !== "" && k !== undefined) {
36
      url.searchParams.append(k, v);
37
    }
38
  }
39
  const response = await fetch(url, {
40
    method: "POST",
41
    headers: {
42
      "Content-Type": "application/json",
43
      Authorization: "Zoho-oauthtoken " + auth.token,
44
    },
45
    body: JSON.stringify(body),
46
  });
47
  if (!response.ok) {
48
    const text = await response.text();
49
    throw new Error(`${response.status} ${text}`);
50
  }
51
  return await response.json();
52
}
53