Explorar o código

fix: 🚑️ changed the payment setup detection

IceToast %!s(int64=3) %!d(string=hai) anos
pai
achega
b775ce6cc7

+ 8 - 3
app/Http/Controllers/Admin/CreditProductController.php

@@ -21,11 +21,16 @@ class CreditProductController extends Controller
      */
     public function index(Request $request)
     {
-        $isPaypalSetup = false;
-        if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
+        $isPaymentSetup = false;
+
+        if (
+            env('APP_ENV') == 'local' ||
+            env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID') ||
+            env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS')
+        ) $isPaymentSetup = true;
 
         return view('admin.store.index', [
-            'isPaypalSetup' => $isPaypalSetup
+            'isPaymentSetup' => $isPaymentSetup
         ]);
     }
 

+ 7 - 10
app/Http/Controllers/StoreController.php

@@ -11,15 +11,13 @@ class StoreController extends Controller
     /** Display a listing of the resource. */
     public function index()
     {
-        $isPaypalSetup = false;
-        $isStripeSetup = false;
+        $isPaymentSetup = false;
 
-        if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
-        if (env('APP_ENV', 'local') == 'local') {
-            $isPaypalSetup = true;
-            $isStripeSetup = true;
-        }
-        if (env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS')) $isStripeSetup = true;
+        if (
+            env('APP_ENV') == 'local' ||
+            env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID') ||
+            env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS')
+        ) $isPaymentSetup = true;
 
         //Required Verification for creating an server
         if (Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
@@ -33,8 +31,7 @@ class StoreController extends Controller
 
         return view('store.index')->with([
             'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
-            'isPaypalSetup' => $isPaypalSetup,
-            'isStripeSetup' => $isStripeSetup
+            'isPaymentSetup' => $isPaymentSetup,
         ]);
     }
 }

+ 4 - 10
resources/views/admin/store/index.blade.php

@@ -26,20 +26,14 @@
 
             <div class="row">
                 <div class="col-lg-4">
-                    @if ($isPaypalSetup == false)
+                    @if ($isPaymentSetup == false)
                         <div class="callout callout-danger">
-                            <h4>{{ __('Paypal is not configured.') }}</h4>
-                            <p>{{ __('To configure PayPal, head to the .env and add your PayPal’s client id and secret.') }}
-                            </p>
-                        </div>
-                    @endif
-                    @if ($isStripeSetup == false)
-                        <div class="callout callout-danger">
-                            <h4>{{ __('Stripe is not configured.') }}</h4>
-                            <p>{{ __('To configure Stripe, head to the .env and add your Stripüe Secret, Endpoint and supported Payment Methods.') }}
+                            <h4>{{ __('No payment method is configured.') }}</h4>
+                            <p>{{ __('To configure your payment methods, head to the .env and add the required options for your prefered payment method.') }}
                             </p>
                         </div>
                     @endif
+
                 </div>
             </div>
 

+ 1 - 1
resources/views/store/index.blade.php

@@ -32,7 +32,7 @@
                 </button>
             </div>
 
-            @if ($isPaypalSetup && $products->count() > 0)
+            @if ($isPaymentSetup && $products->count() > 0)
 
                 <div class="card">
                     <div class="card-header">