108 lines
4.1 KiB
PHP
108 lines
4.1 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
use Inertia\Inertia;
|
|
use App\Models\Payment;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\CardImportController;
|
|
|
|
Route::get('/', function () {
|
|
return Inertia::render('Landing');
|
|
})->name('home');
|
|
|
|
Route::get('dashboard', function () {
|
|
return Inertia::render('Dashboard');
|
|
})->middleware(['auth', 'verified'])->name('dashboard');
|
|
|
|
// Route::get('/cards', [App\Http\Controllers\CardController::class, 'index'])->name('cards.index');
|
|
Route::get('/tirage',[App\Http\Controllers\CardController::class, 'index'])->name('cards.shuffle');
|
|
Route::post('/draw-card', [App\Http\Controllers\CardController::class, 'drawCard']);
|
|
|
|
Route::post('/create-checkout-session', [App\Http\Controllers\StripeController::class, 'createCheckoutSession']);
|
|
|
|
Route::post('/checkout-rendez-vous', [App\Http\Controllers\StripeController::class, 'createRendezVousSession']);
|
|
|
|
Route::post('/stripe/webhook', [App\Http\Controllers\WebhookController::class, 'handleWebhook']);
|
|
|
|
// Wise payment routes
|
|
Route::post('/create-wise-payment', [App\Http\Controllers\WiseController::class, 'createPaymentSession']);
|
|
Route::post('/wise/webhook', [App\Http\Controllers\WiseController::class, 'handleWebhook']);
|
|
Route::get('/wise/validate-payment', [App\Http\Controllers\WiseController::class, 'validatePayment']);
|
|
Route::get('/wise/verify', function () {
|
|
return Inertia::render('wise/VerifyPayment');
|
|
})->name('wise.verify');
|
|
|
|
Route::get('/rendez-vous', [App\Http\Controllers\AppointmentController::class, 'index']);
|
|
|
|
Route::get('/resultat', [App\Http\Controllers\CardController::class, 'cartResult']);
|
|
Route::get('/resultat-gratuit', function(Request $request) {
|
|
return Inertia::render('cards/FreeCardResult');
|
|
})->name('cards.freeResult');
|
|
|
|
Route::get('paiement', function () {
|
|
return Inertia::render('Checkout');
|
|
})->name('paiement');
|
|
|
|
|
|
Route::get('/success', function (Request $request) {
|
|
$clientSessionId = $request->query('client_session_id');
|
|
|
|
$payment = Payment::where('client_session_id', $clientSessionId)
|
|
->where('status', 'succeeded') // Only check for succeeded payments
|
|
->first();
|
|
|
|
if ($payment) {
|
|
return Inertia::render('payments/Success', [
|
|
'paymentSuccess' => true,
|
|
'drawCount' => $payment->draw_count,
|
|
'paymentProvider' => $payment->payment_provider ?? 'stripe'
|
|
]);
|
|
}
|
|
|
|
// If payment not found as succeeded, check if it's pending (especially for Wise)
|
|
$pendingPayment = Payment::where('client_session_id', $clientSessionId)->first();
|
|
|
|
if ($pendingPayment && $pendingPayment->status === 'pending') {
|
|
return Inertia::render('payments/Pending', [
|
|
'message' => 'Payment is being processed. Please wait...',
|
|
'clientSessionId' => $clientSessionId,
|
|
'paymentProvider' => $pendingPayment->payment_provider ?? 'stripe'
|
|
]);
|
|
}
|
|
|
|
return Inertia::render('payments/Error', ['message' => 'Payment validation failed.']);
|
|
})->name('payment.success');
|
|
|
|
Route::get('/rendez-vous/success', function (Request $request){
|
|
$clientSessionId = $request->query('client_session_id');
|
|
$payment = Payment::where('client_session_id', $clientSessionId)
|
|
->where('status', 'succeeded') // Only check for succeeded payments
|
|
->first();
|
|
|
|
if ($payment) {
|
|
return Inertia::render('AppointSuccess', [
|
|
'appointment_date' => $payment->appointment_date,
|
|
]);
|
|
}
|
|
|
|
})->name('appoint.success');
|
|
|
|
Route::get('/cancel', function () {
|
|
return Inertia::render('payments/Error'); // Your error page
|
|
})->name('payments.cancel');
|
|
|
|
Route::get('/term-condition', function () {
|
|
return Inertia::render('TermCondition'); // Your terms and conditions page
|
|
})->name('term-condition');
|
|
|
|
Route::get('/politique-confidalite', function () {
|
|
return Inertia::render('PolitiqueConf'); // Your terms and conditions page
|
|
})->name('politique-conf');
|
|
|
|
|
|
// CSV import endpoint for cards
|
|
Route::post('/cards/import', [CardImportController::class, 'store'])->middleware(['auth']);
|
|
|
|
require __DIR__.'/settings.php';
|
|
require __DIR__.'/auth.php';
|