0

Cancel 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
 * Cancel 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
    lines: {
14
      id: string;
15
      quantity?: number;
16
      amount?: { currency: string; value: string };
17
    }[];
18
    testmode?: false | true;
19
  },
20
) {
21
  const url = new URL(`https://api.mollie.com/v2/orders/${orderId}/lines`);
22

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