0

SearchTerminalRefunds

by
Published Oct 17, 2025

Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * SearchTerminalRefunds
7
 * Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days.
8
 */
9
export async function main(
10
  auth: Square,
11
  body: {
12
    query?: {
13
      filter?: {
14
        device_id?: string;
15
        created_at?: { start_at?: string; end_at?: string };
16
        status?: string;
17
      };
18
      sort?: { sort_order?: string };
19
    };
20
    cursor?: string;
21
    limit?: number;
22
  },
23
) {
24
  const url = new URL(
25
    `https://connect.squareup.com/v2/terminals/refunds/search`,
26
  );
27

28
  const response = await fetch(url, {
29
    method: "POST",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: JSON.stringify(body),
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