コンテンツにスキップ
アカウントを作成
または
サインイン
Stripe ドキュメントのロゴ
/
AI に質問する
アカウントを作成
サインイン
始める
支払い
財務の自動化
プラットフォームおよびマーケットプレイス
資金管理
開発者向けのツール
始める
支払い
財務の自動化
始める
支払い
財務の自動化
プラットフォームおよびマーケットプレイス
資金管理
概要
Connect の使用を開始
導入の基本
    連結アカウントに対する API コールの実行
    導入に関する推奨事項
    更新のリッスン
    テスト
    Accounts v2 API の概要
導入の例
アカウント登録
アカウントのダッシュボードを設定する
決済を受け付ける
アカウントへの送金
Connect プラットフォームを管理
Connect プラットフォームの納税申告書
連結アカウントのタイプの操作
ホームプラットフォームおよびマーケットプレイスIntegration fundamentals

注

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

Connect Webhook

Connect で Webhook を使用して Stripe アクティビティの通知を受ける方法をご紹介します。

ページをコピー

アカウントでイベントが発生すると、Stripe は Webhook を使用してアプリケーションに通知します。すべての Connect の組み込みでは、Webhook エンドポイントを設定して、Connect イベントをリッスンする必要があります。

Connect webhooks

A Connect platform uses two types of webhooks:

  • Account webhooks are for activity on your own account (for example, most requests made using your API keys and without authenticating as another Stripe account). This includes all types of charges, except those made directly on a connected account.
  • Connect webhooks are for activity on any connected account. We send all events on the connected account (including account updates and direct charges) to the Connect webhooks.

When you create a Connect webhook, you must configure it to receive Connect webhook events. When creating it in the Dashboard, for Listen to, select Events on Connected accounts. When creating it using the API, set the connect parameter to true.

Webhook settings in the Stripe Dashboard

For Connect webhooks, your development webhook URLs receive only test webhooks, but your production webhook URLs receive both live and test webhooks. This is because you can perform both live and test transactions under a production application. We recommend that you check the livemode value when receiving an event webhook to determine whether users need to take action.

Each event for a connected account contains a top-level account property that identifies the connected account. Because the connected account owns the object that triggered the event, you must make API requests for that object as the connected account.

{ "id":
"{{EVENT_ID}}"
, "livemode": true, "object": "event", "type": "customer.created", "account":
"{{CONNECTED_ACCOUNT_ID}}"
, "pending_webhooks": 2, "created": 1349654313, "data": {...} }

The following table describes some of the most common and important events related to connected accounts:

Eventdata.object typeDescription
account.application.deauthorizedapplicationOccurs when a connected account disconnects from your platform. You can use it to trigger cleanup on your server. Available for connected accounts with access to the Stripe Dashboard, which includes Standard accounts.
account.external_account.updatedAn external account, such as card or bank_accountOccurs when a bank account or debit card attached to a connected account is updated, which can impact payouts. Available for connected accounts that your platform controls, which includes Custom and Express accounts, and Standard accounts with platform controls enabled.
account.updatedaccountAllows you to monitor changes to connected account requirements and status changes. Available for all connected accounts.
balance.availablebalanceOccurs when your Stripe balance has been updated. For example, when funds you’ve added from your bank account are available for transfer to your connected account.
payment_intent.succeededpayment_intentOccurs when a payment intent results in a successful charge. Available for all payments, including destination and direct charges.
payout.failedpayoutOccurs when a payout fails. When a payout fails, the external account involved is disabled, and no automatic or manual payouts can be processed until the external account is updated.
person.updatedpersonOccurs when a Person associated with the Account is updated. If you use the Persons API to handle requirements, listen for this event to monitor changes to requirements and status changes for individuals. Available for connected accounts that your platform controls, which includes Custom and Express accounts, and Standard accounts with platform controls enabled.
server.rb
Ruby
# Using Sinatra. require 'sinatra' require 'stripe' set :port, 4242 # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key =
'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
# If you're testing your webhook locally with the Stripe CLI, you # can find the endpoint's secret by running `stripe listen` # Otherwise, find your endpoint's secret in your webhook settings in # the Developer Dashboard endpoint_secret = 'whsec_...' post '/webhook' do payload = request.body.read sig_header = request.env['HTTP_STRIPE_SIGNATURE'] event = nil # Verify webhook signature and extract the event. # See https://stripe.com/docs/webhooks#verify-events for more information. begin event = Stripe::Webhook.construct_event( payload, sig_header, endpoint_secret ) rescue JSON::ParserError => e # Invalid payload. status 400 return rescue Stripe::SignatureVerificationError => e # Invalid Signature. status 400 return end if event['type'] == 'account.application.deauthorized' application = event['data']['object'] connected_account_id = event['account'] handle_deauthorization(connected_account_id, application) end status 200 end def handle_deauthorization(connected_account_id, application) # Clean up account state. puts 'Connected account ID: ' + connected_account_id puts application.to_s end

Test webhooks locally

You can test webhooks locally with the Stripe CLI.

  1. If you haven’t already, install the Stripe CLI on your machine.

  2. Log in to your Stripe account and set up the CLI by running stripe login on the command line.

  3. Allow your local host to receive a simulated event on your connected account by running stripe listen --forward-to localhost:{PORT}/webhook in one terminal window, and running stripe trigger {{EVENT_NAME}} in another.

注

For Connect webhooks, use –forward-connect-to with stripe listen and –stripe-account with stripe trigger.

参照情報

  • Webhook documentation
  • Event object reference

Webhook をローカルでテストする

Stripe CLI を使用して、Webhook をローカルでテストできます。

  1. まだインストールしていない場合は、マシンに Stripe CLI をインストールします。

  2. Stripe アカウントにログインし、コマンドラインで stripe login を実行して CLI を設定します。

  3. 1 つの端末ウィンドウで stripe listen --forward-to localhost:{PORT}/webhook を実行し、別の端末ウィンドウで stripe trigger {{EVENT_NAME}} を実行することにより、ローカルホストがシミュレーションされたイベントを連結アカウントで受信できるようにします。

注

Connect Webhook では、stripe listen で –forward-connect-to を使用し、stripe trigger で –stripe-account を使用します。

参照情報

  • Webhook のドキュメント
  • Event (イベント) オブジェクトのリファレンス
このページはお役に立ちましたか。
はいいいえ
お困りのことがございましたら 、サポートにお問い合わせください。
早期アクセスプログラムにご参加ください。
変更ログをご覧ください。
ご不明な点がございましたら、お問い合わせください。
LLM ですか?llms.txt を読んでください。
Powered by Markdoc