diff --git a/.env.example b/.env.example index cd370fd7..f6d2f38e 100644 --- a/.env.example +++ b/.env.example @@ -29,22 +29,6 @@ DB_USERNAME=dashboarduser DB_PASSWORD= ### --- DB Settings End --- ### -### --- Payment Options (required for payments) --- ### -# Paypal API Credentials - https://developer.paypal.com/docs/integration/direct/rest/ - Sandbox credentials are being used when APP_ENV is set to local -PAYPAL_SANDBOX_SECRET= -PAYPAL_SANDBOX_CLIENT_ID= -PAYPAL_SECRET= -PAYPAL_CLIENT_ID= - -# Stripe API Credentials - https://dashboard.stripe.com/account/apikeys - Test credentials are being used when APP_ENV is set to local -STRIPE_TEST_SECRET= -STRIPE_SECRET= -#https://dashboard.stripe.com/webhooks -> webhook route: /payment/StripeWebhooks -STRIPE_ENDPOINT_TEST_SECRET= -STRIPE_ENDPOINT_SECRET= -# Stripe payment methods - comma seperated list of payment methods that are enabled https://stripe.com/docs/payments/payment-methods/integration-options -STRIPE_METHODS= -### --- Payment Options End --- ### ### --- Discord Settings (optional) --- ### # Discord API Credentials - https://discordapp.com/developers/applications/ diff --git a/app/Classes/Settings/Payments.php b/app/Classes/Settings/Payments.php new file mode 100644 index 00000000..3d13ff9c --- /dev/null +++ b/app/Classes/Settings/Payments.php @@ -0,0 +1,53 @@ + REQUEST-VALUE (coming from the html-form) + "SETTINGS::PAYMENTS:PAYPAL:SECRET" => "paypal-client-secret", + "SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID" => "paypal-client-id", + "SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET" => "paypal-sandbox-secret", + "SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID" => "paypal-sandbox-id", + "SETTINGS::PAYMENTS:STRIPE:SECRET" => "stripe-secret", + "SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET" => "stripe-endpoint-secret", + "SETTINGS::PAYMENTS:STRIPE:TEST_SECRET" => "stripe-test-secret", + "SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET" => "stripe-endpoint-test-secret", + "SETTINGS::PAYMENTS:STRIPE:METHODS" => "stripe-methods", + "SETTINGS::PAYMENTS:SALES_TAX" => "salex_tax" + ]; + + + foreach ($values as $key => $value) { + $param = $request->get($value); + if (!$param) { + $param = ""; + } + Settings::where('key', $key)->update(['value' => $param]); + Cache::forget("setting" . ':' . $key); + Session::remove("locale"); + } + + + return redirect()->route('admin.settings.index')->with('success', 'Payment settings updated!'); + } + +} diff --git a/app/Http/Controllers/Admin/CreditProductController.php b/app/Http/Controllers/Admin/CreditProductController.php index d85297fe..268811d8 100644 --- a/app/Http/Controllers/Admin/CreditProductController.php +++ b/app/Http/Controllers/Admin/CreditProductController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin; use App\Models\CreditProduct; +use App\Models\Settings; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; @@ -25,8 +26,8 @@ class CreditProductController extends Controller if ( env('APP_ENV') == 'local' || - env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID') || - env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS') + Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") || + Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:METHODS") ) $isPaymentSetup = true; return view('admin.store.index', [ diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index 7c0ed360..7efaaa35 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -134,7 +134,7 @@ class PaymentController extends Controller */ protected function getPaypalClientId() { - return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_CLIENT_ID') : env('PAYPAL_CLIENT_ID'); + return env('APP_ENV') == 'local' ? Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID") : Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID"); } /** @@ -142,7 +142,7 @@ class PaymentController extends Controller */ protected function getPaypalClientSecret() { - return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_SECRET') : env('PAYPAL_SECRET'); + return env('APP_ENV') == 'local' ? Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET") : Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SECRET"); } /** @@ -266,7 +266,7 @@ class PaymentController extends Controller ], 'mode' => 'payment', - "payment_method_types" => str_getcsv(env('STRIPE_METHODS')), + "payment_method_types" => str_getcsv(Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:METHODS")), 'success_url' => route('payment.StripeSuccess', ['product' => $creditProduct->id]) . '&session_id={CHECKOUT_SESSION_ID}', 'cancel_url' => route('payment.Cancel'), ]); @@ -474,8 +474,8 @@ class PaymentController extends Controller protected function getStripeSecret() { return env('APP_ENV') == 'local' - ? env('STRIPE_TEST_SECRET') - : env('STRIPE_SECRET'); + ? Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:TEST_SECRET") + : Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:SECRET"); } /** @@ -484,8 +484,8 @@ class PaymentController extends Controller protected function getStripeEndpointSecret() { return env('APP_ENV') == 'local' - ? env('STRIPE_ENDPOINT_TEST_SECRET') - : env('STRIPE_ENDPOINT_SECRET'); + ? Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET") + : Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET"); } diff --git a/app/Http/Controllers/StoreController.php b/app/Http/Controllers/StoreController.php index eac70f98..db692bfb 100644 --- a/app/Http/Controllers/StoreController.php +++ b/app/Http/Controllers/StoreController.php @@ -15,8 +15,8 @@ class StoreController extends Controller if ( env('APP_ENV') == 'local' || - env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID') || - env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS') + Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID") || + Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET") && Settings::getValueByKey("SETTINGS::PAYMENTS:STRIPE:METHODS") ) $isPaymentSetup = true; //Required Verification for creating an server diff --git a/database/seeders/Seeds/SettingsSeeder.php b/database/seeders/Seeds/SettingsSeeder.php index 010e76b0..85ed7ad2 100644 --- a/database/seeders/Seeds/SettingsSeeder.php +++ b/database/seeders/Seeds/SettingsSeeder.php @@ -246,5 +246,137 @@ class SettingsSeeder extends Seeder 'type' => 'string', 'description' => 'The Language of the Datatables. Grab the Language-Codes from here https://datatables.net/plug-ins/i18n/' ]); + + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your PayPal Secret-Key ( https://developer.paypal.com/docs/integration/direct/rest/)' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your PayPal Client_ID' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your PayPal SANDBOX Secret-Key used for testing ' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your PayPal SANDBOX Client-ID used for testing ' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:STRIPE:SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your Stripe Secret-Key ( https://dashboard.stripe.com/account/apikeys )' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your Stripe endpoint secret-key' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your Stripe test secret-key' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Your Stripe endpoint test secret-key' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::PAYMENTS:STRIPE:METHODS', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Comma seperated list of payment methods that are enabled (https://stripe.com/docs/payments/payment-methods/integration-options)' + ]); + + Settings::firstOrCreate([ + 'key' => 'SETTINGS::DISCORD:CLIENT_ID', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Discord API Credentials - https://discordapp.com/developers/applications/' + ]); + + Settings::firstOrCreate([ + 'key' => 'SETTINGS::DISCORD:CLIENT_SECRET', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Discord API Credentials - https://discordapp.com/developers/applications/' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::DISCORD:BOT_TOKEN', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Discord API Credentials - https://discordapp.com/developers/applications/' + ]); + + Settings::firstOrCreate([ + 'key' => 'SETTINGS::DISCORD:GUILD_ID', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Discord API Credentials - https://discordapp.com/developers/applications/' + ]); + + Settings::firstOrCreate([ + 'key' => 'SETTINGS::DISCORD:ROLE_ID', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Discord role that will be assigned to users when they register' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::DISCORD:INVITE_URL', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'The invite URL to your Discord Server' + ]); + + Settings::firstOrCreate([ + 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'Admin API Token from Pterodactyl Panel - necessary for the Panel to work. The Key needs all read&write permissions!' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'The URL to your Pterodactyl Panel. Must not end with a / ' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::MISC:PHPMYADMIN:URL', + ], [ + 'value' => '', + 'type' => 'string', + 'description' => 'The URL to your PHPMYADMIN Panel. Must not end with a /, remove to remove database button' + ]); } } diff --git a/resources/views/admin/settings/tabs/language.blade.php b/resources/views/admin/settings/tabs/language.blade.php index 289935cc..f013ed29 100644 --- a/resources/views/admin/settings/tabs/language.blade.php +++ b/resources/views/admin/settings/tabs/language.blade.php @@ -77,13 +77,6 @@ - - - - - - -