<?php
 use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; Route::get('/.well-known/acme-challenge/{token}', function (string $token) { $payload = \App\Services\Ssl\AcmeService::resolveChallengeToken($token); abort_if($payload === null, 404); return response($payload, 200, ['Content-Type' => 'text/plain']); })->where('token', '[A-Za-z0-9_\-]+')->name('acme.challenge'); Route::get('/.well-known/apple-developer-merchantid-domain-association', [\App\Http\Controllers\Store\PaymentController::class, 'applePayDomainAssociation']) ->name('paypal.apple-pay-domain'); Route::middleware('throttle:10,1')->group(function () { Route::get('/email/unsubscribe/{token}', [\App\Http\Controllers\PublicUnsubscribeController::class, 'show']) ->where('token', '[a-f0-9]{32}') ->name('email.unsubscribe.show'); Route::post('/email/unsubscribe/{token}', [\App\Http\Controllers\PublicUnsubscribeController::class, 'confirm']) ->where('token', '[a-f0-9]{32}') ->name('email.unsubscribe.confirm'); }); Route::middleware('throttle:600,1')->group(function () { Route::get('/email/campaign-track/open/{token}', [\App\Http\Controllers\EmailCampaignTrackingController::class, 'open']) ->where('token', '[a-f0-9]{32}(\.gif)?') ->name('email.campaign-track.open'); Route::get('/email/campaign-track/click/{token}/{linkHash}', [\App\Http\Controllers\EmailCampaignTrackingController::class, 'click']) ->where(['token' => '[a-f0-9]{32}', 'linkHash' => '[a-f0-9]{16}']) ->name('email.campaign-track.click'); }); Route::middleware('throttle:120,1')->group(function () { Route::post('/email/campaign-webhook/mailchimp', [\App\Http\Controllers\EmailCampaignWebhookController::class, 'mailchimp']) ->name('email.campaign-webhook.mailchimp'); Route::post('/email/campaign-webhook/mailerlite', [\App\Http\Controllers\EmailCampaignWebhookController::class, 'mailerlite']) ->name('email.campaign-webhook.mailerlite'); Route::post('/payment/webhook/{gateway}/{invoice}', [\App\Http\Controllers\Store\PaymentController::class, 'machineWebhook']) ->where(['gateway' => '[A-Za-z0-9_-]+', 'invoice' => '[0-9]+']) ->name('store.payment.webhook'); }); if (app()->environment(['local', 'testing'])) { Route::prefix('sandbox')->name('sandbox.')->group(function () { Route::get('/payu/3d/{token}', [App\Http\Controllers\Sandbox\SandboxPaymentController::class, 'showPayu3D']) ->name('payu.3d'); Route::post('/payu/3d/{token}/result', [App\Http\Controllers\Sandbox\SandboxPaymentController::class, 'handlePayu3DResult']) ->name('payu.3d.result'); }); } Route::middleware('store.locale')->group(function () { require __DIR__.'/store.php'; }); Route::middleware('admin.locale')->group(function () { require __DIR__.'/admin.php'; }); Route::get('/clientarea', function () { return auth()->guard('client')->check() ? redirect()->route('store.auth.dashboard') : redirect()->route('store.auth.login'); }); Route::middleware([ 'auth:admin', \App\Http\Middleware\Admin\EnsureTwoFactorVerified::class, 'throttle:10,1', 'can:manage api tokens', ])->group(function () { Route::post('/sanctum/token', function (Request $request) { $token = $request->user()->createToken('admin-token', ['*']); return response()->json(['token' => $token->plainTextToken]); })->name('sanctum.token'); }); Route::get('/modules/payment/{module}/{file}', function ($module, $file) { $allowedExtensions = ['svg', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'ico', 'css', 'js']; $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (! preg_match('/^[A-Za-z0-9_]+$/', $module)) { abort(404); } if (! in_array($ext, $allowedExtensions, true)) { abort(404); } $moduleDir = app_path('Modules/Payment/'.ucfirst($module)); $modulePath = $moduleDir.'/'.$file; $realPath = realpath($modulePath); $realModuleDir = realpath($moduleDir); if ($realPath === false || $realModuleDir === false) { abort(404); } if (! str_starts_with($realPath, $realModuleDir.DIRECTORY_SEPARATOR)) { abort(404); } $mimeType = mime_content_type($realPath); return response()->file($realPath, [ 'Content-Type' => $mimeType, 'Cache-Control' => 'public, max-age=31536000', ]); })->where('file', '.*'); 