jpskill.com
🛠️ 開発・MCP コミュニティ

stripe-testing

Stripeの決済連携におけるWebhook処理の検証、決済フローのシミュレーション、エラーの原因究明などを支援し、安全な環境でStripe APIの問題を解決するSkill。

📜 元の英語説明(参考)

Test and debug Stripe payment integrations. Use when someone needs to verify webhook handling, simulate payment flows, debug failed charges, validate subscription lifecycle, or troubleshoot Stripe API errors. Trigger words: stripe, payment testing, webhook debugging, charge failed, subscription error, payment intent, checkout session.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Stripeの決済連携におけるWebhook処理の検証、決済フローのシミュレーション、エラーの原因究明などを支援し、安全な環境でStripe APIの問題を解決するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o stripe-testing.zip https://jpskill.com/download/15427.zip && unzip -o stripe-testing.zip && rm stripe-testing.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15427.zip -OutFile "$d\stripe-testing.zip"; Expand-Archive "$d\stripe-testing.zip" -DestinationPath $d -Force; ri "$d\stripe-testing.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して stripe-testing.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → stripe-testing フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Stripe テスト

概要

このスキルは、Stripe の支払い連携をエンドツーエンドでテストおよびデバッグするのに役立ちます。Webhook の検証、Stripe CLI とテストモードを使用した支払いフローのシミュレーション、請求失敗の診断、およびサブスクリプションのライフサイクルの検証について説明します。

手順

テスト環境のセットアップ

  1. Stripe CLI がインストールされていることを確認します: stripe --version
  2. 環境変数にテスト API キー (STRIPE_SECRET_KEYsk_test_ で始まる) があるか確認します
  3. キーが見つからない場合は、Stripe ダッシュボード → 開発者 → API キー から設定するように指示します
  4. stripe listen --forward-to localhost:<port>/webhooks/stripe を実行して、Webhook をローカルに転送します

失敗した請求のデバッグ

  1. Payment Intent ID または Charge ID (pi_ または ch_ で始まる) を尋ねます
  2. 詳細を取得します: stripe payment_intents retrieve <id> --api-key $STRIPE_SECRET_KEY
  3. 拒否理由について last_payment_error フィールドを確認します
  4. 一般的な拒否コードと修正:
    • card_declined → テストカード 4000000000000002 を使用して再現します
    • insufficient_funds4000000000009995 でテストします
    • expired_card4000000000000069 でテストします
    • incorrect_cvc4000000000000127 でテストします
  5. イベントタブを確認します: stripe events list --limit 5 --api-key $STRIPE_SECRET_KEY

Webhook ハンドラーのテスト

  1. 登録されている Webhook エンドポイントを一覧表示します: stripe webhook_endpoints list --api-key $STRIPE_SECRET_KEY
  2. 特定のイベントをトリガーします: stripe trigger <event_type> (例: stripe trigger payment_intent.succeeded)
  3. ローカルサーバーがイベントを正しく受信して処理したことを確認します
  4. ハンドラーコードで Webhook 署名検証を確認します — stripe.webhooks.constructEvent() を探します
  5. テストする一般的な Webhook イベント:
    • checkout.session.completed
    • invoice.payment_succeeded
    • invoice.payment_failed
    • customer.subscription.updated
    • customer.subscription.deleted

サブスクリプションのライフサイクルの検証

  1. テスト顧客を作成します: stripe customers create --name "Test User" --email test@example.com --api-key $STRIPE_SECRET_KEY
  2. 時間シミュレーション用のテストクロックを使用してサブスクリプションを作成します:
    stripe test_clocks create --frozen-time $(date +%s) --api-key $STRIPE_SECRET_KEY
  3. テストクロックを進めて、請求サイクルをシミュレートします:
    stripe test_clocks advance <clock_id> --frozen-time <future_timestamp> --api-key $STRIPE_SECRET_KEY
  4. サブスクリプションのステータス遷移を確認します: trialingactivepast_duecanceled

