Pārlūkot izejas kodu

feat: ✨ Added Notification if Stripe isnt setup (like paypal) in store

IceToast 3 gadi atpakaļ
vecāks
revīzija
7989ff57b9

+ 9 - 3
app/Http/Controllers/StoreController.php

@@ -12,9 +12,14 @@ class StoreController extends Controller
     public function index()
     {
         $isPaypalSetup = false;
-        if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
-        if (env('APP_ENV', 'local') == 'local') $isPaypalSetup = true;
+        $isStripeSetup = 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;
 
         //Required Verification for creating an server
         if (Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
@@ -28,7 +33,8 @@ class StoreController extends Controller
 
         return view('store.index')->with([
             'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
-            'isPaypalSetup' => $isPaypalSetup
+            'isPaypalSetup' => $isPaypalSetup,
+            'isStripeSetup' => $isStripeSetup
         ]);
     }
 }

+ 55 - 31
resources/views/admin/store/index.blade.php

@@ -6,13 +6,13 @@
         <div class="container-fluid">
             <div class="row mb-2">
                 <div class="col-sm-6">
-                    <h1>{{__('Store')}}</h1>
+                    <h1>{{ __('Store') }}</h1>
                 </div>
                 <div class="col-sm-6">
                     <ol class="breadcrumb float-sm-right">
-                        <li class="breadcrumb-item"><a href="{{route('home')}}">{{__('Dashboard')}}</a></li>
+                        <li class="breadcrumb-item"><a href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
                         <li class="breadcrumb-item"><a class="text-muted"
-                                                       href="{{route('admin.store.index')}}">{{__('Store')}}</a></li>
+                                href="{{ route('admin.store.index') }}">{{ __('Store') }}</a></li>
                     </ol>
                 </div>
             </div>
@@ -26,10 +26,18 @@
 
             <div class="row">
                 <div class="col-lg-4">
-                    @if($isPaypalSetup == false)
+                    @if ($isPaypalSetup == 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>
+                            <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.') }}
+                            </p>
                         </div>
                     @endif
                 </div>
@@ -39,9 +47,9 @@
 
                 <div class="card-header">
                     <div class="d-flex justify-content-between">
-                        <h5 class="card-title"><i class="fas fa-sliders-h mr-2"></i>{{__('Store')}}</h5>
-                        <a href="{{route('admin.store.create')}}" class="btn btn-sm btn-primary"><i
-                                class="fas fa-plus mr-1"></i>{{__('Create new')}}</a>
+                        <h5 class="card-title"><i class="fas fa-sliders-h mr-2"></i>{{ __('Store') }}</h5>
+                        <a href="{{ route('admin.store.create') }}" class="btn btn-sm btn-primary"><i
+                                class="fas fa-plus mr-1"></i>{{ __('Create new') }}</a>
                     </div>
                 </div>
 
@@ -49,15 +57,15 @@
 
                     <table id="datatable" class="table table-striped">
                         <thead>
-                        <tr>
-                            <th>{{__('Active')}}</th>
-                            <th>{{__('Type')}}</th>
-                            <th>{{__('Price')}}</th>
-                            <th>{{__('Display')}}</th>
-                            <th>{{__('Description')}}</th>
-                            <th>{{__('Created at')}}</th>
-                            <th></th>
-                        </tr>
+                            <tr>
+                                <th>{{ __('Active') }}</th>
+                                <th>{{ __('Type') }}</th>
+                                <th>{{ __('Price') }}</th>
+                                <th>{{ __('Display') }}</th>
+                                <th>{{ __('Description') }}</th>
+                                <th>{{ __('Created at') }}</th>
+                                <th></th>
+                            </tr>
                         </thead>
                         <tbody>
                         </tbody>
@@ -78,26 +86,42 @@
             return confirm("Are you sure you wish to delete?") !== false;
         }
 
-        document.addEventListener("DOMContentLoaded", function () {
+        document.addEventListener("DOMContentLoaded", function() {
             $('#datatable').DataTable({
                 language: {
-                    url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{config("app.datatable_locale")}}.json'
+                    url: '//cdn.datatables.net/plug-ins/1.11.3/i18n/{{ config('app.datatable_locale') }}.json'
                 },
                 processing: true,
                 serverSide: true,
                 stateSave: true,
-                ajax: "{{route('admin.store.datatable')}}",
-                order: [[ 2, "desc" ]],
-                columns: [
-                    {data: 'disabled'},
-                    {data: 'type'},
-                    {data: 'price'},
-                    {data: 'display'},
-                    {data: 'description'},
-                    {data: 'created_at'},
-                    {data: 'actions', sortable: false},
+                ajax: "{{ route('admin.store.datatable') }}",
+                order: [
+                    [2, "desc"]
+                ],
+                columns: [{
+                        data: 'disabled'
+                    },
+                    {
+                        data: 'type'
+                    },
+                    {
+                        data: 'price'
+                    },
+                    {
+                        data: 'display'
+                    },
+                    {
+                        data: 'description'
+                    },
+                    {
+                        data: 'created_at'
+                    },
+                    {
+                        data: 'actions',
+                        sortable: false
+                    },
                 ],
-                fnDrawCallback: function( oSettings ) {
+                fnDrawCallback: function(oSettings) {
                     $('[data-toggle="popover"]').popover();
                 }
             });