Skip to content
Back to skills

Adding Stripe

ASecurity

Integrate Stripe payments into a web application, including checkout sessions, webhooks, and customer portal.

  • 4 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 10, 2026
developmentrustbashtestingapidatabase

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 10, 2026

npx -y skills add 0xAidan/polymarket-bot-test --skill adding-stripe --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Adding Stripe?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Adding Stripe
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/0xaidan-adding-stripe/badge)](https://www.skillsdirectory.com/skills/0xaidan-adding-stripe)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: adding-stripe
description: Integrate Stripe payments into a web application, including checkout sessions, webhooks, and customer portal.
---

# Add Stripe Payments

Use this skill when the user asks to add payments, billing, subscriptions, or Stripe integration.

## Steps

1. **Install the SDK**

   ```bash
   npm install stripe @stripe/stripe-js
   ```

2. **Add environment variables**

   ```
   STRIPE_SECRET_KEY=sk_test_...
   NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
   STRIPE_WEBHOOK_SECRET=whsec_...
   ```

3. **Create a Stripe client module** — create `lib/stripe.ts`:

   ```ts
   import Stripe from "stripe";

   export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
     apiVersion: "2024-12-18.acacia",
   });
   ```

4. **Create a checkout API route** — create an endpoint that creates a Stripe Checkout session:

   ```ts
   const session = await stripe.checkout.sessions.create({
     mode: "subscription", // or "payment" for one-time
     payment_method_types: ["card"],
     line_items: [{ price: priceId, quantity: 1 }],
     success_url: `${origin}/success?session_id={CHECKOUT_SESSION_ID}`,
     cancel_url: `${origin}/pricing`,
     customer_email: userEmail,
   });
   return redirect(session.url!);
   ```

5. **Create a webhook handler** — create a `POST` endpoint at `/api/webhooks/stripe`:

   - Verify the webhook signature using `stripe.webhooks.constructEvent`.
   - Handle key events: `checkout.session.completed`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.payment_failed`.
   - Update your database with the subscription status.

6. **Add customer portal (optional)** — create an endpoint that redirects to `stripe.billingPortal.sessions.create` so users can manage their subscription.

7. **Add pricing page UI** — create a pricing page with plan cards that call the checkout API route.

## Notes

- Always verify webhook signatures — never trust unverified payloads.
- Use Stripe CLI (`stripe listen --forward-to localhost:3000/api/webhooks/stripe`) for local webhook testing.
- Store the Stripe customer ID in your user database to avoid creating duplicate customers.
- Use `stripe.prices.list` to fetch prices dynamically instead of hardcoding them.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.