0

Disable payment method

by
Published Apr 8, 2025

Disable a payment method on a specific profile. When using a profile-specific API credential, the alias `me` can be used instead of the profile ID to refer to the current profile. > 🔑 Access with > > API key > > Access token with **profiles.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
 * Disable payment method
7
 * Disable a payment method on a specific profile.
8

9
When using a profile-specific API credential, the alias `me` can be used instead of the profile ID to refer to the current profile.
10

11
> 🔑 Access with
12
>
13
> API key
14
>
15
> Access token with **profiles.write**
16
 */
17
export async function main(auth: Mollie, profileId: string, id: string) {
18
  const url = new URL(
19
    `https://api.mollie.com/v2/profiles/${profileId}/methods/${id}`,
20
  );
21

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