Changes
Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com>
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user