MCPcopy Create free account
hub / github.com/WebDevSimplified/course-platform / POST

Function POST

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

Source from the content-addressed store, hash-verified

30}
31
32export async function POST(request: NextRequest) {
33 const event = await stripeServerClient.webhooks.constructEvent(
34 await request.text(),
35 request.headers.get("stripe-signature") as string,
36 env.STRIPE_WEBHOOK_SECRET
37 )
38
39 switch (event.type) {
40 case "checkout.session.completed":
41 case "checkout.session.async_payment_succeeded": {
42 try {
43 await processStripeCheckout(event.data.object)
44 } catch {
45 return new Response(null, { status: 500 })
46 }
47 }
48 }
49 return new Response(null, { status: 200 })
50}
51
52async function processStripeCheckout(checkoutSession: Stripe.Checkout.Session) {
53 const userId = checkoutSession.metadata?.userId

Callers

nothing calls this directly

Calls 1

processStripeCheckoutFunction · 0.85

Tested by

no test coverage detected