Przeglądaj źródła

feat: ♻️ Changed payment Status to "paid" && Updated admin/payment table

IceToast 3 lat temu
rodzic
commit
45b7d703a5

+ 6 - 3
app/Http/Controllers/Admin/PaymentController.php

@@ -179,7 +179,7 @@ class PaymentController extends Controller
                     'payment_id' => $response->result->id,
                     'payment_method' => 'paypal',
                     'type' => 'Credits',
-                    'status' => $response->result->status,
+                    'status' => 'paid',
                     'amount' => $creditProduct->quantity,
                     'price' => $creditProduct->price,
                     'tax_value' => $creditProduct->getTaxValue(),
@@ -290,7 +290,6 @@ class PaymentController extends Controller
         try{
         $paymentSession = $stripeClient->checkout->sessions->retrieve($request->input('session_id'));
         $capturedPaymentIntent = $stripeClient->paymentIntents->capture($paymentSession->payment_intent);
-
         if ($capturedPaymentIntent->status == "succeeded") {
 
             //update credits
@@ -314,7 +313,7 @@ class PaymentController extends Controller
                 'payment_id' => $capturedPaymentIntent->id,
                 'payment_method' => 'stripe',
                 'type' => 'Credits',
-                'status' => $capturedPaymentIntent->status,
+                'status' => 'paid',
                 'amount' => $creditProduct->quantity,
                 'price' => $creditProduct->price,
                 'tax_value' => $creditProduct->getTaxValue(),
@@ -388,9 +387,13 @@ class PaymentController extends Controller
             ->editColumn('tax_value', function (Payment $payment) {
                 return $payment->formatToCurrency($payment->tax_value);
             })
+            ->editColumn('tax_percent', function (Payment $payment) {
+                return $payment->tax_percent . ' %';
+            })
             ->editColumn('total_price', function (Payment $payment) {
                 return $payment->formatToCurrency($payment->total_price);
             })
+
             ->editColumn('created_at', function (Payment $payment) {
                 return $payment->created_at ? $payment->created_at->diffForHumans() : '';
             })

+ 5 - 7
resources/views/admin/payments/index.blade.php

@@ -34,15 +34,14 @@
                         <thead>
                         <tr>
                             <th>ID</th>
-                            <th>User</th>
                             <th>Type</th>
                             <th>Amount</th>
                             <th>Product Price</th>
-                            <th>Tax</th>
-                            <th>Tax(%)</th>
+                            <th>Tax Value</th>
+                            <th>Tax Percentage</th>
                             <th>Total Price</th>
                             <th>Payment_ID</th>
-                            <th>Payer_ID</th>
+                            <th>Payment Method</th>
                             <th>Created at</th>
                         </tr>
                         </thead>
@@ -67,7 +66,6 @@
                 ajax: "{{route('admin.payments.datatable')}}",
                 columns: [
                     {data: 'id' , name : 'payments.id'},
-                    {data: 'user', sortable: false},
                     {data: 'type'},
                     {data: 'amount'},
                     {data: 'price'},
@@ -75,12 +73,12 @@
                     {data: 'tax_percent'},
                     {data: 'total_price'},
                     {data: 'payment_id'},
-                    {data: 'payer_id'},
+                    {data: 'payment_method'},
                     {data: 'created_at'},
                 ],
                 fnDrawCallback: function( oSettings ) {
                     $('[data-toggle="popover"]').popover();
-                }
+                },  
             });
         });
     </script>