From 7a5b0d4c538e00e243b15b5984a7125d55ac6724 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patrick=20M=C3=BCller?= <p.mueller@pcsg.de>
Date: Thu, 8 Mar 2018 16:24:34 +0100
Subject: [PATCH] fix: do not execute Order event if Order has no payment

---
 src/QUI/ERP/Payments/Amazon/Events.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/QUI/ERP/Payments/Amazon/Events.php b/src/QUI/ERP/Payments/Amazon/Events.php
index d22a295..b36046b 100644
--- a/src/QUI/ERP/Payments/Amazon/Events.php
+++ b/src/QUI/ERP/Payments/Amazon/Events.php
@@ -90,7 +90,13 @@ class Events
      */
     public static function onQuiqqerOrderSuccessful(QUI\ERP\Order\AbstractOrder $Order)
     {
-        if (!($Order->getPayment()->getPaymentType() instanceof AmazonPayment)) {
+        $OrderPayment = $Order->getPayment();
+
+        if (is_null($OrderPayment)) {
+            return;
+        }
+
+        if (!($OrderPayment->getPaymentType() instanceof AmazonPayment)) {
             return;
         }
 
-- 
GitLab