stripe-integration-expert
Skill này làm gì
Skill này khiến agent xây dựng và gỡ lỗi thanh toán Stripe trong ứng dụng web. Skill dành cho lập trình viên thêm đăng ký, thanh toán một lần hoặc tính phí theo mức sử dụng vào các dự án Next.js, Express hoặc Django.
Khi nào nên dùng
- ✓Khi bạn muốn thêm thanh toán đăng ký có thời gian dùng thử miễn phí vào ứng dụng.
- ✓Khi bạn cần xử lý các webhook Stripe bị lỗi hoặc đến nhiều hơn một lần.
- ✓Khi bạn muốn người dùng nâng cấp, hạ cấp hoặc hủy gói của họ.
Liên kết skill
https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/skills/stripe-integration-expert/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm gói đăng ký hằng tháng với dùng thử miễn phí 14 ngày vào ứng dụng Next.js của tôi, dùng Stripe checkout.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thiết kế vòng đời đăng ký, thiết lập checkout và cổng khách hàng, rồi viết các trình xử lý webhook an toàn khi được chạy lại. Nó cũng giúp gỡ lỗi các vấn đề phân phát webhook.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Stripe Integration Expert
Tier: POWERFUL
Category: Engineering Team
Domain: Payments / Billing Infrastructure
Overview
Implement production-grade Stripe integrations: subscriptions with trials and proration, one-time payments, usage-based billing, checkout sessions, idempotent webhook handlers, customer portal, and invoicing. Covers Next.js, Express, and Django patterns.
Core Capabilities
- Subscription lifecycle management (create, upgrade, downgrade, cancel, pause)
- Trial handling and conversion tracking
- Proration calculation and credit application
- Usage-based billing with metered pricing
- Idempotent webhook handlers with signature verification
- Customer portal integration
- Invoice generation and PDF access
- Full Stripe CLI local testing setup
When to Use
- Adding subscription billing to any web app
- Implementing plan upgrades/downgrades with proration
- Building usage-based or seat-based billing
- Debugging webhook delivery failures
- Migrating from one billing model to another
Subscription Lifecycle State Machine
FREE_TRIAL ──paid──► ACTIVE ──cancel──► CANCEL_PENDING ──period_end──► CANCELED
│ │ │
│ downgrade reactivate
│ ▼ │
│ DOWNGRADING ──period_end──► ACTIVE (lower plan) │
│ │
└──trial_end without payment──► PAST_DUE ──payment_failed 3x──► CANCELED
│
payment_success
│
▼
ACTIVE
DB subscription status values:
trialing | active | past_due | canceled | cancel_pending | paused | unpaid
Stripe Client Setup
// lib/stripe.ts
import Stripe from "stripe"
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: "2024-04-10",
typescript: true,
appInfo: {
name: "myapp",
version: "1.0.0",
},
})
// Price IDs by plan (set in env)
export const PLANS = {
starter: {
monthly: process.env.STRIPE_STARTER_MONTHLY_PRICE_ID!,
yearly: process.env.STRIPE_STARTER_YEARLY_PRICE_ID!,
features: ["5 projects", "10k events"],
},
pro: {
monthly: process.env.STRIPE_PRO_MONTHLY_PRICE_ID!,
yearly: process.env.STRIPE_PRO_YEARLY_PRICE_ID!,
features: ["Unlimited projects", "1M events"],
},
} as const
Checkout Session (Next.js App Router)
// app/api/billing/checkout/route.ts
import { NextResponse } from "next/server"
import { stripe } from "@/lib/stripe"
import { getAuthUser } from "@/lib/auth"
import { db } from "@/lib/db"
export async function POST(req: Request) {
const user = await getAuthUser()
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
const { priceId, interval = "monthly" } = await req.json()
// Get or create Stripe customer
let stripeCustomerId = user.stripeCustomerId
if (!stripeCustomerId) {
const customer = await stripe.customers.create({
email: user.email,
name: "username-undefined"
metadata: { userId: user.id },
})
stripeCustomerId = customer.id
await db.user.update({ where: { id: user.id }, data: { stripeCustomerId } })
}
const session = await stripe.checkout.sessions.create({
customer: stripeCustomerId,
mode: "subscription",
payment_method_types: ["card"],
line_items: [{ price: priceId, quantity: 1 }],
allow_promotion_codes: true,
subscription_data: {
trial_period_days: user.hasHadTrial ? undefined : 14,
metadata: { userId: user.id },
},
success_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/pricing`,
metadata: { userId: user.id },
})
return NextResponse.json({ url: session.url })
}
Subscription Upgrade/Downgrade
// lib/billing.ts
export async function changeSubscriptionPlan(
subscriptionId: string,
newPriceId: string,
immediate = false
) {
const subscription = await stripe.subscriptions.retrieve(subscriptionId)
const currentItem = subscription.items.data[0
Câu hỏi thường gặp
Trình xử lý webhook idempotent là gì?
Đó là trình xử lý cho ra cùng một kết quả ngay cả khi Stripe gửi cùng một sự kiện nhiều lần.
Skill có xử lý phân bổ theo thời gian (proration) khi gói thay đổi không?
Có. Skill bao gồm các phép tính phân bổ và tín dụng khi người dùng nâng cấp hoặc hạ cấp.
Tôi có thể thử thanh toán ở máy cục bộ không?
Có. Skill có thiết lập Stripe CLI để kiểm thử cục bộ.
Chi tiết
Mô tả gốc của tác giả
Use for any Stripe integration: subscriptions, trials, proration, checkout, usage billing, webhooks, customer portal or invoicing in Next.js, Express or Django. Writes idempotent webhook handlers and debugs delivery failures.
Độ phổ biến
- Sao GitHub
- 29k
- Vị trí xếp hạng
- #9519
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agent-launcher-orchestrator
29kGiúp agent của bạn lên kế hoạch, xây dựng, kiểm thử và lên lịch một Claude managed agent trong tài khoản riêng, từng bước một, bắt đầu từ một mục tiêu rõ ràng.
grade-iterate
29kCho phép agent của bạn chấm kết quả một managed AI agent theo bảng tiêu chí và cải thiện qua số vòng cố định, nên không bao giờ lặp vô tận.
interview
29kCho phép agent của bạn phỏng vấn bạn về ý tưởng agent AI và biến câu trả lời thành một kế hoạch xây dựng đơn giản trước khi khởi chạy bất cứ điều gì.
run-without-you
29kGiúp agent của bạn thiết lập một managed AI agent chạy theo lịch hoặc khi có sự kiện xảy ra, với thời gian cron được kiểm tra trước khi khởi chạy.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.