Public
Back
Version 39
1/10/2025
/** @jsxImportSource https://esm.sh/react */
import type { StripeEvents as BaseStripeEvents } from "https://esm.town/v/wolf/stripeEvents?v=2";
import { listActionsForTrigger } from "https://esm.town/v/wolf/triggerUtils?v=26";
import Stripe from "npm:stripe@14.8.0";
import { bindActionToTrigger } from "https://esm.town/v/wolf/triggerUtils?v=25";
export type StripeHandlers = Partial<BaseStripeEvents | {
catchAll: (event: Stripe.Event) => Promise<void>;
}>;
export function bindAction(actionUrl: string) {
bindActionToTrigger(actionUrl, import.meta.url)
}
const actions = await listActionsForTrigger(import.meta.url);
const stripe = new Stripe(
Deno.env.get("TEST_STRIPE_SECRET") as string,
{ apiVersion: "2023-10-16" },
);
default export async function trigger(req: Request): Promise<Response> {
const url = new URL(req.url);
if (req.method === "GET" && url.pathname === "/") {
return new Response("OK", { status: 200 });
}
const signature = req.headers.get("stripe-signature");
if (!signature) {
console.log("Missing Stripe Signature");
return new Response("Missing Stripe Signature", { status: 400 });
}
const webhookSecret = Deno.env.get("STRIPE_WEBHOOK_SECRET");
if (!webhookSecret) {
wolf-stripetrigger.web.val.run
Updated: January 10, 2025