diff --git a/app/Extensions/PaymentGateways/PayPal/routes.php b/app/Extensions/PaymentGateways/PayPal/routes.php new file mode 100644 index 00000000..7ec92f81 --- /dev/null +++ b/app/Extensions/PaymentGateways/PayPal/routes.php @@ -0,0 +1,6 @@ +name('payment.PayPalPay'); +Route::get('payment/PayPalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PaypalSuccess'); diff --git a/app/Helpers/ExtensionHelper.php b/app/Helpers/ExtensionHelper.php new file mode 100644 index 00000000..f0cd7e4a --- /dev/null +++ b/app/Helpers/ExtensionHelper.php @@ -0,0 +1,32 @@ + 'extensions'], function () { - $extensions = glob(app_path() . '/Extensions/*', GLOB_ONLYDIR); + + // get all extensions that are inside App/Extensions + // It is important that the extensions are inside a folder with the name of the extension + // while those folders are inside Folders with the name of the type of extension like PaymentGateways, Themes, etc. + $extensionNamespaces = glob(app_path() . '/Extensions/*', GLOB_ONLYDIR); + $extensions = []; + foreach ($extensionNamespaces as $extensionNamespace) { + $extensions = array_merge($extensions, glob($extensionNamespace . '/*', GLOB_ONLYDIR)); + } + foreach ($extensions as $extension) { $routesFile = $extension . '/routes.php'; if (file_exists($routesFile)) { include_once $routesFile; } - } + } }); \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index db124a34..2e86a556 100644 --- a/routes/web.php +++ b/routes/web.php @@ -85,8 +85,7 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { #payments Route::get('checkout/{shopProduct}', [PaymentController::class, 'checkOut'])->name('checkout'); - Route::get('payment/PaypalPay/{shopProduct}', [PaymentController::class, 'PaypalPay'])->name('payment.PaypalPay'); - Route::get('payment/PaypalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PaypalSuccess'); + Route::get('payment/pay', [PaymentController::class, 'pay'])->name('payment.pay'); Route::get('payment/StripePay/{shopProduct}', [PaymentController::class, 'StripePay'])->name('payment.StripePay'); Route::get('payment/StripeSuccess', [PaymentController::class, 'StripeSuccess'])->name('payment.StripeSuccess'); Route::get('payment/Cancel', [PaymentController::class, 'Cancel'])->name('payment.Cancel'); @@ -214,3 +213,5 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { Route::get('/home', [HomeController::class, 'index'])->name('home'); }); + +require __DIR__ . '/extensions.php';