From ebb041c0cce122a24e7bd1a668888daa1aa5c903 Mon Sep 17 00:00:00 2001 From: idevakk <219866223+idevakk@users.noreply.github.com> Date: Fri, 5 Dec 2025 06:59:08 -0800 Subject: [PATCH] feat(payment): implement secure payment cancellation page with session tracking - Create PaymentCancelController with authentication and subscription detection - Design responsive cancellation view with red/orange gradient theme - Add session token logging and recent subscription lookup functionality - Update payment cancel route to use new controller with auth middleware - Include security assurances and proper navigation to checkout/dashboard - Remove broken route references and ensure all buttons link to valid pages --- .../Controllers/PaymentCancelController.php | 51 ++++++ resources/views/payment/cancel.blade.php | 154 ++++++++++++++++++ routes/payment.php | 5 +- 3 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/PaymentCancelController.php create mode 100644 resources/views/payment/cancel.blade.php diff --git a/app/Http/Controllers/PaymentCancelController.php b/app/Http/Controllers/PaymentCancelController.php new file mode 100644 index 0000000..0d71255 --- /dev/null +++ b/app/Http/Controllers/PaymentCancelController.php @@ -0,0 +1,51 @@ +get('customer_session_token'); + + Log::info('PaymentCancelController: Cancellation page accessed', [ + 'user_id' => auth()->id(), + 'session_token' => $sessionToken ? substr($sessionToken, 0, 20) . '...' : 'none', + 'ip_address' => $request->ip(), + 'user_agent' => $request->userAgent(), + ]); + + // Look for any recent subscriptions for this user + $recentSubscription = null; + if (auth()->check()) { + $recentMinutes = 15; // Look for subscriptions in last 15 minutes + $recentSubscription = Subscription::where('user_id', auth()->id()) + ->where('created_at', '>=', now()->subMinutes($recentMinutes)) + ->whereIn('status', ['pending_payment', 'incomplete', 'cancelled']) + ->orderBy('created_at', 'desc') + ->first(); + + if ($recentSubscription) { + Log::info('PaymentCancelController: Found recent subscription', [ + 'user_id' => auth()->id(), + 'subscription_id' => $recentSubscription->id, + 'status' => $recentSubscription->status, + 'provider' => $recentSubscription->provider, + ]); + } + } + + return view('payment.cancel', [ + 'sessionToken' => $sessionToken, + 'recentSubscription' => $recentSubscription, + ]); + } +} \ No newline at end of file diff --git a/resources/views/payment/cancel.blade.php b/resources/views/payment/cancel.blade.php new file mode 100644 index 0000000..806733e --- /dev/null +++ b/resources/views/payment/cancel.blade.php @@ -0,0 +1,154 @@ + + + + + + Payment Cancelled - {{ config('app.name') }} + + + + + +
+
+
+
+
+
+ Z +
+

+ Zemailnator +

+
+
+ + + + + Back to Dashboard + +
+
+
+ + +
+
+ +
+ +
+
+ + + +
+

+ Payment Cancelled +

+

+ Your payment session has been cancelled. No charges were made. +

+
+ + +
+
+
+ + + +
+ +

+ No worries, your subscription wasn't created +

+ +

+ You can try subscribing again anytime. Your payment information is secure and no charges were processed. +

+ + + @if ($recentSubscription) +
+
+ + + +

+ We found a recent subscription attempt that was cancelled. You can try again from the pricing page. +

+
+
+ @endif +
+ + + +
+
+ + +
+
+ + + + + Session: {{ $sessionToken ? substr($sessionToken, 0, 20) . '...' : 'Not provided' }} + +
+
+ + +
+
+ + + + + Your payment information is secure. No charges were made. + +
+
+
+
+ + + + + diff --git a/routes/payment.php b/routes/payment.php index e9c95f8..0f8727f 100644 --- a/routes/payment.php +++ b/routes/payment.php @@ -1,5 +1,6 @@ name('payment.')->group(function () { Route::get('/success', [PaymentSuccessController::class, 'show']) ->middleware(['auth', 'verified']) ->name('success'); - Route::get('/cancel', [PaymentController::class, 'cancel'])->name('cancel'); + Route::get('/cancel', [PaymentCancelController::class, 'show']) + ->middleware(['auth', 'verified']) + ->name('cancel'); // UNIFIED: Payment processing endpoints (new unified payment system) Route::post('/checkout', [PaymentController::class, 'createCheckout'])->name('checkout');