0

List balance transactions

by
Published Apr 8, 2025

Retrieve a list of all balance transactions. Transactions include for example payments, refunds, chargebacks, and settlements. For an aggregated report of these balance transactions, refer to the [Get balance report](get-balance-report) endpoint. The alias `primary` can be used instead of the balance ID to refer to the organization's primary balance. The results are paginated. > 🔑 Access with > > Access token with **balances.read**

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * List balance transactions
7
 * Retrieve a list of all balance transactions. Transactions include for example payments, refunds, chargebacks, and settlements.
8

9
For an aggregated report of these balance transactions, refer to the [Get balance report](get-balance-report) endpoint.
10

11
The alias `primary` can be used instead of the balance ID to refer to the organization's primary balance.
12

13
The results are paginated.
14

15
> 🔑 Access with
16
>
17
> Access token with **balances.read**
18
 */
19
export async function main(
20
  auth: Mollie,
21
  balanceId: string,
22
  from: string | undefined,
23
  limit: string | undefined,
24
  testmode: string | undefined,
25
) {
26
  const url = new URL(
27
    `https://api.mollie.com/v2/balances/${balanceId}/transactions`,
28
  );
29
  for (const [k, v] of [
30
    ["from", from],
31
    ["limit", limit],
32
    ["testmode", testmode],
33
  ]) {
34
    if (v !== undefined && v !== "" && k !== undefined) {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "GET",
40
    headers: {
41
      Authorization: "Bearer " + auth.token,
42
    },
43
    body: undefined,
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.text();
50
}
51