//native
type Mollie = {
token: string;
};
/**
* Create a delayed route
* Create a route for a specific payment. The routed amount is credited to the account of your customer.
> 🔑 Access with
>
> API key
*/
export async function main(
auth: Mollie,
paymentId: string,
body: {
resource?: string;
id?: string;
paymentId?: string;
amount?: { currency: string; value: string };
description?: string;
destination?: { type?: string; organizationId?: string };
_links?: {
self?: { href?: string; type?: string };
documentation?: { href?: string; type?: string };
};
},
) {
const url = new URL(`https://api.mollie.com/v2/payments/${paymentId}/routes`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago