0

Update order line

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
 * Update order line
7
 * **⚠️ We no longer recommend implementing the Orders API.
8
 */
9
export async function main(
10
  auth: Mollie,
11
  orderId: string,
12
  id: string,
13
  body: {
14
    name?: string;
15
    imageUrl?: string;
16
    productUrl?: string;
17
    sku?: string;
18
    metadata?: string;
19
    quantity?: number;
20
    unitPrice?: { currency: string; value: string };
21
    discountAmount?: { currency: string; value: string };
22
    totalAmount?: { currency: string; value: string };
23
    vatAmount?: { currency: string; value: string };
24
    vatRate?: string;
25
    testmode?: false | true;
26
  },
27
) {
28
  const url = new URL(
29
    `https://api.mollie.com/v2/orders/${orderId}/lines/${id}`,
30
  );
31

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