Forráskód Böngészése

Merge branch 'master' of https://rav.triplestart.com/tigerphp/lemon-admin

Peter Muturi 7 hónapja
szülő
commit
9bf22ce54c

+ 20 - 8
app/Models/PaymentMethod.php

@@ -77,15 +77,27 @@ class PaymentMethod extends BaseModel
     }
 
     public function isExpired() {
-        $stripeDetailJson = json_decode($this->stripe_detail_json);
-        $expirationMonth = @$stripeDetailJson->card ? @$stripeDetailJson->card->exp_month : null;
-        $expirationYear = @$stripeDetailJson->card ? @$stripeDetailJson->card->exp_year : null;
-
-        if((int) $expirationYear >= (int) date('Y')){
-            if((int) $expirationMonth >= (int) date('m')){
-                return false;
+        $expirationMonth = $this->expiration_month;
+        $expirationYear = $this->expiration_year;
+    
+        // If expiration details are missing, try to retrieve them from stripe_detail_json
+        if (!$expirationYear || !$expirationMonth) {
+            $stripeDetailJson = json_decode($this->stripe_detail_json);
+    
+            if (isset($stripeDetailJson->card->exp_month) && isset($stripeDetailJson->card->exp_year)) {
+                $expirationMonth = (int) $stripeDetailJson->card->exp_month;
+                $expirationYear = (int) $stripeDetailJson->card->exp_year;
+            } else {
+                // Return true if expiration details are not found
+                return true;
             }
         }
-        return true;
+    
+        $currentYear = (int) date('Y');
+        $currentMonth = (int) date('m');
+    
+        // Check if the card is expired
+        return ($expirationYear < $currentYear) || 
+               ($expirationYear === $currentYear && $expirationMonth < $currentMonth);
     }
 }

+ 1 - 0
app/Models/StoreOrder.php

@@ -193,6 +193,7 @@ class StoreOrder extends BaseModel
         $summary['all_tests'] = $allTests;
         $summary['client_total'] = $orderTotal - $partnerTotal;
         $summary['partner_total'] = $partnerTotal;
+        $summary['sub_total'] = $orderTotal + $partnerDiscount;
         $summary['final_total'] = $orderTotal;
         $summary['has_partner'] = $hasPartner;
         $summary['partner_total_discount'] = $partnerDiscount;

+ 20 - 29
resources/views/app/my-account/admin/orders/sub/template/invoice-order-detail.blade.php

@@ -1,7 +1,7 @@
 <?php
-$orderDetailJson = $order->detailJson();
-$orderSelectedOptions = json_decode(@$orderDetailJson->selected_options ?? '{}');
-$orderSummary = $order->getOrderAllTestsRequested();
+    $orderDetailJson = $order->detailJson();
+    $orderSelectedOptions = json_decode(@$orderDetailJson->selected_options ?? '{}');
+    $orderSummary = $order->getOrderAllTestsRequested();
 ?>
 
 <tr>
@@ -34,8 +34,7 @@ $orderSummary = $order->getOrderAllTestsRequested();
                 <tr height="24" style="background-color:rgb(250,250,250)">
                     <td colspan="5" valign="top"
                         style="text-align:center;text-transform:uppercase;padding:6px;border-top-left-radius:3px;border-bottom-left-radius:3px">
-                        <span style="font-size:15px;font-weight:600">Tests Ordered</span>
-                    </td>
+                        <span style="font-size:15px;font-weight:600">Tests Ordered</span></td>
                 </tr>
                 <tr height="15">
                     <td colspan="5"></td>
@@ -43,7 +42,8 @@ $orderSummary = $order->getOrderAllTestsRequested();
                 @foreach ($orderSummary['all_tests'] as $tkey => $test)
                     <tr>
                         <td colspan="3" style="padding:0 0 0 0;vertical-align:top;">
-                            <span style="font-weight:400;">{{ $test['name'] }}</span>
+                            <span
+                                style="font-weight:400;">{{ $test['name'] }}</span>
                         </td>
                         <td align="right" valign="top" style="padding:0 0px;">
                             <span
@@ -54,17 +54,18 @@ $orderSummary = $order->getOrderAllTestsRequested();
 
                 @if (@$orderSelectedOptions->partner == 1)
 
-                    @foreach ($orderSummary['all_tests'] as $pTestKey => $pTest)
-                        <tr>
-                            <td colspan="3" style="padding:0 0 0 0;vertical-align:top;">
-                                <span style="font-weight:400;">{{ $pTest['name'] }} (Partner Test)</span>
-                            </td>
-                            <td align="right" valign="top" style="padding:0 0px;">
-                                <span
-                                    style="font-weight:400;white-space:nowrap;display:block;">${{ number_format($pTest['price'], 2) }}</span>
-                            </td>
-                        </tr>
-                    @endforeach
+                @foreach ($orderSummary['all_tests'] as $pTestKey => $pTest)
+                    <tr>
+                        <td colspan="3" style="padding:0 0 0 0;vertical-align:top;">
+                            <span
+                                style="font-weight:400;">{{ $pTest['name'] }} (Partner Test)</span>
+                        </td>
+                        <td align="right" valign="top" style="padding:0 0px;">
+                            <span
+                                style="font-weight:400;white-space:nowrap;display:block;">${{ number_format($pTest['price'], 2) }}</span>
+                        </td>
+                    </tr>
+                @endforeach
                 @endif
             </tbody>
         </table>
@@ -87,21 +88,11 @@ $orderSummary = $order->getOrderAllTestsRequested();
                     <tr height="28">
                         <td align="right"
                             style="color:#000;font-size:14px;font-weight:400;padding:0 30px 0 0;border:none;border-width:1px;border-color:rgb(238,238,238)">
-                            User Tests Total</td>
-                        <td width="1" style="background-color:rgb(238,238,238);width:1px"></td>
-                        <td width="90" align="right"
-                            style="width:120px;font-size:16px;font-weight:400;white-space:nowrap">
-                            ${{ number_format(@$orderSummary['client_total'], 2) }}
-                        </td>
-                    </tr>
-                    <tr height="28">
-                        <td align="right"
-                            style="color:#000;font-size:14px;font-weight:400;padding:0 30px 0 0;border:none;border-width:1px;border-color:rgb(238,238,238)">
-                            Partner Total</td>
+                            Subtotal</td>
                         <td width="1" style="background-color:rgb(238,238,238);width:1px"></td>
                         <td width="90" align="right"
                             style="width:120px;font-size:16px;font-weight:400;white-space:nowrap">
-                            ${{ number_format(@$orderSummary['partner_total'], 2) }}
+                            ${{ number_format(@$orderSummary['sub_total'], 2) }}
                         </td>
                     </tr>
                     <tr height="28">

+ 6 - 1
resources/views/layouts/app.blade.php

@@ -32,11 +32,16 @@
     <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
 
     {!! ReCaptcha::htmlScriptTagJsApi() !!}
+    <script>
+        const sessionKey = "{{ @$performer->session_key }}";
+    </script>
     <script>
         $(function() {
       $.ajaxSetup({
         headers: {
-          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
+          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
+          'sessionKey': sessionKey,
+          
         }
       });
     });