サーバーサイドログの読み取り

  1. アプリケーションログで Stripe 関連のエントリを検索します (stripewebhookpayment を探します)
  2. Stripe Webhook 配信に対する HTTP 4xx/5xx レスポンスを確認します
  3. 冪等性を検証します — 重複する Webhook 配信によって重複するレコードが作成されないようにします

例 1: 失敗したチェックアウトのデバッグ

ユーザープロンプト:

一部の顧客でチェックアウトが失敗しています。最後に失敗した Payment Intent は pi_3OxR2aKX8dVqS71m0abc1234 です。何が問題なのか調べていただけますか?

エージェントの行動:

stripe payment_intents retrieve pi_3OxR2aKX8dVqS71m0abc1234 --api-key $STRIPE_SECRET_KEY

エージェントの出力:

Payment Intent pi_3OxR2aKX8dVqS71m0abc1234:
  Status: requires_payment_method
  Last error: card_declined (generic_decline)
  Amount: $49.00 USD
  Customer: cus_PqR7xYz

分析:
1. カードが拒否されました (一般的な拒否) — これは、発行銀行が拒否したことを意味します
2. これはコードの問題ではありません — 顧客の銀行が請求を拒否しました
3. エラー処理は正しいようです — PI は requires_payment_method に移行しました

推奨事項:
- フロントエンドに明確な「カードが拒否されました」というメッセージが表示されるようにします
- 代替の支払い方法 (Apple Pay、Google Pay、銀行振込) を提供します
- `invoice.payment_failed` Webhook のリトライロジックがあるかどうかを確認します

例 2: Webhook ハンドラーが動作することを確認する

ユーザープロンプト:

サブスクリプションのキャンセル用の新しい Webhook ハンドラーをデプロイしました。テストしていただけますか?

エージェントの行動:

stripe listen --forward-to localhost:3000/api/webhooks/stripe &
stripe trigger customer.subscription.deleted

エージェントの出力:

Webhook forwarding active on localhost:3000/api/webhooks/stripe

Triggered: customer.subscription.deleted
  → Delivered to localhost:3000/api/webhooks/stripe [200 OK] in 145ms

Verified:
✓ Webhook が受信され、200 で応答されました
✓ 署名検証に合格しました (whsec_ 署名シークレットを使用)
✓ イベントタイプがハンドラーに正しく一致しました

次のステップ:
- データベースを確認してください: サブスクリプションはキャンセル済みとしてマークされましたか?
- 顧客がキャンセルメールを受信したことを確認します
- エッジケースをテストします: 冪等性を確認するために 2 回トリガーします

ガイドライン

  • 常にテストモードキー (sk_test_) を使用してください — テストにライブキーを使用しないでください
  • 実際のカードデータではなく、Stripe の組み込みテストカード番号を使用してください
  • テストクロックはサブスクリプションのテストに不可欠です — 時間を早送りできます
  • Webhook 署名検証が正しく実装されていることを常に確認してください
  • 競合状態を確認してください: Webhook はリダイレクトが完了する前に到着する可能性があります
  • Stripe ダッシュボード → 開発者 → Webhook で配信の失敗を監視します
  • 間違いを避けるために、環境に依存するのではなく、--api-key フラグを明示的に使用してください
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Stripe Testing

Overview

This skill helps you test and debug Stripe payment integrations end-to-end. It covers webhook verification, payment flow simulation using Stripe CLI and test mode, charge failure diagnosis, and subscription lifecycle validation.

Instructions

Setting Up the Test Environment

  1. Verify Stripe CLI is installed: stripe --version
  2. Check for a test API key in environment variables (STRIPE_SECRET_KEY starting with sk_test_)
  3. If no key is found, instruct the user to set one from the Stripe Dashboard → Developers → API keys
  4. Run stripe listen --forward-to localhost:<port>/webhooks/stripe to forward webhooks locally

Debugging Failed Charges

  1. Ask for the payment intent ID or charge ID (starts with pi_ or ch_)
  2. Retrieve details: stripe payment_intents retrieve <id> --api-key $STRIPE_SECRET_KEY
  3. Check the last_payment_error field for the decline reason
  4. Common decline codes and fixes:
    • card_declined → Use test card 4000000000000002 to reproduce
    • insufficient_funds → Test with 4000000000009995
    • expired_card → Test with 4000000000000069
    • incorrect_cvc → Test with 4000000000000127
  5. Check the Events tab: stripe events list --limit 5 --api-key $STRIPE_SECRET_KEY

