//native
type Mollie = {
token: string;
};
/**
* List all payment methods
* Retrieve all payment methods that Mollie offers, regardless of the eligibility of the organization for the specific method. The results of this endpoint are **not** paginated — unlike most other list endpoints in our API.
The list can optionally be filtered using a number of parameters described below.
> 🔑 Access with
>
> API key
>
> Access token with **payments.read**
*/
export async function main(
auth: Mollie,
locale: string | undefined,
amount: string | undefined,
include: "issuers" | "pricing" | undefined,
sequenceType: string | undefined,
) {
const url = new URL(`https://api.mollie.com/v2/methods/all`);
for (const [k, v] of [
["locale", locale],
["amount", amount],
["include", include],
["sequenceType", sequenceType],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago