From f626157ab44370869390552db657e9fc709d352a Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 29 Jan 2026 21:54:18 -0600 Subject: [PATCH] Stripe checkout and webhook --- bootstrap/app.php | 6 +++++- config/services.php | 5 +++++ routes/web.php | 11 ++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index c183276..184e281 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,8 +11,12 @@ return Application::configure(basePath: dirname(__DIR__)) health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { - // + $middleware->validateCsrfTokens(except: [ + 'stripe/webhook', + ]); }) + + ->withExceptions(function (Exceptions $exceptions): void { // })->create(); diff --git a/config/services.php b/config/services.php index 6a90eb8..1c2ef58 100644 --- a/config/services.php +++ b/config/services.php @@ -35,4 +35,9 @@ return [ ], ], + 'stripe' => [ + 'secret' => env('STRIPE_SK'), + 'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'), + ], + ]; diff --git a/routes/web.php b/routes/web.php index 7043873..a849767 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,13 +17,14 @@ Route::middleware(['auth', 'verified'])->group(function () { Route::view('invoices', 'invoices.index')->name('invoices'); Route::get('invoices/{invoice}/edit', fn(Invoice $invoice) => view('invoices.edit', compact('invoice')))->name('invoices.edit'); - Route::get('invoices/{invoice}', CustomerInvoiceController::class)->name('invoices.show'); Route::view('payments', 'payments.index')->name('payments'); }); -// Testing Stripe -Route::get('stripe', [StripeController::class, 'index'])->name('stripe.index'); -Route::post('/checkout ', [StripeController::class, 'checkout'])->name('stripe.checkout'); -Route::get('/success', [StripeController::class, 'success'])->name('stripe.success'); +Route::get('invoices/{invoice}', CustomerInvoiceController::class)->name('invoices.show'); +// Stripe +Route::get('stripe', [StripeController::class, 'index'])->name('stripe.index'); +Route::post('/stripe/checkout ', [StripeController::class, 'checkout'])->name('stripe.checkout'); +Route::get('/success', [StripeController::class, 'success'])->name('stripe.success'); +Route::post('stripe/webhook', [StripeController::class, 'webhook'])->name('stripe.webhook'); require __DIR__.'/settings.php';