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

Function GET

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

Source from the content-addressed store, hash-verified

10import Stripe from "stripe"
11
12export async function GET(request: NextRequest) {
13 const stripeSessionId = request.nextUrl.searchParams.get("stripeSessionId")
14 if (stripeSessionId == null) redirect("/products/purchase-failure")
15
16 let redirectUrl: string
17 try {
18 const checkoutSession = await stripeServerClient.checkout.sessions.retrieve(
19 stripeSessionId,
20 { expand: ["line_items"] }
21 )
22 const productId = await processStripeCheckout(checkoutSession)
23
24 redirectUrl = `/products/${productId}/purchase/success`
25 } catch {
26 redirectUrl = "/products/purchase-failure"
27 }
28
29 return NextResponse.redirect(new URL(redirectUrl, request.url))
30}
31
32export async function POST(request: NextRequest) {
33 const event = await stripeServerClient.webhooks.constructEvent(

Callers

nothing calls this directly

Calls 1

processStripeCheckoutFunction · 0.85

Tested by

no test coverage detected