Back

Version 14

1/3/2025
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";

export let newKofiEvent = async (req: Request) => {
const url = new URL(req.url);
if (req.method === "GET")
return new Response("OK", { status: 200 });

const formData = await req.formData();
const data = formData.get("data");
const parsed = JSON.parse(data.toString());
console.log(parsed);

if (parsed.is_public) {
if (parsed.type === "Donation") {
// discordWebhook({
// url: Deno.env.get("KOFI_DISCORD_WEBHOOK_URL"),
// content: `Someone just made a ${parsed.amount} ${parsed.currency} donation on KoFi! 🥳`,
// });
}

if (parsed.type === "Subscription") {
if (parsed.is_first_subscription_payment) {
} else {
}
}
}

// const signature = req.headers.get("Stripe-Signature");
// const body = await req.text();
// const webhookSecret = Deno.env.get("STRIPE_WEBHOOK_SECRET");
// let event;
// try {
// event = await stripe.webhooks.constructEventAsync(
// body,
// signature,
// webhookSecret,
lgug2z-kofidiscordnotification.web.val.run
Updated: January 14, 2025