فهرست منبع

fix: 🐛 PayPalSuccess payment status "paid" & Require auth on payment routes

IceToast 2 سال پیش
والد
کامیت
41f8fd9550

+ 3 - 3
app/Extensions/PaymentGateways/PayPal/index.php

@@ -118,7 +118,7 @@ function PaypalSuccess(Request $laravelRequest)
         if ($response->statusCode == 201 || $response->statusCode == 200) {
             //update payment
             $payment->update([
-                'status' => 'success',
+                'status' => 'paid',
                 'payment_id' => $response->result->id,
             ]);
 
@@ -133,7 +133,7 @@ function PaypalSuccess(Request $laravelRequest)
             dd($response);
         } else {
             $payment->update([
-                'status' => 'failed',
+                'status' => 'cancelled',
                 'payment_id' => $response->result->id,
             ]);
             abort(500);
@@ -145,7 +145,7 @@ function PaypalSuccess(Request $laravelRequest)
             dd($ex->getMessage());
         } else {
             $payment->update([
-                'status' => 'failed',
+                'status' => 'cancelled',
                 'payment_id' => $response->result->id,
             ]);
             abort(422);

+ 12 - 7
app/Extensions/PaymentGateways/PayPal/routes.php

@@ -1,13 +1,18 @@
 <?php
 
 use Illuminate\Support\Facades\Route;
+
 include_once(__DIR__ . '/index.php');
 
-Route::get('payment/PayPalPay/{shopProduct}', function () {
-    PaypalPay(request());
-})->name('payment.PayPalPay');
+Route::middleware(['web', 'auth'])->group(function () {
+    Route::get('payment/PayPalPay/{shopProduct}', function () {
+        PaypalPay(request());
+    })->name('payment.PayPalPay');
 
-Route::get('payment/PayPalSuccess',  function () {
-    PaypalSuccess(request());
-}
-)->name('payment.PayPalSuccess');
+    Route::get(
+        'payment/PayPalSuccess',
+        function () {
+            PaypalSuccess(request());
+        }
+    )->name('payment.PayPalSuccess');
+});

+ 11 - 10
app/Extensions/PaymentGateways/Stripe/routes.php

@@ -3,17 +3,18 @@
 use Illuminate\Support\Facades\Route;
 
 include_once(__DIR__ . '/index.php');
+Route::middleware(['web', 'auth'])->group(function () {
+    Route::get('payment/StripePay/{shopProduct}', function () {
+        StripePay(request());
+    })->name('payment.StripePay');
 
-Route::get('payment/StripePay/{shopProduct}', function () {
-    StripePay(request());
-})->name('payment.StripePay');
-
-Route::get(
-    'payment/StripeSuccess',
-    function () {
-        StripeSuccess(request());
-    }
-)->name('payment.StripeSuccess');
+    Route::get(
+        'payment/StripeSuccess',
+        function () {
+            StripeSuccess(request());
+        }
+    )->name('payment.StripeSuccess');
+});
 
 
 // Stripe WebhookRoute -> validation in Route Handler