diff --git a/Components/Manager/OrderManager.php b/Components/Manager/OrderManager.php
new file mode 100644
index 00000000..fc6f15cd
--- /dev/null
+++ b/Components/Manager/OrderManager.php
@@ -0,0 +1,41 @@
+modelManager = $modelManager;
+ }
+
+ public function save(Order $order)
+ {
+ $this->modelManager->persist($order);
+ $this->modelManager->flush($order);
+ }
+
+ public function updatePspReference(Order $order, string $pspReference)
+ {
+ $order = $order->setTransactionId($pspReference);
+ $this->modelManager->persist($order);
+ }
+
+ public function updatePayment(Order $order, string $pspReference, Status $paymentStatus)
+ {
+ $order->setPaymentStatus($paymentStatus);
+ $order = $order->setTransactionId($pspReference);
+ $this->modelManager->persist($order);
+ }
+}
diff --git a/Components/Manager/OrderManagerInterface.php b/Components/Manager/OrderManagerInterface.php
new file mode 100644
index 00000000..dbee8f5e
--- /dev/null
+++ b/Components/Manager/OrderManagerInterface.php
@@ -0,0 +1,15 @@
+basketService = $this->get('adyen_payment.components.basket_service');
$this->orderMailService = $this->get('adyen_payment.components.order_mail_service');
$this->logger = $this->get('adyen_payment.logger');
+ $this->orderManager = $this->get('AdyenPayment\Components\Manager\OrderManager');
}
/**
@@ -142,9 +146,11 @@ private function handleReturnResult(array $result, $order)
break;
}
- $order->setPaymentStatus($paymentStatus);
- $order->setTransactionId($result['pspReference']);
- $this->getModelManager()->persist($order);
+ $this->orderManager->updatePayment(
+ $order,
+ (string) ($result['pspReference'] ?? ''),
+ $paymentStatus
+ );
}
/**
diff --git a/Resources/services/managers.xml b/Resources/services/managers.xml
index 13ce85e5..bdeff574 100644
--- a/Resources/services/managers.xml
+++ b/Resources/services/managers.xml
@@ -11,6 +11,10 @@
class="AdyenPayment\Components\NotificationManager">
+
+
+
+
diff --git a/Resources/services/subscribers.xml b/Resources/services/subscribers.xml
index 0aa3273a..4874eff4 100644
--- a/Resources/services/subscribers.xml
+++ b/Resources/services/subscribers.xml
@@ -66,5 +66,9 @@
+
+
+
+
diff --git a/Subscriber/Cronjob/ProcessNotifications.php b/Subscriber/Cronjob/ProcessNotifications.php
index 9793eab4..49ff6aee 100644
--- a/Subscriber/Cronjob/ProcessNotifications.php
+++ b/Subscriber/Cronjob/ProcessNotifications.php
@@ -81,7 +81,6 @@ public static function getSubscribedEvents()
public function runCronjob(Shopware_Components_Cron_CronJob $job)
{
$textNotifications = $this->fifoTextNotificationLoader->get();
-
$this->incomingNotificationManager->convertNotifications($textNotifications);
/** @var \Generator $feedback */
diff --git a/Subscriber/Notification/UpdateOrderPsPSubscriber.php b/Subscriber/Notification/UpdateOrderPsPSubscriber.php
new file mode 100644
index 00000000..1cf7d3ee
--- /dev/null
+++ b/Subscriber/Notification/UpdateOrderPsPSubscriber.php
@@ -0,0 +1,49 @@
+orderManager = $orderManager;
+ }
+
+ public static function getSubscribedEvents(): array
+ {
+ return [
+ Event::NOTIFICATION_PROCESS_AUTHORISATION => '__invoke',
+ ];
+ }
+
+ public function __invoke(Enlight_Event_EventArgs $args)
+ {
+ /**
+ * @var \Shopware\Models\Order\Order $order
+ * @var \AdyenPayment\Models\Notification $notification
+ */
+ $order = $args->get('order');
+ $notification = $args->get('notification');
+ if (!$notification->isSuccess()) {
+ return;
+ }
+
+ if ($order->getTransactionId() === $notification->getPspReference()) {
+ return;
+ }
+
+ $this->orderManager->updatePspReference($order, $notification->getPspReference());
+ }
+}