1414use PayPlugModule \Model \PayPlugCard ;
1515use PayPlugModule \Model \PayPlugCardQuery ;
1616use PayPlugModule \Model \PayPlugConfigValue ;
17+ use PayPlugModule \Model \PayPlugNotificationHistory ;
18+ use PayPlugModule \Model \PayPlugNotificationHistoryQuery ;
1719use PayPlugModule \PayPlugModule ;
1820use PayPlugModule \Service \OrderStatusService ;
1921use Propel \Runtime \Collection \Collection ;
2022use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
2123use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
2224use Thelia \Core \Event \Order \OrderEvent ;
2325use Thelia \Core \Event \TheliaEvents ;
26+ use Thelia \Log \Tlog ;
2427use Thelia \Model \Order ;
2528use Thelia \Model \OrderQuery ;
2629use Thelia \Model \OrderStatusQuery ;
@@ -164,11 +167,20 @@ public function handleRefundNotification(RefundNotificationEvent $event)
164167 if (!$ transactionRef ) {
165168 return ;
166169 }
167-
170+ $ id = $ event -> getResource ()-> id ;
168171 $ order = OrderQuery::create ()
169172 ->filterByTransactionRef ($ transactionRef )
170173 ->findOne ();
171174
175+ $ notificationHistory = PayPlugNotificationHistoryQuery::create ()
176+ ->filterByUuid ($ id )
177+ ->findOne ();
178+
179+ if (!!$ notificationHistory ) {
180+ Tlog::getInstance ()->addAlert ("Notification ' {$ id }' already exist " );
181+ return ;
182+ }
183+
172184 $ multiPayment = OrderPayPlugMultiPaymentQuery::create ()
173185 ->findOneByPaymentId ($ transactionRef );
174186
@@ -182,6 +194,8 @@ public function handleRefundNotification(RefundNotificationEvent $event)
182194 return ;
183195 }
184196
197+ (new PayPlugNotificationHistory ())->setUuid ($ id )->setOrderId ($ order ->getId ())->save ();
198+
185199 $ orderPayPlugData = OrderPayPlugDataQuery::create ()
186200 ->findOneById ($ order ->getId ());
187201
@@ -204,4 +218,4 @@ public static function getSubscribedEvents()
204218 RefundNotificationEvent::REFUND_NOTIFICATION_EVENT => ['handleRefundNotification ' , 128 ]
205219 ];
206220 }
207- }
221+ }
0 commit comments