コンテンツにスキップ
アカウント作成/サインイン
Stripe ドキュメントのロゴ
/
AI に質問する
アカウントを作成サインイン
導入方法
決済管理
売上管理
プラットフォームとマーケットプレイス
資金管理
開発者向けリソース
API & SDKヘルプ
概要
バージョン管理
変更ログ
API バージョンのアップグレード
SDK バージョンをアップグレードする
Essentials
SDK
API
テスト
Stripe CLI
サンプルプロジェクト
ツール
Stripe ダッシュボード
ワークベンチ
開発者ダッシュボード
Stripe Shell
Visual Studio Code をご利用の場合
機能
ワークフロー
イベントの送信先
    イベントとの連携
    Amazon EventBridge
    Webhook エンドポイント
      Webhook ビルダー
      決済イベントの処理
      Webhook のバージョン管理
      シンイベントに移行する
      Webhook の署名確認エラーを解決
      未配信の Webhook イベントを処理
      回復不能な Webhook イベントを処理する
      Manage webhooks with event notification handlers
Stripe 健全性アラートファイルのアップロード
AI ソリューション
エージェントツールキット
モデルコンテキストプロトコルエージェントを使用した AI SaaS 請求ワークフローの構築
セキュリティとプライバシー
セキュリティ
Stripebot ウェブクローラー
プライバシー
Stripe を拡張する
Stripe Appsを構築する
Stripe アプリを使用する
パートナー
Partner Ecosystem
パートナー認定
アメリカ
日本語
ホーム開発者向けリソースEvent destinationsWebhook endpoint

メモ

このページはまだ日本語ではご利用いただけません。より多くの言語で文書が閲覧できるように現在取り組んでいます。準備が整い次第、翻訳版を提供いたしますので、もう少しお待ちください。

Process incoming webhooks with event notification handlers公開プレビュー

公開プレビュー

Event notification handlers are available in public preview.

This feature doesn’t support event destinations that use EventBridge in public preview.

In each of our SDKs, we’ve created a specialized class that encapsulates the mechanics of parsing and validating a Stripe webhook. Event notification handlers take care of validating, parsing, and routing incoming webhooks to your business logic.

To use this feature, you must write a function for each event type you want to handle. After you register these functions on the handler, Stripe will call them when you receive the corresponding event notification.

はじめに

You must use the following SDK version (or higher) to use event notification handlers.

  • Java: v31.2.0-beta.1
  • Python: v14.2.0b1
  • Ruby: v18.2.0-beta.1
  • PHP: v19.2.0-beta.1
  • Go: v84.2.0-beta.1
  • Node: v20.2.0-beta.1
  • .NET: v50.2.0-beta.1

Write a fallback callback

Write a function that runs whenever a dedicated callback hasn’t been registered for a specific event type. It will receive the EventNotification, plus a StripeClient and additional information about the event.

This function might log the fact that you received an unexpected event or throw an error to alert you to the unexpected state. You can also add business logic in this function if you’re handling events that your SDK doesn’t have types for.

Python
Java
Ruby
PHP
Go
Node
.NET
No results
def fallback_callback(notif: EventNotification, client: StripeClient, details: UnhandledNotificationDetails): print(f'Got an unhandled event of type {notif.type}!')

As part of your migration, consider moving all of your webhook endpoint code into this function. Then, you can migrate individual event types to their own functions.

Initialize your handler

In your webhook endpoint, initialize an EventNotificationHandler, passing it your fallback callback. There’s a convenience method on StripeClient to simplify this step.

Python
Java
Ruby
PHP
Go
Node
.NET
No results
client = StripeClient(api_key) handler = client.notification_handler(webhook_secret, fallback_callback)

Write & register a callback

Next, write a function responsible for handling a specific event type. It uses the event types released with the Clover API version in September 2025.

Your callback will receive the event notification cast to the correct class. You’ll also get a StripeClient, bound to the context of the notification, which makes it easy to make additional API calls without juggling account ids.

Python
Java
Ruby
PHP
Go
Node
.NET
No results
# can be anywhere in your codebase @handler.on_v1_billing_meter_error_report_triggered def handle_meter_error( notif: V1BillingMeterErrorReportTriggeredEventNotification, client: StripeClient, ): event = notif.fetch_event() print(f"Err! No meter found: {event.data.developer_message_summary}")

You can register zero or more callbacks. If you don’t register any, all events will be routed to your fallback callback.

Process events

Send incoming POST bodies into the handler. This replaces most of the original code in your webhook endpoint.

Python
Java
Ruby
PHP
Go
Node
.NET
No results
@app.route("/webhook", methods=["POST"]) def webhook(): webhook_body = request.data sig_header = request.headers.get("Stripe-Signature") try: handler.handle(webhook_body, sig_header) return jsonify(success=True), 200 except Exception as e: return jsonify(error=str(e)), 500

参照情報

  • Using thin events
  • Receive Stripe events in your webhook endpoint
このページはお役に立ちましたか。
はいいいえ
  • お困りのことがございましたら 、サポートにお問い合わせください。
  • 変更ログをご覧ください。
  • ご不明な点がございましたら、お問い合わせください。
  • LLM ですか?llms.txt を読んでください。
  • Powered by Markdoc