const response = await fetch("https://api.hilt.so/v1/products", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Hilt-Key": process.env.HILT_API_KEY!,
},
body: JSON.stringify({
product_type: "PAYMENT_LINK",
title: "Discord membership",
description: "Monthly paid access",
amount_minor_units: 29000000,
token_mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
merchant_wallet: "So1anaMerchantWallet1111111111111111111111111",
delivery_type: "DISCORD_INVITE",
delivery_value: "https://discord.gg/example",
}),
});
if (!response.ok) {
const error = await response.json().catch(() => ({}));
throw new Error(error.detail ?? `Hilt request failed: ${response.status}`);
}
const product = await response.json();
console.log(product.id, product.slug);