0

Manage order lines

by
Published Apr 8, 2025

**⚠️ We no longer recommend implementing the Orders API.

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * Manage order lines
7
 * **⚠️ We no longer recommend implementing the Orders API.
8
 */
9
export async function main(
10
  auth: Mollie,
11
  orderId: string,
12
  body: {
13
    operations: {
14
      operation: string;
15
      data: {
16
        id?: string;
17
        quantity?: number;
18
        amount?: { currency: string; value: string };
19
      };
20
    }[];
21
    testmode?: false | true;
22
  },
23
) {
24
  const url = new URL(`https://api.mollie.com/v2/orders/${orderId}/lines`);
25

26
  const response = await fetch(url, {
27
    method: "PATCH",
28
    headers: {
29
      "Content-Type": "application/json",
30
      Authorization: "Bearer " + auth.token,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.text();
39
}
40