- Home
- Skills
- APIs & Backend
- Stripe Payments: Checkout, Subscriptions & Webhooks
Works with the AI Agents you already use
Stripe Payments: Checkout, Subscriptions & Webhooks
Implement secure Stripe Checkout, subscriptions, and webhook handlers with signature verification and idempotency.
Free
Stripe Payments: Checkout, Subscriptions & Webhooks
Example session with this skill installed
Add a Stripe subscription checkout to my Next.js app. I need a Pro plan at $20/month, trial period of 14 days, and a webhook to handle the fulfillment.
- Read your context and instructions
- Compiled the stripe payments
I have implemented the Stripe subscription flow using Next.js API routes and the Stripe SDK. This includes a checkout session creator with a 14-day trial and a secure webhook handler to manage user entitlements.
Stripe Subscription Integration
// app/api/stripe/checkout/route.ts
import { stripe } from "@/lib/stripe";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
const { userId, email } = await req.json();
const session = await stripe.checkout.sessions.create({
customer_email: email,
line_items: [{ price: process.env.STRIPE_PRO_PRICE_ID, quantity: 1 }],
mode: "subscription",
subscription_data: { trial_period_days: 14 },
success_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/pricing`,
client_reference_id: userId,
metadata: { userId },
});
return NextResponse.json({ url: session.url });
}
// app/api/stripe/webhook/route.ts
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get("stripe-signature") as string;
let event;
try {
event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!);
} catch (err) {
return new Response(`Webhook Error: ${err.message}`, { status: 400 });
}
// Handle idempotency by checking event.id in DB here
switch (event.type) {
case "checkout.session.completed":
const session = event.data.object;
await updateUserSubscription(session.client_reference_id, session.customer);
break;
case "invoice.paid":
await extendAccess(event.data.object.customer);
break;
case "customer.subscription.deleted":
await revokeAccess(event.data.object.customer);
break;
}
return new Response(null, { status: 200 });
}
Next steps
- Add
STRIPE_PRO_PRICE_IDandSTRIPE_WEBHOOK_SECRETto your.env.local. - Run
stripe listen --forward-to localhost:3000/api/stripe/webhookto test the fulfillment logic. - Use the test card
4242 4242 4242 4242to verify the 14-day trial checkout flow.
Connects securely to your tools. The creator never sees your data.
About this skill
Integrating payments is a high-stakes task where small errors in webhook logic or idempotency lead to lost revenue and broken entitlements. This skill implements Stripe integrations correctly from the start, ensuring your backend handles the subscription lifecycle without relying on fragile client-side redirects.
What it does
- Multi-flow integration implements Stripe Checkout for fast deployment or Payment Element for custom UI.
- Subscription management handles trials, coupons, upgrades, downgrades, and the Customer Portal.
- Webhook orchestration builds signature-verified handlers for session completion, successful payments, and failures.
- Database syncing maps local users to Stripe customer IDs and tracks subscription statuses.
- Test-driven verification provides specific Stripe CLI commands and test card numbers for all edge cases.
How it works
- Selection defines if the app needs one-time payments, subscriptions, or a marketplace Connect setup.
- Environment config sets up the necessary secret keys, publishable keys, and webhook secrets in
.env.example. - Route implementation creates the server-side Checkout Session or PaymentIntent and the corresponding client-side trigger.
- Webhook hardening writes the handler to process events like
invoice.paidwith idempotency and signature checks. - Validation runs a suite of tests using the Stripe CLI to simulate successful and failed payment flows.
Frameworks & tools
Supports Next.js, Nuxt, Express, FastAPI, Django, and Laravel. Uses the official Stripe SDKs and the Stripe CLI for local development.
Why this beats prompting it yourself
Most LLMs default to client-side logic that fails if a user closes their browser before the redirect. This skill enforces a webhook-first architecture, ensuring your database stays in sync with Stripe's actual state regardless of browser behavior.
Use cases
- Add a SaaS pricing page with monthly and yearly subscription tiers.
- Build a checkout flow that handles automatic tax calculation and promo codes.
- Implement a customer billing portal for self-service plan management.
- Debug a failing webhook integration that is missing signature verification.
Known limitations
Does not handle physical shipping logistics or inventory management. Requires a Stripe account and the Stripe CLI installed for local webhook testing.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Requires Stripe CLI for local webhook testing. User must manually create Products and Prices in the Stripe Dashboard or provide IDs.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 1 day ago
- Free with an Agensi account