Handle Stripe payments, custom checkouts, and webhook fulfillment outside of standard plans/credits.
Use this skill when you need to implement payment logic using Stripe, specifically for use cases that are NOT standard SaaS subscription plans or standard Credit packages (which are handled by plans-handler and credits-handler respectively).
checkout.session.completed for custom metadata.src/app/api/webhooks/stripe/route.ts for non-standard events.Before writing code, determine the nature of the payment:
plans-handler.credits-handler.You need a server-side endpoint to create the Stripe Checkout Session.
src/app/api/app/orders/create/route.ts) or Server Action.import stripe from "@/lib/stripe";metadata to the session to identify the purchase type in the webhook.metadata: {
type: "my_custom_feature",
userId: user.id,
customId: "..."
}
${process.env.NEXT_PUBLIC_APP_URL}/app/subscribe/success?session_id={CHECKOUT_SESSION_ID}${process.env.NEXT_PUBLIC_APP_URL}/app/subscribe/errorAll Stripe events go to src/app/api/webhooks/stripe/route.ts.
src/app/api/webhooks/stripe/route.tsonCheckoutSessionCompleted (for one-time) or handleOutsidePlanManagementProductInvoicePaid (for invoices).metadata from the event object.metadata.type matches your custom feature.Recommended for production: If your fulfillment logic involves multiple DB calls, external APIs, or could timeout (Stripe expects a response in < 3s):
inngest-handler to create a new function.await inngest.send({ name: "app/payment.custom_succeeded", data: { sessionId: object.id, metadata } });
src/inngest/functions/....orders, courses).url (Stripe Checkout).stripe listen to test webhooks locally.See reference.md for code snippets on creating sessions, handling webhooks, and using Inngest.