@@ -275,7 +275,15 @@ public function receivePush()
275275
276276 $ this ->logging ->addDebug (__METHOD__ . '|1_2| ' );
277277 $ orderIncrementID = $ this ->getOrderIncrementId ();
278- $ this ->logging ->addDebug (__METHOD__ . '|Lock Name| - ' . var_export ($ orderIncrementID , true ));
278+ $ transactionKey = $ this ->getTransactionKey ();
279+
280+ $ this ->logging ->addDebug (sprintf (
281+ '%s|Processing push for Order: %s, Transaction: %s ' ,
282+ __METHOD__ ,
283+ $ orderIncrementID ,
284+ $ transactionKey
285+ ));
286+
279287 $ lockAcquired = $ this ->lockManager ->lockOrder ($ orderIncrementID , 5 );
280288
281289 if (!$ lockAcquired ) {
@@ -1294,14 +1302,47 @@ protected function getOrderByTransactionKey()
12941302 {
12951303 $ trxId = $ this ->getTransactionKey ();
12961304
1297- $ this ->transaction -> load ( $ trxId , 'txn_id ' );
1298- $ order = $ this ->transaction -> getOrder ();
1305+ $ this ->searchCriteriaBuilder -> addFilter ( ' txn_id ' , $ trxId , 'eq ' );
1306+ $ searchCriteria = $ this ->searchCriteriaBuilder -> create ();
12991307
1300- if (!$ order ) {
1308+ try {
1309+ $ transactionList = $ this ->transactionRepository ->getList ($ searchCriteria );
1310+ $ items = $ transactionList ->getItems ();
1311+
1312+ if (empty ($ items )) {
1313+ $ this ->logging ->addError (sprintf (
1314+ '%s|No transaction found for txn_id: %s. This may indicate the transaction was not saved properly or a database transaction was rolled back. ' ,
1315+ __METHOD__ ,
1316+ $ trxId
1317+ ));
1318+ throw new Exception (__ ('There was no order found by transaction Id ' ));
1319+ }
1320+
1321+ // Get the first (and should be only) transaction
1322+ $ transaction = reset ($ items );
1323+ $ order = $ transaction ->getOrder ();
1324+
1325+ if (!$ order || !$ order ->getId ()) {
1326+ $ this ->logging ->addError (sprintf (
1327+ '%s|Transaction found but order is missing for txn_id: %s. Transaction ID: %s ' ,
1328+ __METHOD__ ,
1329+ $ trxId ,
1330+ $ transaction ->getTransactionId ()
1331+ ));
1332+ throw new Exception (__ ('There was no order found by transaction Id ' ));
1333+ }
1334+
1335+ return $ order ;
1336+
1337+ } catch (\Exception $ e ) {
1338+ $ this ->logging ->addError (sprintf (
1339+ '%s|Error loading transaction by txn_id: %s. Error: %s ' ,
1340+ __METHOD__ ,
1341+ $ trxId ,
1342+ $ e ->getMessage ()
1343+ ));
13011344 throw new Exception (__ ('There was no order found by transaction Id ' ));
13021345 }
1303-
1304- return $ order ;
13051346 }
13061347
13071348 /**
0 commit comments