Testing Webhook Handlers

  1. List registered webhook endpoints: stripe webhook_endpoints list --api-key $STRIPE_SECRET_KEY
  2. Trigger a specific event: stripe trigger <event_type> (e.g., stripe trigger payment_intent.succeeded)
  3. Verify the local server received and processed the event correctly
  4. Check webhook signature verification in the handler code — look for stripe.webhooks.constructEvent()
  5. Common webhook events to test:
    • checkout.session.completed
    • invoice.payment_succeeded
    • invoice.payment_failed
    • customer.subscription.updated
    • customer.subscription.deleted

Validating Subscription Lifecycle

  1. Create a test customer: stripe customers create --name "Test User" --email test@example.com --api-key $STRIPE_SECRET_KEY
  2. Create a subscription with a test clock for time simulation:
    stripe test_clocks create --frozen-time $(date +%s) --api-key $STRIPE_SECRET_KEY
  3. Advance the test clock to simulate billing cycles:
    stripe test_clocks advance <clock_id> --frozen-time <future_timestamp> --api-key $STRIPE_SECRET_KEY
  4. Verify subscription status transitions: trialingactivepast_duecanceled

Reading Server-Side Logs

  1. Search the application logs for Stripe-related entries (look for stripe, webhook, payment)
  2. Check for HTTP 4xx/5xx responses to Stripe webhook deliveries
  3. Verify idempotency — duplicate webhook deliveries should not create duplicate records

Examples

Example 1: Debug a Failed Checkout

User prompt:

Our checkout is failing for some customers. The last failed payment intent is pi_3OxR2aKX8dVqS71m0abc1234. Can you figure out what's going wrong?

Agent actions:

stripe payment_intents retrieve pi_3OxR2aKX8dVqS71m0abc1234 --api-key $STRIPE_SECRET_KEY

Agent output:

Payment Intent pi_3OxR2aKX8dVqS71m0abc1234:
  Status: requires_payment_method
  Last error: card_declined (generic_decline)
  Amount: $49.00 USD
  Customer: cus_PqR7xYz

Analysis:
1. The card was declined with a generic decline — this means the issuing bank refused it
2. This is NOT a code issue — the customer's bank rejected the charge
3. Your error handling looks correct — the PI moved to requires_payment_method

Recommendations:
- Ensure your frontend shows a clear "card declined" message
- Offer alternative payment methods (Apple Pay, Google Pay, bank transfer)
- Check if you have retry logic for `invoice.payment_failed` webhooks

Example 2: Verify Webhook Handler Works

User prompt:

I just deployed a new webhook handler for subscription cancellations. Can you test it?

Agent actions:

stripe listen --forward-to localhost:3000/api/webhooks/stripe &
stripe trigger customer.subscription.deleted

Agent output:

Webhook forwarding active on localhost:3000/api/webhooks/stripe

Triggered: customer.subscription.deleted
  → Delivered to localhost:3000/api/webhooks/stripe [200 OK] in 145ms

Verified:
✓ Webhook received and acknowledged with 200
✓ Signature verification passed (using whsec_ signing secret)
✓ Event type correctly matched to handler

Next steps:
- Check your database: was the subscription marked as canceled?
- Verify the customer received a cancellation email
- Test edge case: trigger it twice to confirm idempotency

Guidelines

  • Always use test mode keys (sk_test_) — never use live keys for testing
  • Use Stripe's built-in test card numbers rather than real card data
  • Test clocks are essential for subscription testing — they let you fast-forward time
  • Always verify webhook signature validation is implemented correctly
  • Check for race conditions: webhooks can arrive before the redirect completes
  • Monitor the Stripe Dashboard → Developers → Webhooks for delivery failures
  • Use --api-key flag explicitly rather than relying on environment to avoid mistakes