1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Stripe CLIを利用して、Webhookを試す(Laravel版)

Last updated at Posted at 2021-05-16

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/*',
    ];
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?