From 322bfed97257cf02f2ee0cb306e3b83e1b67c6be Mon Sep 17 00:00:00 2001 From: IceToast Date: Sat, 4 Mar 2023 15:13:14 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Added=20PayPal=20Settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PaymentGateways/PayPal/PayPalSettings.php | 48 ++++++++++ ...3_03_04_135248_create_pay_pal_settings.php | 19 ++++ app/Providers/AppServiceProvider.php | 89 +------------------ 3 files changed, 69 insertions(+), 87 deletions(-) create mode 100644 app/Extensions/PaymentGateways/PayPal/PayPalSettings.php create mode 100644 app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php diff --git a/app/Extensions/PaymentGateways/PayPal/PayPalSettings.php b/app/Extensions/PaymentGateways/PayPal/PayPalSettings.php new file mode 100644 index 00000000..3413a451 --- /dev/null +++ b/app/Extensions/PaymentGateways/PayPal/PayPalSettings.php @@ -0,0 +1,48 @@ +>> + */ + public static function getOptionInputData() + { + return [ + 'category_icon' => 'fas fa-dollar-sign', + 'client_id' => [ + 'type' => 'text', + 'label' => 'Client ID', + 'description' => 'The Client ID of your PayPal App', + ], + 'client_secret' => [ + 'type' => 'text', + 'label' => 'Client Secret', + 'description' => 'The Client Secret of your PayPal App', + ] + ]; + } +} diff --git a/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php b/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php new file mode 100644 index 00000000..67d85524 --- /dev/null +++ b/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php @@ -0,0 +1,19 @@ +migrator->addEncrypted('paypal.client_id', "1234"); + $this->migrator->addEncrypted('paypal.client_secret', "123456"); + } + + public function down(): void + { + $this->migrator->delete('paypal.client_id'); + $this->migrator->delete('paypal.client_secret'); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index c6018744..97a269c0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Extensions\PaymentGateways\PayPal\PayPalSettings; use App\Models\UsefulLink; use App\Settings\MailSettings; use Exception; @@ -10,7 +11,7 @@ use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Validator; use Illuminate\Support\ServiceProvider; -use Qirolab\Theme\Theme; + class AppServiceProvider extends ServiceProvider { @@ -64,91 +65,5 @@ class AppServiceProvider extends ServiceProvider $settings = $this->app->make(MailSettings::class); $settings->setConfig(); - - //only run if the installer has been executed - // try { - // $settings = Settings::all(); - // // Set all configs from database - // foreach ($settings as $setting) { - // config([$setting->key => $setting->value]); - // } - - // if(!file_exists(base_path('themes') . "/" . config("SETTINGS::SYSTEM:THEME"))){ - // config(['SETTINGS::SYSTEM:THEME' => "default"]); - // } - - // if(config('SETTINGS::SYSTEM:THEME') !== config('theme.active')){ - // Theme::set(config("SETTINGS::SYSTEM:THEME"), "default"); - // } - - // // Set Mail Config - // //only update config if mail settings have changed in DB - // if ( - // config('mail.default') != config('SETTINGS:MAIL:MAILER') || - // config('mail.mailers.smtp.host') != config('SETTINGS:MAIL:HOST') || - // config('mail.mailers.smtp.port') != config('SETTINGS:MAIL:PORT') || - // config('mail.mailers.smtp.username') != config('SETTINGS:MAIL:USERNAME') || - // config('mail.mailers.smtp.password') != config('SETTINGS:MAIL:PASSWORD') || - // config('mail.mailers.smtp.encryption') != config('SETTINGS:MAIL:ENCRYPTION') || - // config('mail.from.address') != config('SETTINGS:MAIL:FROM_ADDRESS') || - // config('mail.from.name') != config('SETTINGS:MAIL:FROM_NAME') - // ) { - // config(['mail.default' => config('SETTINGS::MAIL:MAILER')]); - // config(['mail.mailers.smtp' => [ - // 'transport' => 'smtp', - // 'host' => config('SETTINGS::MAIL:HOST'), - // 'port' => config('SETTINGS::MAIL:PORT'), - // 'encryption' => config('SETTINGS::MAIL:ENCRYPTION'), - // 'username' => config('SETTINGS::MAIL:USERNAME'), - // 'password' => config('SETTINGS::MAIL:PASSWORD'), - // 'timeout' => null, - // 'auth_mode' => null, - // ]]); - // config(['mail.from' => ['address' => config('SETTINGS::MAIL:FROM_ADDRESS'), 'name' => config('SETTINGS::MAIL:FROM_NAME')]]); - - // Artisan::call('queue:restart'); - // } - - // // Set Recaptcha API Config - // // Load recaptcha package if recaptcha is enabled - // if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') { - // $this->app->register(\Biscolab\ReCaptcha\ReCaptchaServiceProvider::class); - // } - - // //only update config if recaptcha settings have changed in DB - // if ( - // config('recaptcha.api_site_key') != config('SETTINGS::RECAPTCHA:SITE_KEY') || - // config('recaptcha.api_secret_key') != config('SETTINGS::RECAPTCHA:SECRET_KEY') - // ) { - // config(['recaptcha.api_site_key' => config('SETTINGS::RECAPTCHA:SITE_KEY')]); - // config(['recaptcha.api_secret_key' => config('SETTINGS::RECAPTCHA:SECRET_KEY')]); - - // Artisan::call('config:clear'); - // Artisan::call('cache:clear'); - // } - - // try { - // $stringfromfile = file(base_path().'/.git/HEAD'); - - // $firstLine = $stringfromfile[0]; //get the string from the array - - // $explodedstring = explode('/', $firstLine, 3); //seperate out by the "/" in the string - - // $branchname = $explodedstring[2]; //get the one that is always the branch name - // } catch (Exception $e) { - // $branchname = 'unknown'; - // Log::notice($e); - // } - // config(['BRANCHNAME' => $branchname]); - - // // Set Discord-API Config - // config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]); - // config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]); - // } catch (Exception $e) { - // error_log('Settings Error: Could not load settings from database. The Installation probably is not done yet.'); - // error_log($e); - // Log::error('Settings Error: Could not load settings from database. The Installation probably is not done yet.'); - // Log::error($e); - // } } }