//native
type Mollie = {
token: string;
};
/**
* Cancel payment refund
* Refunds will be executed with a delay of two hours. Until that time, refunds may be canceled manually via the Mollie Dashboard, or by using this endpoint.
A refund can only be canceled while its `status` field is either `queued` or `pending`. See the [Get refund endpoint](get-refund) for more information.
> 🔑 Access with
>
> API key
>
> Access token with **refunds.write**
*/
export async function main(
auth: Mollie,
paymentId: string,
refundId: string,
testmode: string | undefined,
) {
const url = new URL(
`https://api.mollie.com/v2/payments/${paymentId}/refunds/${refundId}`,
);
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