MCPcopy Create free account
hub / github.com/code-with-antonio/nodebase / POST

Function POST

src/app/api/webhooks/stripe/route.ts:4–46  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

2import { type NextRequest, NextResponse } from "next/server";
3
4export async function POST(request: NextRequest) {
5 try {
6 const url = new URL(request.url);
7 const workflowId = url.searchParams.get("workflowId");
8
9 if (!workflowId) {
10 return NextResponse.json(
11 { success: false, error: "Missing required query parameter: workflowId" },
12 { status: 400 },
13 );
14 };
15
16 const body = await request.json();
17
18 const stripeData = {
19 // Event metadata
20 eventId: body.id,
21 eventType: body.type,
22 timestamp: body.created,
23 livemode: body.livemode,
24 raw: body.data?.object,
25 };
26
27 // Trigger an Inngest job
28 await sendWorkflowExecution({
29 workflowId,
30 initialData: {
31 stripe: stripeData,
32 },
33 });
34
35 return NextResponse.json(
36 { success: true },
37 { status: 200 },
38 );
39 } catch (error) {
40 console.error("Stripe webhook error:" , error);
41 return NextResponse.json(
42 { success: false, error: "Failed to process Stripe event" },
43 { status: 500 },
44 );
45 }
46};

Callers

nothing calls this directly

Calls 1

sendWorkflowExecutionFunction · 0.90

Tested by

no test coverage detected