stripe-integration
できること
このスキルは、アプリやウェブサイトにStripeの決済を追加する手順を、エージェントに案内します。チェックアウト、サブスクリプション、Webhookを扱い、注文の取りこぼしや鍵の漏えいを防ぐ手順を含みます。
使う場面
- ✓ウェブサイトやアプリに、チェックアウト、サブスクリプション、請求機能を追加したいとき。
- ✓注文が確実に確定するよう、StripeのWebhookを設定したいとき。
- ✓既存の決済コードに誤りやセキュリティ上の問題がないか、再確認したいとき。
スキルのリンク
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/stripe-integration/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“オンラインショップにStripe Checkoutを設定し、決済がWebhookで確定されるようにしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはStripeの最新の指針に従い、あなたの場合に合う決済の方法を選びます。冪等性や制限付きのAPIキーなどの確認を適用します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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
よくある質問
返金も扱いますか?
はい。チェックアウトやサブスクリプションと並んで、返金も説明に含まれています。
秘密鍵はどのように扱いますか?
鍵を公開しないよう注意を促し、制限付きのAPIキーを使うことを勧めています。
助言は最新ですか?
このスキルは2026年10月時点のStripeの指針に従うと明記しています。詳細が重要な場合は、Stripeのドキュメントを確認するよう指示されています。
詳細
作者による元の説明
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.
人気
- GitHubのスター
- 33k
- ランキング
- #8802
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
owasp-security
33kエージェントがWebアプリ、API、モバイル、コンテナ、AIエージェント向けの OWASP のセキュリティ指針を理解し、よくある弱点を見つけて修正案を出せるよう支援します。
agent-management
33kエージェントが、AI Maestro のコマンドラインを使って AI エージェントを作成、一覧表示、休止、再開、名前変更、削除できるよう支援します。各エージェントのライフサイクルを管理します。
agent-messaging
33kエージェントが、主に自分のマシン上で Agent Messaging Protocol を使い、AIエージェント同士の署名付きメッセージを送信、受信、返信できるよう支援します。
docs-search
33kエージェントが、自動生成されたコードのドキュメントから関数の署名、クラスの定義、コメントを検索できるよう支援します。コードを変更する前に、実際のAPIを確認できます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。