From b148fdb33c7d4f434fb3e7e19027416691d997a6 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 11 Jul 2026 12:58:47 +0000 Subject: [PATCH] Changes Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com> --- supabase/functions/payments-webhook/index.ts | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 supabase/functions/payments-webhook/index.ts diff --git a/supabase/functions/payments-webhook/index.ts b/supabase/functions/payments-webhook/index.ts new file mode 100644 index 0000000..98d8670 --- /dev/null +++ b/supabase/functions/payments-webhook/index.ts @@ -0,0 +1,27 @@ +import { verifyWebhook, type StripeEnv } from "../_shared/stripe.ts"; + +Deno.serve(async (req) => { + if (req.method !== "POST") return new Response("Method not allowed", { status: 405 }); + + const rawEnv = new URL(req.url).searchParams.get("env"); + if (rawEnv !== "sandbox" && rawEnv !== "live") { + return new Response(JSON.stringify({ received: true, ignored: "invalid env" }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); + } + const env: StripeEnv = rawEnv; + + try { + const event = await verifyWebhook(req, env); + console.log(`[payments-webhook:${env}] ${event.type}`); + // Minimal handler — Stripe dashboard is source of truth for subscriptions. + return new Response(JSON.stringify({ received: true }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); + } catch (e) { + console.error("Webhook error:", e); + return new Response("Webhook error", { status: 400 }); + } +});