Token导航 LogoToken导航

Agent Skill · 研究检索

nextjs-stripe-integration(Next.js Stripe 集成)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

nextjs-stripe-integration 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 68,884。

总安装 222周安装 9GitHub Stars 195下载 70核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:nextjs-stripe-integration(Next.js Stripe 集成)
来源仓库:https://github.com/microck/ordinary-claude-skills
仓库路径:skills/nextjs-stripe-integration
安装命令:
npx skills add https://github.com/microck/ordinary-claude-skills --skill nextjs-stripe-integration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/microck/ordinary-claude-skills --skill nextjs-stripe-integration

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助 Next.js 项目中 Stripe 支付功能的集成与开发。适合在 Codex、Claude、Cursor 等宿主中生成支付流程和后端交互逻辑。使用时需结合项目业务需求和 Stripe API 文档,确保支付安全合规。

安装方式:GitHub 仓库,命令为 npx skills add <repo> --skill nextjs-stripe-integration。注意:需确认权限范围和维护状态,避免触发不必要的文件读写或网络请求。

来源仓库内路径:skills/nextjs-stripe-integration

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/microck/ordinary-claude-skills --skill nextjs-…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

nextjs-stripe-integration 怎么安装?

在终端执行 npx skills add https://github.com/microck/ordinary-claude-skills --skill nextjs-stripe-int…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

nextjs-stripe-integration 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

nextjs-stripe-integration 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

nextjs-stripe-integration 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

nextjs-stripe-integration 用的人多吗?

公开数据是累计安装 222 次,近一周安装 9 次,下载 70 次,GitHub 195 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

nextjs-stripe-integration 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
nextjs-stripe-integration

Next.js Stripe 集成 · 本页

222195接触敏感数据未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Next.js + Stripe Integration

This Skill teaches Claude how to implement Stripe payment processing in Next.js projects, including one-time payments, subscriptions, webhooks, and customer management. Based on real-world implementation experience with modern Stripe APIs and authentication frameworks.

⚠️ CRITICAL: Breaking Changes in Modern Stripe.js

stripe.redirectToCheckout() is DEPRECATED and no longer works!

Modern Stripe implementations use the checkout session URL directly:

// ❌ OLD (BROKEN)
const { error } = await stripe.redirectToCheckout({ sessionId });

// ✅ NEW (CORRECT)
const session = await stripe.checkout.sessions.create({...});
window.location.href = session.url; // Use the URL directly!

Quick Start Checklist

When implementing Stripe in a Next.js project:

  1. Install dependencies: stripe and @stripe/stripe-js
  2. Configure environment: Add NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY and STRIPE_SECRET_KEY to .env.local
  3. Access env vars correctly: Load inside functions, NOT at module level (critical for runtime)
  4. Create API routes: Build endpoints for checkout sessions, webhooks, and customer portal
  5. Build UI: Create checkout forms and payment pages
  6. Handle webhooks: Set up secure webhook handlers for payment events
  7. Update middleware: Add payment routes to unauthenticatedPaths if using auth middleware
  8. Test locally: Use Stripe CLI for webhook testing

Core Implementation Patterns

1. Environment Setup & Runtime Loading

# .env.local
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

CRITICAL: Access environment variables inside API route functions, NOT at module initialization:

// ❌ WRONG - Fails at build/startup
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
export async function POST() { ... }

// ✅ CORRECT - Variables loaded at runtime
export async function POST(request: NextRequest) {
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
  if (!stripeSecretKey) {
    return NextResponse.json({ error: 'API key not configured' }, { status: 500 });
  }
  const stripe = new Stripe(stripeSecretKey);
  // ... rest of function
}

Important: Only use NEXT_PUBLIC_ prefix for publishable keys. Secret keys stay server-side only.

2. One-Time Payments (Checkout) - Modern Approach

API Route (app/api/checkout/route.ts):

  • Load Stripe with secret key inside the function
  • Create a Stripe checkout session with mode: 'payment'
  • Return the full session URL (not just session ID)
  • Verify webhook signatures on payment success
// ✅ CORRECT: Load env vars inside function
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const session = await stripe.checkout.sessions.create({...});
return NextResponse.json({ url: session.url }); // Return URL directly

Client Side (Simplified):

  • NO need to load Stripe.js for basic checkout
  • Call checkout API route
  • Redirect to session.url directly from response
  • Handle success/cancel redirects via query parameters

3. Subscriptions

Differences from one-time payments:

  • Create products in Stripe Dashboard with recurring pricing
  • Use mode: 'subscription' when creating checkout sessions
  • Manage customer subscriptions in database
  • Handle multiple lifecycle events via webhooks

Key workflow:

  1. Fetch available subscription tiers from Stripe API
  2. Display pricing page with subscription options
  3. Create checkout session with subscription mode
  4. Handle customer.subscription.created webhook
  5. Sync subscription status to your database

4. Webhook Handling

Critical security requirements:

  • Verify webhook signatures using Stripe's libraries
  • Use raw request body for signature validation (disable body parsing)
  • Handle these key events:

- payment_intent.succeeded — one-time payment confirmed - customer.subscription.created — new subscription - customer.subscription.updated — subscription changes - customer.subscription.deleted — cancellation - invoice.payment_succeeded — renewal payment

