Aller au contenu principal

Stripe

Paiements en ligne.

Configuration

import Stripe from 'stripe';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

Webhooks

// app/api/webhooks/stripe/route.ts
export async function POST(req: Request) {
const sig = req.headers.get('stripe-signature')!;
const event = stripe.webhooks.constructEvent(
await req.text(),
sig,
process.env.STRIPE_WEBHOOK_SECRET!
);

switch (event.type) {
case 'checkout.session.completed':
// Traiter paiement
break;
}
}

Dashboard

https://dashboard.stripe.com