//native
type Mollie = {
token: string;
};
/**
* Update order line
* **⚠️ We no longer recommend implementing the Orders API.
*/
export async function main(
auth: Mollie,
orderId: string,
id: string,
body: {
name?: string;
imageUrl?: string;
productUrl?: string;
sku?: string;
metadata?: string;
quantity?: number;
unitPrice?: { currency: string; value: string };
discountAmount?: { currency: string; value: string };
totalAmount?: { currency: string; value: string };
vatAmount?: { currency: string; value: string };
vatRate?: string;
testmode?: false | true;
},
) {
const url = new URL(
`https://api.mollie.com/v2/orders/${orderId}/lines/${id}`,
);
const response = await fetch(url, {
method: "PATCH",
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