//native
type Mollie = {
token: string;
};
/**
* Revoke mandate
* Revoke a customer's mandate. You will no longer be able to charge the customer's bank account or card with this mandate, and all connected subscriptions will be canceled.
> 🔑 Access with
>
> API key
>
> Access token with **mandates.write**
*/
export async function main(
auth: Mollie,
customerId: string,
id: string,
testmode: string | undefined,
) {
const url = new URL(
`https://api.mollie.com/v2/customers/${customerId}/mandates/${id}`,
);
for (const [k, v] of [["testmode", testmode]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "DELETE",
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