add stripe

This commit is contained in:
2025-06-12 15:06:38 +02:00
parent 4bb4fd6121
commit bac53f8089
56 changed files with 1375 additions and 159 deletions

View File

@@ -0,0 +1,36 @@
// src/app/api/create-checkout-session/route.ts
import { NextResponse } from 'next/server'
import Stripe from 'stripe'
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: '2023-08-16',
})
export async function POST(req: Request) {
const { amount } = await req.json()
try {
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Indaba Donation',
},
unit_amount: amount * 100,
},
quantity: 1,
},
],
mode: 'payment',
success_url: `${process.env.NEXT_PUBLIC_BASE_URL}/success`,
cancel_url: `${process.env.NEXT_PUBLIC_BASE_URL}/cancel`,
})
return NextResponse.json({ url: session.url })
} catch (error) {
return NextResponse.json({ error: 'Stripe checkout failed' }, { status: 500 })
}
}