From a32e8e9d053c88421c0420f4f331d7d0a7246be4 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 6 May 2023 21:48:46 +1000 Subject: [PATCH] Added webhook to capture incoming webhooks --- app/Http/Controllers/WelcomeController.php | 8 ++++++++ config/logging.php | 6 ++++++ routes/api.php | 11 +++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/WelcomeController.php b/app/Http/Controllers/WelcomeController.php index 247dcee..d02d30c 100644 --- a/app/Http/Controllers/WelcomeController.php +++ b/app/Http/Controllers/WelcomeController.php @@ -2,9 +2,17 @@ namespace App\Http\Controllers; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; + class WelcomeController extends Controller { public function home() { return view('welcome.home'); } + + public function webhook(Request $request) + { + Log::channel('webhook')->debug('Webhook event',['request'=>$request]); + } } \ No newline at end of file diff --git a/config/logging.php b/config/logging.php index 91dd4c3..8a2875b 100644 --- a/config/logging.php +++ b/config/logging.php @@ -54,6 +54,12 @@ return [ 'days' => 14, ], + 'webhook' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/webhook.log'), + 'level' => env('LOG_LEVEL', 'debug'), + ], + 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), diff --git a/routes/api.php b/routes/api.php index 0d62f40..e0f8f21 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,10 @@ ['auth:api','role:reseller']], function() { Route::group(['middleware'=>'auth:api'], function() { Route::post('/u/checkout/fee/{o}',[CheckoutController::class,'fee']) ->where('o','[0-9]+'); -}); \ No newline at end of file +}); + +Route::any('/intuit/webhook',[WelcomeController::class,'webhook']) + ->where('o','[0-9]+'); \ No newline at end of file