Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php |
— | — | @@ -31,15 +31,14 @@ |
32 | 32 | $files = $this->getAllLogFileNames(); |
33 | 33 | $payments = array(); |
34 | 34 | foreach ($files as $file){ |
35 | | - if (count($payments) >= $this->max_per_execute){ |
36 | | - continue; |
| 35 | + if (count($payments) < $this->max_per_execute){ |
| 36 | + $file_array = $this->getLogfileLines( $file ); |
| 37 | + $payments = array_merge($this->findTransactionLines($file_array), $payments); |
| 38 | + if (count($payments) === 0){ |
| 39 | + $this->killfiles[] = $file; |
| 40 | + echo print_r($this->killfiles, true); |
| 41 | + } |
37 | 42 | } |
38 | | - $file_array = $this->getLogfileLines( $file ); |
39 | | - $payments = array_merge($this->findTransactionLines($file_array), $payments); |
40 | | - if (count($payments) === 0){ |
41 | | - $this->killfiles[] = $file; |
42 | | - echo print_r($this->killfiles, true); |
43 | | - } |
44 | 43 | } |
45 | 44 | |
46 | 45 | $data = array( |
— | — | @@ -89,19 +88,23 @@ |
90 | 89 | // Preferably *before* you rewrite the Order ID file. |
91 | 90 | |
92 | 91 | //we may need to unset some hooks out here. Like... recaptcha. Makes no sense. |
| 92 | + $i = 0; |
93 | 93 | foreach($payments as $payment_data){ |
94 | | - $adapter->loadDataAndReInit($payment_data['unstaged']); |
95 | | - $results = $adapter->do_transaction('Confirm_CreditCard'); |
96 | | - if ($results['status'] == true){ |
97 | | - $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": FINAL: " . $results['action']); |
98 | | - unset($this->order_ids[$payment_data['unstaged']['order_id']]); |
99 | | - } else { |
100 | | - $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " . $results['message']); |
101 | | - if (strpos($results['message'], "GET_ORDERSTATUS reports that the payment is already complete.")){ |
| 94 | + if ($i < $this->max_per_execute){ |
| 95 | + ++$i; |
| 96 | + $adapter->loadDataAndReInit($payment_data['unstaged']); |
| 97 | + $results = $adapter->do_transaction('Confirm_CreditCard'); |
| 98 | + if ($results['status'] == true){ |
| 99 | + $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": FINAL: " . $results['action']); |
102 | 100 | unset($this->order_ids[$payment_data['unstaged']['order_id']]); |
| 101 | + } else { |
| 102 | + $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " . $results['message']); |
| 103 | + if (strpos($results['message'], "GET_ORDERSTATUS reports that the payment is already complete.")){ |
| 104 | + unset($this->order_ids[$payment_data['unstaged']['order_id']]); |
| 105 | + } |
103 | 106 | } |
| 107 | + echo $results['message'] . "\n"; |
104 | 108 | } |
105 | | - echo $results['message'] . "\n"; |
106 | 109 | } |
107 | 110 | |
108 | 111 | if ($outstanding_count != count($this->order_ids)){ |
— | — | @@ -138,16 +141,15 @@ |
139 | 142 | |
140 | 143 | $order_ids = $this->order_ids; |
141 | 144 | foreach ($lines as $line_no=>$line_data){ |
142 | | - if (count($orders) >= $this->max_per_execute){ |
143 | | - continue; |
144 | | - } |
145 | | - $pos1 = strpos($line_data, '<ORDERID>') + 9; |
146 | | - $pos2 = strpos($line_data, '</ORDERID>'); |
147 | | - if ($pos2 > $pos1){ |
148 | | - $tmp = substr($line_data, $pos1, $pos2-$pos1); |
149 | | - if (isset($order_ids[$tmp])){ |
150 | | - $orders[$tmp] = trim($line_data); |
151 | | - unset($order_ids[$tmp]); |
| 145 | + if (count($orders) < $this->max_per_execute){ |
| 146 | + $pos1 = strpos($line_data, '<ORDERID>') + 9; |
| 147 | + $pos2 = strpos($line_data, '</ORDERID>'); |
| 148 | + if ($pos2 > $pos1){ |
| 149 | + $tmp = substr($line_data, $pos1, $pos2-$pos1); |
| 150 | + if (isset($order_ids[$tmp])){ |
| 151 | + $orders[$tmp] = trim($line_data); |
| 152 | + unset($order_ids[$tmp]); |
| 153 | + } |
152 | 154 | } |
153 | 155 | } |
154 | 156 | } |