本文へ移動
cccskills
無料GitHub で公開

adding-stripe

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

インストール方法を見る

含まれるファイル(1)

  • SKILL.md2.2 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Add Stripe Payments

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

Steps

  1. Install the SDK

    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:

    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:

    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.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Use Cursor's browser aria snapshots to audit a page for accessibility issues — missing labels, broken tab order, contrast, and ARIA misuse.

日本語の概要は準備中です。原文の説明を表示しています。

0xAidan/polymarket-bot-test42026年9月4日 更新

Add PostHog analytics to a web application, including event tracking, page views, feature flags, and session replay.

日本語の概要は準備中です。原文の説明を表示しています。

0xAidan/polymarket-bot-test42026年9月4日 更新

Generate OpenAPI/Swagger documentation for an API, including endpoint schemas, request/response types, and interactive docs UI.

日本語の概要は準備中です。原文の説明を表示しています。

0xAidan/polymarket-bot-test42026年9月4日 更新

Add authentication to a web application using NextAuth.js (Auth.js), including OAuth providers, session management, and protected routes.

日本語の概要は準備中です。原文の説明を表示しています。

0xAidan/polymarket-bot-test42026年9月4日 更新

Dockerize an application with a production-ready Dockerfile, docker-compose setup, and .dockerignore.

日本語の概要は準備中です。原文の説明を表示しています。

0xAidan/polymarket-bot-test42026年9月4日 更新

Set up Playwright end-to-end testing in a project, including test configuration, example tests, and CI integration.

日本語の概要は準備中です。原文の説明を表示しています。

0xAidan/polymarket-bot-test42026年9月4日 更新

0xAidan のスキルをすべて見る

このスキルの問題を報告する