diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index 6ba123c5..9a554ad4 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\Configuration; use App\Models\Payment; use App\Models\PaypalProduct; use Illuminate\Contracts\Foundation\Application; @@ -20,15 +21,11 @@ use PayPalHttp\HttpException; class PaymentController extends Controller { - protected $allowedAmounts = [ - '87', - '350', - '1000', - '2000', - '4000' - ]; - - public function index(){ + /** + * @return Application|Factory|View + */ + public function index() + { return view('admin.payments.index')->with([ 'payments' => Payment::paginate(15) ]); @@ -51,17 +48,17 @@ class PaymentController extends Controller * @param PaypalProduct $paypalProduct * @return RedirectResponse */ - public function pay(Request $request , PaypalProduct $paypalProduct) + public function pay(Request $request, PaypalProduct $paypalProduct) { $request = new OrdersCreateRequest(); $request->prefer('return=representation'); $request->body = [ - "intent" => "CAPTURE", - "purchase_units" => [ + "intent" => "CAPTURE", + "purchase_units" => [ [ "reference_id" => uniqid(), - "amount" => [ - "value" => $paypalProduct->price, + "amount" => [ + "value" => $paypalProduct->price, "currency_code" => strtoupper($paypalProduct->currency_code) ] ] @@ -69,7 +66,7 @@ class PaymentController extends Controller "application_context" => [ "cancel_url" => route('payment.cancel'), "return_url" => route('payment.success', ['product' => $paypalProduct->id]), - 'brand_name' => config('app.name', 'Laravel') , + 'brand_name' => config('app.name', 'Laravel'), ] ]; @@ -133,8 +130,10 @@ class PaymentController extends Controller Auth::user()->increment('credits', $paypalProduct->quantity); //update server limit - if (Auth::user()->server_limit < 10) { - Auth::user()->update(['server_limit' => 10]); + if (Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE', 10) !== 0) { + if (Auth::user()->server_limit < Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE', 10)) { + Auth::user()->update(['server_limit' => 10]); + } } //update role diff --git a/app/Http/Controllers/StoreController.php b/app/Http/Controllers/StoreController.php index 2efd147f..03d2668e 100644 --- a/app/Http/Controllers/StoreController.php +++ b/app/Http/Controllers/StoreController.php @@ -16,6 +16,7 @@ class StoreController extends Controller { $isPaypalSetup = false; if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true; + if (env('APP_ENV' , 'local') == 'local') $isPaypalSetup = true; return view('store.index')->with([ 'products' => PaypalProduct::where('disabled' , '=' , false)->orderBy('price' , 'asc')->get(), diff --git a/database/seeders/Seeds/ConfigurationSeeder.php b/database/seeders/Seeds/ConfigurationSeeder.php index 02e6a220..7f42f334 100644 --- a/database/seeders/Seeds/ConfigurationSeeder.php +++ b/database/seeders/Seeds/ConfigurationSeeder.php @@ -80,7 +80,7 @@ class ConfigurationSeeder extends Seeder ], [ 'value' => '10', 'type' => 'integer', - 'description' => 'Sets the users server limit to this amount after purchasing with money, set to 0 to ignore this.', + 'description' => 'updates the users server limit to this amount (unless the user already has a higher server limit) after making a purchase with real money, set to 0 to ignore this.', ]); } } diff --git a/resources/views/admin/configurations/index.blade.php b/resources/views/admin/configurations/index.blade.php index afcee010..2b7297da 100644 --- a/resources/views/admin/configurations/index.blade.php +++ b/resources/views/admin/configurations/index.blade.php @@ -40,7 +40,7 @@ Key Value Type - Description + Description Created at diff --git a/resources/views/store/index.blade.php b/resources/views/store/index.blade.php index 1afe1983..8f448c2b 100644 --- a/resources/views/store/index.blade.php +++ b/resources/views/store/index.blade.php @@ -59,10 +59,10 @@ @else
-

@if($products->count() == 0) The store is temporarily - disabled! @else The store is not correctly configured! @endif +

@if($products->count() == 0) There are no store products! @else The store is not correctly configured! @endif

+ @endif