Index: /mods/wpsg_mod_paypalapi.class.php
===================================================================
--- /mods/wpsg_mod_paypalapi.class.php	(revision 8327)
+++ /mods/wpsg_mod_paypalapi.class.php	(revision 8328)
@@ -768,7 +768,17 @@
 				
 				$log_JsonData = json_decode($bodyReceived, true);
-				$log_paymentID = $log_JsonData['resource']['id'];
-				$log_orderID = $this->db->fetchOne("SELECT `target_id` FROM `".WPSG_TBL_META."` WHERE `meta_table` = 'WPSG_TBL_ORDER' AND `meta_key` = 'wpsg_mod_paypalapi_paymentid' AND `meta_value` = '".wpsg_q($log_paymentID)."' ");
-					
+				
+				if ($log_JsonData['event_type'] === 'PAYMENT.CAPTURE.COMPLETED') {
+	
+					$log_paymentID = $log_JsonData['resource']['id'];
+					$log_orderID = intval($this->db->fetchOne("SELECT `target_id` FROM `".WPSG_TBL_META."` WHERE `meta_table` = 'WPSG_TBL_ORDER' AND `meta_key` = 'wpsg_mod_paypalapi_saleid' AND `meta_value` = '".wpsg_q($log_paymentID)."' "));
+					
+				} else {
+	
+					$log_paymentID = $log_JsonData['resource']['parent_payment'];
+					$log_orderID = $this->db->fetchOne("SELECT `target_id` FROM `".WPSG_TBL_META."` WHERE `meta_table` = 'WPSG_TBL_ORDER' AND `meta_key` = 'wpsg_mod_paypalapi_paymentid' AND `meta_value` = '".wpsg_q($log_paymentID)."' ");
+	
+				}
+				
 				$strLog = date('d.m.Y H:i:s', time())."\r\nRAW:".$bodyReceived."\r\nDECODED:".print_r($log_JsonData, 1)."\r\nPAYMENT_ID:".$log_paymentID."\r\nGEFUNDENE BESTELLID:".$log_orderID."\r\n---------------\r\n\r\n";
 				file_put_contents($log_file, file_get_contents($log_file)."\r\n".$strLog);
