Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php |
— | — | @@ -1,15 +1,15 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
4 | | - exit( 1 ); |
5 | | -} |
| 3 | +//actually, as a maintenance script, this totally is a valid entry point. |
| 4 | + |
6 | 5 | //If you want to use this script, you will have to add the following line to LocalSettings.php: |
7 | 6 | //$wgAutoloadClasses['GlobalCollectOrphanAdapter'] = $IP . '/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php'; |
8 | 7 | |
9 | | -//TODO: Something that is not specific to anybody's install, here. |
10 | | -global $IP; |
11 | | -if ( !isset($IP) ) { |
12 | | - $IP = '../../../../'; |
| 8 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 9 | +if ( $IP === false ) { |
| 10 | + $IP = dirname( _FILE_ ) . '/../..'; |
13 | 11 | } |
| 12 | + |
| 13 | +//If you get errors on this next line, set (and export) your MW_INSTALL_PATH var. |
14 | 14 | require_once( "$IP/maintenance/Maintenance.php" ); |
15 | 15 | |
16 | 16 | class GlobalCollectOrphanRectifier extends Maintenance { |
— | — | @@ -20,7 +20,6 @@ |
21 | 21 | protected $target_execute_time = 30; //(seconds) - only used by the stomp option. |
22 | 22 | protected $adapter; |
23 | 23 | |
24 | | - |
25 | 24 | function execute(){ |
26 | 25 | $func = 'parse_files'; |
27 | 26 | if ( !empty( $_SERVER['argv'][1] ) ){ |
— | — | @@ -49,7 +48,7 @@ |
50 | 49 | } |
51 | 50 | |
52 | 51 | function orphan_stomp(){ |
53 | | - |
| 52 | + echo "Orphan Stomp\n"; |
54 | 53 | $this->removed_message_count = 0; |
55 | 54 | $this->now = time(); //time at start, thanks very much. |
56 | 55 | |
— | — | @@ -99,8 +98,17 @@ |
100 | 99 | break; |
101 | 100 | } |
102 | 101 | } |
103 | | - echo "\nDone! Final results: \n $am destroyed via antimessage \n $rec rectified orphans \n $err errored out\n"; |
| 102 | + $final = "\nDone! Final results: \n"; |
| 103 | + $final .= " $am destroyed via antimessage \n"; |
| 104 | + $final .= " $rec rectified orphans \n"; |
| 105 | + $final .= " $err errored out \n"; |
| 106 | + if ( isset( $this->adapter->orphanstats ) ){ |
| 107 | + foreach ( $this->adapter->orphanstats as $status => $count ) { |
| 108 | + $final .= " Status $status = $count\n"; |
| 109 | + } |
| 110 | + } |
104 | 111 | |
| 112 | + echo $final; |
105 | 113 | } |
106 | 114 | |
107 | 115 | function keepGoing(){ |
— | — | @@ -118,20 +126,19 @@ |
119 | 127 | if ( $correlation_id ) { |
120 | 128 | $bucket[$correlation_id] = "'$correlation_id'"; //avoiding duplicates. |
121 | 129 | $this->handled_ids[$correlation_id] = 'antimessage'; |
122 | | - echo "Added $correlation_id to the ack bucket : Total bucket count = " . count( $bucket ); |
123 | 130 | } |
124 | 131 | if ( count( $bucket ) && ( count( $bucket ) >= $count || $ackNow ) ){ |
125 | 132 | //ack now. |
126 | | - echo 'Acking ' . count( $bucket ) . ' bucket messages.'; |
| 133 | + echo 'Acking ' . count( $bucket ) . " bucket messages.\n"; |
127 | 134 | $selector = 'JMSCorrelationID IN (' . implode( ", ", $bucket ) . ')'; |
128 | 135 | $ackMe = stompFetchMessages( 'cc-limbo', $selector, $count * 100 ); //This is outrageously high, but I just want to be reasonably sure we get all the matches. |
129 | 136 | $retrieved_count = count( $ackMe ); |
130 | 137 | if ( $retrieved_count ){ |
131 | 138 | stompAckMessages( $ackMe ); |
132 | 139 | $this->removed_message_count += $retrieved_count; |
133 | | - echo "Done acking $retrieved_count messages. "; |
| 140 | + echo "Done acking $retrieved_count messages. \n"; |
134 | 141 | } else { |
135 | | - echo "Oh noes! No messages to ack for some reason..."; |
| 142 | + echo "Oh noes! No messages retrieved for $selector...\n"; |
136 | 143 | } |
137 | 144 | $bucket = array(); |
138 | 145 | } |
— | — | @@ -149,7 +156,7 @@ |
150 | 157 | if (array_key_exists('correlation-id', $message->headers)) { |
151 | 158 | $this->addStompCorrelationIDToAckBucket( $message->headers['correlation-id'] ); |
152 | 159 | } else { |
153 | | - echo 'The STOMP message ' . $message->headers['message-id'] . ' has no correlation ID!'; |
| 160 | + echo 'The STOMP message ' . $message->headers['message-id'] . " has no correlation ID!\n"; |
154 | 161 | } |
155 | 162 | } |
156 | 163 | $antimessages = stompFetchMessages( 'cc-limbo', $selector, 1000 ); |
— | — | @@ -181,8 +188,10 @@ |
182 | 189 | $order_id = $order_id[1]; |
183 | 190 | $decoded['order_id'] = $order_id; |
184 | 191 | $decoded['i_order_id'] = $order_id; |
| 192 | + $decoded = unCreateQueueMessage($decoded); |
| 193 | + $decoded['card_num'] = ''; |
185 | 194 | $orphans[$correlation_id] = $decoded; |
186 | | - echo "\nFound an orphan! $correlation_id"; |
| 195 | + echo "Found an orphan! $correlation_id \n"; |
187 | 196 | } |
188 | 197 | } |
189 | 198 | } |
— | — | @@ -200,7 +209,7 @@ |
201 | 210 | $this->order_ids[$id] = $id; //easier to unset this way. |
202 | 211 | } |
203 | 212 | $outstanding_count = count( $this->order_ids ); |
204 | | - echo "Order ID count: " . $outstanding_count . "\n"; |
| 213 | + echo "Order ID count: $outstanding_count \n"; |
205 | 214 | |
206 | 215 | $files = $this->getAllLogFileNames(); |
207 | 216 | $payments = array(); |
— | — | @@ -277,7 +286,7 @@ |
278 | 287 | * @return boolean True if the orphan has been rectified, false if not. |
279 | 288 | */ |
280 | 289 | function rectifyOrphan( $data, $query_contribution_tracking = true ){ |
281 | | - echo "\nRectifying Orphan " . $data['order_id']; |
| 290 | + echo 'Rectifying Orphan ' . $data['order_id'] . "\n"; |
282 | 291 | $rectified = false; |
283 | 292 | |
284 | 293 | $this->adapter->loadDataAndReInit( $data, $query_contribution_tracking ); |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | $msg .= "$key = $val "; |
158 | 158 | } |
159 | 159 | $this->log( "$ctid: Found UTM Data. $msg" ); |
160 | | - echo $msg; |
| 160 | + echo "$msg\n"; |
161 | 161 | return $data; |
162 | 162 | } |
163 | 163 | } |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -1123,8 +1123,9 @@ |
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | } |
1127 | | - |
| 1127 | + $gotCVV = false; |
1128 | 1128 | if ( count( $addme ) ){ |
| 1129 | + $gotCVV = true; |
1129 | 1130 | $this->addData( $addme ); |
1130 | 1131 | $this->staged_data['order_id'] = $this->staged_data['i_order_id']; |
1131 | 1132 | $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': '; |
— | — | @@ -1133,10 +1134,7 @@ |
1134 | 1135 | self::log( $logmsg ); |
1135 | 1136 | $this->runPreProcessHooks(); |
1136 | 1137 | $status_result['action'] = $this->getValidationAction(); |
1137 | | - } else { |
1138 | | - $problemflag = true; //nothing to be done. |
1139 | | - $problemmessage = "Unable to retrieve orphan cvv/avs results (Communication problem?)."; |
1140 | | - } |
| 1138 | + } |
1141 | 1139 | } |
1142 | 1140 | |
1143 | 1141 | //we filtered |
— | — | @@ -1152,6 +1150,20 @@ |
1153 | 1151 | $order_status_results = $this->getTransactionWMFStatus(); |
1154 | 1152 | $txn_data = $this->getTransactionData(); |
1155 | 1153 | $original_status_code = isset( $txn_data['STATUSID']) ? $txn_data['STATUSID'] : 'NOT SET'; |
| 1154 | + if ( $is_orphan ){ |
| 1155 | + //save stats. |
| 1156 | + if (!isset($this->orphanstats) || !isset( $this->orphanstats[$original_status_code] ) ){ |
| 1157 | + $this->orphanstats[$original_status_code] = 0; |
| 1158 | + } else { |
| 1159 | + $this->orphanstats[$original_status_code] += 1; |
| 1160 | + } |
| 1161 | + |
| 1162 | + if ( $original_status_code > 70 && !$gotCVV ){ |
| 1163 | + $problemflag = true; |
| 1164 | + $problemmessage = "Unable to retrieve orphan cvv/avs results (Communication problem?)."; |
| 1165 | + } |
| 1166 | + |
| 1167 | + } |
1156 | 1168 | if (!$order_status_results){ |
1157 | 1169 | $problemflag = true; |
1158 | 1170 | $problemmessage = "We don't have a Transaction WMF Status after doing a GET_ORDERSTATUS."; |
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -188,7 +188,7 @@ |
189 | 189 | */ |
190 | 190 | function createQueueMessage( $transaction ) { |
191 | 191 | // specifically designed to match the CiviCRM API that will handle it |
192 | | - // edit this array to include/ignore transaction data sent to the server |
| 192 | + // edit this array to include/ignore transaction data sent to the server |
193 | 193 | $message = array( |
194 | 194 | 'contribution_tracking_id' => $transaction['contribution_tracking_id'], |
195 | 195 | 'optout' => $transaction['optout'], |
— | — | @@ -236,6 +236,42 @@ |
237 | 237 | return $message; |
238 | 238 | } |
239 | 239 | |
| 240 | + |
| 241 | +function unCreateQueueMessage( $transaction ) { |
| 242 | + // For now, this function assumes that we have a complete queue message. |
| 243 | + // TODO: Something more robust and programmatic, as time allows. This whole file is just terrible. |
| 244 | + |
| 245 | + $rekey = array( |
| 246 | + 'first_name' => 'fname', |
| 247 | + 'middle_name' => 'mname', |
| 248 | + 'last_name' => 'lname', |
| 249 | + 'street_address' => 'street', |
| 250 | + 'state_province' => 'state', |
| 251 | + 'postal_code' => 'zip', |
| 252 | + 'first_name_2' => 'fname2', |
| 253 | + 'last_name_2' => 'lname2', |
| 254 | + 'street_address_2' => 'street2', |
| 255 | + 'city_2' => 'city2', |
| 256 | + 'state_province_2' => 'state2', |
| 257 | + 'postal_code_2' => 'zip2', |
| 258 | +// 'currency' => 'currency_code', |
| 259 | + 'original_currency' => 'currency_code', |
| 260 | + 'original_gross' => 'amount', |
| 261 | +// 'gross' => 'amount', |
| 262 | +// 'net' => 'amount', |
| 263 | + ); |
| 264 | + |
| 265 | + foreach ( $rekey as $stomp => $di ){ |
| 266 | + if ( isset( $transaction[$stomp] ) ){ |
| 267 | + $transaction[$di] = $transaction[$stomp]; |
| 268 | + unset($transaction[$stomp]); |
| 269 | + }; |
| 270 | + } |
| 271 | + |
| 272 | + return $transaction; |
| 273 | +} |
| 274 | + |
| 275 | + |
240 | 276 | /** |
241 | 277 | * Fetches all the messages in a queue that match the supplies selector. |
242 | 278 | * Limiting to a completely arbitrary 50, just in case something goes amiss somewhere. |