//native
type Mollie = {
token: string;
};
/**
* List payment methods
* Retrieve all enabled payment methods.
*/
export async function main(
auth: Mollie,
sequenceType: string | undefined,
locale: string | undefined,
amount: string | undefined,
resource: string | undefined,
billingCountry: string | undefined,
includeWallets: string | undefined,
orderLineCategories: string | undefined,
profileId: string | undefined,
include: "issuers" | "pricing" | undefined,
testmode: string | undefined,
) {
const url = new URL(`https://api.mollie.com/v2/methods`);
for (const [k, v] of [
["sequenceType", sequenceType],
["locale", locale],
["amount", amount],
["resource", resource],
["billingCountry", billingCountry],
["includeWallets", includeWallets],
["orderLineCategories", orderLineCategories],
["profileId", profileId],
["include", include],
["testmode", testmode],
]) {
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