Webhook endpoint (app/api/webhooks/stripe/route.ts):

  • Accept POST requests from Stripe
  • Verify signature: stripe.webhooks.constructEvent(body, signature, secret)
  • Process event and update database
  • Return 200 status to acknowledge

5. Authentication Middleware Configuration

When using WorkOS or similar auth frameworks, explicitly allow payment routes:

// middleware.ts
export default authkitMiddleware({
  eagerAuth: true,
  middlewareAuth: {
    enabled: true,
    unauthenticatedPaths: [
      '/',
      '/sign-in',
      '/sign-up',
      '/api/checkout',              // Allow unauthenticated checkout
      '/api/webhooks/stripe',       // Allow webhook delivery
      '/payment-success',
      '/payment-cancel',
    ],
  },
});

Why: Without this, auth middleware intercepts payment routes, causing CORS errors when the frontend tries to call them.

6. Customer Portal

Enable users to manage subscriptions without custom code:

  • Configure Customer Portal in Stripe Dashboard
  • Create API route that generates portal sessions
  • Redirect users to portal for managing subscriptions, payment methods, and invoices

Implementation Guide

Setup Phase

  1. Create Next.js project (or use existing)
  2. Install Stripe packages: npm install stripe @stripe/stripe-js
  3. Get API keys from Stripe Dashboard → Developers → API Keys
  4. Add keys to .env.local
  5. Add .env.local to .gitignore

Build Checkout Flow (One-Time Payments)

  1. Create app/api/checkout/route.ts:

- Load Stripe with secret key inside the function - Accept POST with amount and metadata - Create checkout session - Return session.url directly (not just session ID) - See API_ROUTES.md for complete code

  1. Create checkout page:

- Simple button component (no Stripe.js needed for basic flow) - Call checkout API route on button click - Redirect to response.url directly - Handle success/cancel via query parameters

  1. Create success page:

- Accepts session_id query parameter - Retrieves session details from Stripe (optional - for confirmation display) - Displays confirmation message - Can fetch order details from your database

Build Subscription Flow

  1. Create product in Stripe Dashboard (recurring pricing)
  2. Create app/api/subscriptions/list/route.ts:

- Fetch products and prices from Stripe API - Return formatted subscription tiers

  1. Create app/api/checkout-subscription/route.ts:

- Similar to checkout flow but use mode: 'subscription' - Link to price ID instead of amount

  1. Create subscriptions page:

- Fetch available tiers from API - Display subscription cards with pricing - Implement checkout on selection

  1. Create app/api/customer-portal/route.ts:

- Accept POST request - Create portal session with customer ID - Return portal URL

Webhook Integration

  1. Create app/api/webhooks/stripe/route.ts:

- Disable body parsing: export const config = {api: {bodyParser: false}} - Extract raw body and signature from headers - Verify: stripe.webhooks.constructEvent(body, signature, webhookSecret) - Handle subscription and payment events - Update database based on event type

  1. Test locally with Stripe CLI: stripe listen --forward-to localhost:3000/api/webhooks/stripe stripe trigger payment_intent.succeeded
  2. Deploy webhook endpoint to production
  3. Add webhook endpoint URL in Stripe Dashboard → Webhooks
  4. Use production secret key for production webhooks

Best Practices

  • PCI Compliance: Always load Stripe.js from Stripe's CDN, never bundle it
  • Singleton Pattern: Lazy-load Stripe.js only when needed (performance optimization)
  • Environment Variables: Use NEXT_PUBLIC_ only for publishable keys
  • Error Handling: Catch and log errors from Stripe API calls
  • Webhook Security: Always verify signatures; never trust webhook data without verification
  • Database Sync: Store customer IDs, subscription status, and invoice data in your database
  • Testing: Use Stripe test mode keys during development; switch to live keys only in production
  • Customer Portal: Leverage it for subscription management instead of building custom UI

Common Patterns

Check if User has Active Subscription

// Query your database for customer's subscription status
const subscription = await db.subscriptions.findFirst({
  where: { userId, status: 'active' }
});
return subscription !== null;

Handle Failed Payments

Listen for invoice.payment_failed webhook and:

  • Send customer notification email
  • Update UI to show payment issue
  • Offer retry option via customer portal

Prorate Subscription Changes

Stripe handles this automatically when updating subscriptions via the API. Use proration_behavior to control how changes are billed.

Architecture Recommendations

app/
├── api/
│   ├── checkout/route.ts           # One-time payment sessions
│   ├── checkout-subscription/route.ts
│   ├── subscriptions/
│   │   └── list/route.ts           # Get available tiers
│   ├── customer-portal/route.ts    # Manage subscriptions
│   └── webhooks/
│       └── stripe/route.ts         # Webhook handler
├── checkout/
│   └── page.tsx                    # Checkout form
├── success/
│   └── page.tsx                    # Success page
└── subscriptions/
    └── page.tsx                    # Subscription tiers

Deployment Considerations

  • Vercel: Natural fit for Next.js projects; environment variables work seamlessly
  • Environment Variables: Ensure all keys are added to your hosting platform
  • Webhooks: Update webhook endpoint URL in Stripe Dashboard after deployment
  • HTTPS: Required for production (Stripe won't send webhooks to non-HTTPS URLs)
  • Testing: Create webhook endpoints in both test and production modes

References and Resources

平台分布

Codex

34.7%
按下载量换算24

Claude

30.26%
按下载量换算21

Cursor

18.25%
按下载量换算13

Gemini CLI

11.02%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills