0

Update order

by
Published Apr 8, 2025

**⚠️ We no longer recommend implementing the Orders API. Please refer to the Payments API instead. We are actively working on adding support for Klarna, Billie, in3 and Vouchers to the Payments API later this year.** Certain details of an existing order can be updated. For an in-depth explanation of each parameter, see [Create order](create-order). > 🔑 Access with > > API key > > Access token with **orders.write**

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
7
 * **⚠️ We no longer recommend implementing the Orders API. Please refer to the Payments API instead. We are actively working on adding support for Klarna, Billie, in3 and Vouchers to the Payments API later this year.**
8

9
Certain details of an existing order can be updated.
10

11
For an in-depth explanation of each parameter, see [Create order](create-order).
12

13
> 🔑 Access with
14
>
15
> API key
16
>
17
> Access token with **orders.write**
18
 */
19
export async function main(
20
  auth: Mollie,
21
  id: string,
22
  body: {
23
    orderNumber?: string;
24
    redirectUrl?: string;
25
    cancelUrl?: string;
26
    webhookUrl?: string;
27
    billingAddress?: {};
28
    shippingAddress?: {};
29
    testmode?: false | true;
30
  },
31
) {
32
  const url = new URL(`https://api.mollie.com/v2/orders/${id}`);
33

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