homebrewでstripe cliをインストール。
brew install stripe/stripe-cli/stripe
ログインする。
stripe login
初回時は下記が表示されるので、エンターを押す。
Press Enter to open the browser (^C to quit)
ブラウザが開くので、そちらで許可する。
次にstripe listenを実行。localhost:8000/hooksはエンドポイントのURLを指定。
stripe listen --forward-to localhost:8000/hooks --latest
ちなみにイベントをLaravel側に転送したくない場合は、
stripe listenだけで実行すればログだけ確認できて便利だよ~~~
ターミナルの別タブでAPIリクエストを発行。
stripe payment_intents create --amount=100 --currency=jpy
ちなみに簡易的にしたいイベントをトリガーしたい場合は下記の方法もあり。
stripe trigger payment_intent.created
これで、リッスンしてる側でログが出力される。
csrf保護を外す必要があるので、下記のように記述。
app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
'stripe/*',
];