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.

laravel pay.jp webhook csrf 動かない

Last updated at Posted at 2019-03-14

webhookのテスト送信しても、エラーも出ないしピクリとも動かない。
なので聞いてみた。

json受け取れるようにしておいてねって。
ということで、早速。

Http/Middleware/VerifyCsrfToken.php

    protected $except = [
        //これで payjp/webhook に json を送れるようになる
        'payjp/webhook'
    ];

あとはpayjpの管理画面に webhook を設定。

これで送信できるようになる。
CSRF対策とかいうのをやってるみたいね。laravelは。

外部URLから戻ってくる場合

外部のクレジットカードサイトで決済をし、戻ってくる場合は
以下のようにする。

エラー対策

The POST method is not supported for this route. Supported methods: GET, HEAD.
web.php
//postでも受け取れるように
Route::post('/mypage', function () {
    return view('vue');
})->where('any', '^(?!api\/)[\/\w\.-]*');

そして

Http/Middleware/VerifyCsrfToken.php

    protected $except = [
        //これでmypageに戻ってこれる。
        'mypage'
    ];

OK

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?