# Stripe CLI を使用して Webhook イベントをトリガーする サンドボックスで Webhook イベントをトリガーする方法について説明します。 詳細については、[Stripe CLI リファレンス](https://docs.stripe.com/cli.md)を参照してください。 サンドボックスで Webhook イベントをトリガーするには、次の 2 つの方法があります。 - トリガーするイベントにつながるアクションを実行します。たとえば、Stripe API または Stripe ダッシュボードで[顧客を作成する](https://docs.stripe.com/api/customers/create.md)と、`customer.created` イベントが生成されます。 - Stripe CLI でコマンドを実行して、イベントを自動生成します。 ## イベントのトリガー Stripe CLI がサポートしているすべてのイベントの名前を確認するには、このコマンドを実行します。 ```bash stripe trigger --help ``` 特定のイベントをトリガーするには、次のコマンドを実行して `` をイベントの名前に置き換えます。 ```bash stripe trigger ``` たとえば、このコマンドは `payment_intent.succeeded` イベントをトリガーします。 ```bash stripe trigger payment_intent.succeeded ``` 次に、ダッシュボードの [Events page](https://dashboard.stripe.com/test/events) または [stripe listen](https://docs.stripe.com/cli/listen) コマンドを使用してイベントを表示できます。 > トリガーするイベントに応じて、Stripe CLI は複数の関連イベントを生成する場合があります。たとえば、`stripe trigger price.created` を実行する際、Stripe CLI では Price を作成するために Product を作成する必要があります。このため、`product.created` と `price.created` の 2 つのイベントが生成されます。 ## イベントをカスタマイズする イベントを生成するために、Stripe CLI はいくつかの事前設定されたパラメーターを指定して Stripe API を呼び出します。たとえば、`payment_intent.succeeded` イベントをトリガーするために、Stripe CLI は [Create PaymentIntent endpoint](https://docs.stripe.com/api/payment_intents/create.md) を `amount` パラメーターを `2000` に設定して呼び出します。これらの API パラメーターは、`override` フラグを使用して変更できます。 ```bash stripe trigger --override := ``` 次に、override の例を示します。 ```bash # Set a top-level parameter stripe trigger customer.created --override customer:name=Bob # Set a nested parameter stripe trigger customer.created --override customer:"address[country]"=FR # Append an element to the end of a list stripe trigger customer.created --override customer:"preferred_locales[]"=FR # Replace an element of a list stripe trigger customer.created --override customer:"preferred_locales[0]"=FR # Set a parameter inside a list stripe trigger customer.subscription.created --override subscription:"items[0][price]"=price_xxx ``` 異なるリソースに対して複数のオーバーライドを組み合わせることもできます。 ```bash stripe trigger price.created \ --override product:name=foo \ --override price:unit_amount=4200 ``` 変更可能なリソースとパラメーターを確認するには、Stripe CLI の [GitHub リポジトリ](https://github.com/stripe/stripe-cli/tree/master/pkg/fixtures/triggers)で、該当するトリガーを確認してください。 ## Advanced event customization 使用可能なイベントまたは override がユースケースに十分でない場合は、イベントの生成方法を説明する JSON ファイルを記述し、CLI を使用してそのイベントをトリガーできます。詳細については、[Create and use fixtures](https://docs.stripe.com/cli/fixtures) を参照してください。