0

Generate payment link

by
Published Oct 17, 2025

This API generates a payment link for the invoice with an expiry date.

Script zoho Verified

The script

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