Browse Source

Aways check if has coupon code in the request.

Ferks-FK 1 year ago
parent
commit
04940f040b
1 changed files with 4 additions and 1 deletions
  1. 4 1
      app/Http/Controllers/Admin/PaymentController.php

+ 4 - 1
app/Http/Controllers/Admin/PaymentController.php

@@ -180,7 +180,10 @@ class PaymentController extends Controller
 
             $paymentGatewayExtension = ExtensionHelper::getExtensionClass($paymentGateway);
             $redirectUrl = $paymentGatewayExtension::getRedirectUrl($payment, $shopProduct, $totalPriceString);
-            event(new CouponUsedEvent($couponCode));
+
+            if ($couponCode) {
+                event(new CouponUsedEvent($couponCode));
+            }
         } catch (Exception $e) {
             Log::error($e->getMessage());
             return redirect()->route('store.index')->with('error', __('Oops, something went wrong! Please try again later.'));