stripe-integration
Skill này làm gì
Skill này hướng dẫn agent của bạn thêm thanh toán Stripe vào ứng dụng hoặc website. Nó bao gồm checkout, đăng ký và webhook, với các bước để tránh mất đơn hàng và lộ khóa.
Khi nào nên dùng
- ✓Khi bạn muốn thêm checkout, đăng ký hoặc thanh toán định kỳ vào website hoặc ứng dụng.
- ✓Khi bạn cần thiết lập webhook Stripe để xác nhận đơn hàng đáng tin cậy.
- ✓Khi bạn muốn xem lại code thanh toán hiện có để tìm lỗi hoặc lỗ hổng bảo mật.
Liên kết skill
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/stripe-integration/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
“Hãy thiết lập Stripe Checkout cho cửa hàng trực tuyến của tôi và đảm bảo thanh toán được xác nhận qua webhook.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent làm theo hướng dẫn hiện tại của Stripe, chọn cách thanh toán phù hợp với trường hợp của bạn, và áp dụng các kiểm tra như idempotency và API key có giới hạn quyền.
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
Guidance for building payment code that does not lose orders, double-charge or
leak keys. It follows Stripe's own recommendations as of October 2026. When a
detail matters (a parameter, an event name, an API version), check
docs.stripe.com or the Stripe MCP server's
search_stripe_documentation tool before relying on memory.
Versions
- Latest API version:
2026-09-30.endive. Pin it explicitly on the client so an account default change never alters response shapes under you. - Latest server SDKs: Node.js 23, Python 16, Ruby 20, PHP 22, Java 34, Go 87,
.NET 53. Create a client instance; the global key pattern
(
stripe.api_key = …,Stripe.setApiKey) is deprecated in every SDK. - To move an existing integration to a newer version, read Upgrading your API version first.
// lib/stripe.ts
import Stripe from 'stripe';
export const stripe = new Stripe(process.env.STRIPE_API_KEY!, {
apiVersion: '2026-09-30.endive',
});
Choose the API
| Building | Use |
|---|---|
| One-time payment, simple product | Payment Links (no code) or Checkout Sessions |
| One-time payment in your web app | Checkout Sessions (hosted or embedded) |
| Custom payment form | Checkout Sessions with ui_mode: 'custom' + Payment Element |
| Save a card for later | Setup Intents |
| Charge off-session (no customer present) | Payment Intents with a saved payment method |
| Subscriptions, seats, trials | Billing APIs + Checkout mode: 'subscription' + Customer Portal |
| New usage-based billing | Metronome (Stripe's usage platform), not raw Billing Meters |
| Marketplace or platform | Connect, Accounts v2 (/v2/core/accounts), Stripe-hosted onboarding |
Never use the Charges API, Sources API, Tokens API, Card Element or the
plan object. They are deprecated or legacy; use the rows above and Prices.
Rules
Fulfill from webhooks, never from the success page
A customer can pay and close the tab before the success page loads. Grant access, send email and write orders only in the webhook handler.
- Handle
checkout.session.completedandcheckout.session.async_payment_succeeded. Fulfill only whensession.payment_status !== 'unpaid'. Delayed methods (bank debits) sendcompletedwhile still unpaid. - Handle
checkout.session.async_payment_failedfor those failures. - Subscriptions need
customer.subscription.created|updated|deleted,invoice.paidandinvoice.payment_failed. Renewals, dunning and cancellations only reach you this way. - Webhooks are required before launch, not a follow-up.
Verify every webhook signature on the raw body
Signature verification needs the exact bytes Stripe sent. Body-parsing middleware breaks it.
// Next.js App Router: app/api/stripe/webhook/route.ts
import Stripe from 'stripe';
import { stripe } from '@/lib/stripe';
export async function POST(req: Request) {
const body = await req.text(); // raw body, do not use req.json()
const signature = req.headers.get('stripe-signature');
if (!signature) return new Response('missing signature', { status: 400 });
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(
body,
signature,
process.env.STRIPE_WEBHOOK_SECRET!,
);
} catch {
return new Response('invalid signature', { status: 400 });
}
switch (event.type) {
case 'checkout.session.completed':
case 'checkout.session.async_payment_succeeded': {
// Re-fetch instead of trusting the payload snapshot.
const session = await stripe.checkout.sessions.retrieve(event.data.object.id);
// fulfillOrder must be idempotent: the same event can arrive twice.
if (session.payment_status !== 'unpaid') await fulfillOrder(session.id);
break;
}
case 'checkout.session.async_payment_failed':
await markPaymentFailed(event.data.object.id);
break;
}
return new Response(null, { status: 200 });
}
- On Cloudflare Workers, Deno or Bun use
await stripe.webhooks.constructEventAsync(...). - In Express, mount
express.raw({ type: 'application/json' })on the webhook route only, before any globalexpress.json(). - In live mode Stripe retries for up to three days and can deliver an event more than once
or out of order. Make
fulfillOrderidempotent (store processed event or session IDs with a unique constraint) and decide by the object's current state, not by event order
Câu hỏi thường gặp
Nó có bao gồm hoàn tiền không?
Có. Mô tả bao gồm hoàn tiền, cùng với checkout, đăng ký, cổng khách hàng và Stripe Tax.
Nó xử lý secret key thế nào?
Skill cảnh báo không để lộ khóa và khuyên dùng API key có giới hạn quyền.
Lời khuyên có cập nhật không?
Skill cho biết nó theo hướng dẫn của Stripe tính đến tháng 10 năm 2026, và agent được yêu cầu kiểm tra tài liệu Stripe khi chi tiết quan trọng.
Chi tiết
Mô tả gốc của tác giả
Build or review a Stripe integration with current Stripe guidance: Checkout Sessions, Payment Element, Setup Intents, subscriptions and the Customer Portal, webhook-driven fulfillment, idempotency, restricted API keys and Stripe Tax. Use when: stripe, payments, checkout, subscription, billing, webhook, refund, payment intent.
Độ phổ biến
- Sao GitHub
- 33k
- Vị trí xếp hạng
- #8802
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
owasp-security
33kDạy agent hướng dẫn bảo mật OWASP cho ứng dụng web, API, di động, container và agent AI, để nhận ra các điểm yếu phổ biến và gợi ý cách sửa.
agent-management
33kCho phép agent của bạn tạo, liệt kê, cho ngủ đông, đánh thức, đổi tên và xóa các agent AI bằng dòng lệnh AI Maestro, quản lý vòng đời của từng agent.
agent-messaging
33kCho phép agent của bạn gửi, nhận và trả lời tin nhắn có chữ ký giữa các agent AI, dùng Agent Messaging Protocol, chủ yếu trên máy của bạn.
docs-search
33kCho phép agent của bạn tìm trong tài liệu code được tạo tự động, như chữ ký hàm, định nghĩa lớp và chú thích, để kiểm tra API thật trước khi sửa code.
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ủ.