feat: ✨ Fixed extension routes & Added PayPal Extension Routes
This commit is contained in:
parent
4041955296
commit
16a7391372
6
app/Extensions/PaymentGateways/PayPal/routes.php
Normal file
6
app/Extensions/PaymentGateways/PayPal/routes.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('payment/PayPalPay/{shopProduct}', [PaymentController::class, 'PaypalPay'])->name('payment.PayPalPay');
|
||||
Route::get('payment/PayPalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PaypalSuccess');
|
32
app/Helpers/ExtensionHelper.php
Normal file
32
app/Helpers/ExtensionHelper.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class ExtensionHelper
|
||||
{
|
||||
public static function getExtensionConfig($extensionName, $nameSpace)
|
||||
{
|
||||
$extension = app_path() . '/Extensions/' . $nameSpace . "/" . $extensionName . "/index.php";
|
||||
// Check if extension exists
|
||||
if (!file_exists($extension)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// call the getConfig function from the index.php file of the extension
|
||||
$config = include_once $extension;
|
||||
|
||||
// Check if the getConfig function exists
|
||||
if (!function_exists('getConfig')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$config = call_user_func('getConfig');
|
||||
|
||||
// Check if the getConfig function returned an array
|
||||
if (!is_array($config)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
@ -3,11 +3,20 @@
|
|||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => '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;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue