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');