0

Enable payment method issuer

by
Published Apr 8, 2025

Enable an issuer for a payment method on a specific profile. Currently only the payment methods `voucher` and `giftcard` are supported. 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
 * Enable payment method issuer
7
 * Enable an issuer for a payment method on a specific profile.
8

9
Currently only the payment methods `voucher` and `giftcard` are supported.
10

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

13
> 🔑 Access with
14
>
15
> API key
16
>
17
> Access token with **profiles.write**
18
 */
19
export async function main(
20
  auth: Mollie,
21
  profileId: string,
22
  methodId: "voucher" | "giftcard",
23
  id: string,
24
  body: { contractId?: string },
25
) {
26
  const url = new URL(
27
    `https://api.mollie.com/v2/profiles/${profileId}/methods/${methodId}/issuers/${id}`,
28
  );
29

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