Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php |
— | — | @@ -29,29 +29,19 @@ |
30 | 30 | |
31 | 31 | $files = $this->getAllLogFileNames(); |
32 | 32 | foreach ($files as $file){ |
33 | | - $file_array = file($file, FILE_SKIP_EMPTY_LINES); |
| 33 | + $file_array = $this->getLogfileLines( $file ); |
34 | 34 | $payments = $this->findTransactionLines($file_array); |
35 | 35 | if (count($payments) === 0){ |
36 | 36 | $this->killfiles[] = $file; |
| 37 | + echo print_r($this->killfiles, true); |
37 | 38 | } |
38 | 39 | } |
39 | 40 | |
40 | 41 | $data = array( |
41 | | - 'wheeee' => 'yes' |
42 | | -// 'order_id' => '1052864192', |
43 | | -// 'i_order_id' => '1052864192', |
44 | | -// 'city' => '', |
45 | | -// 'state' => '', |
46 | | -// 'zip' => '', |
47 | | -// 'country' => 'US', |
48 | | -// 'email' => '', |
49 | | -// 'card_num' => '', |
50 | | - |
| 42 | + 'wheeee' => 'yes' |
51 | 43 | ); |
52 | 44 | |
53 | | - $class_name = 'GlobalCollectOrphanAdapter'; |
54 | | - |
55 | | - $adapter = new $class_name(array('external_data' => $data)); |
| 45 | + $adapter = new GlobalCollectOrphanAdapter(array('external_data' => $data)); |
56 | 46 | $adapter->setCurrentTransaction('INSERT_ORDERWITHPAYMENT'); |
57 | 47 | $var_map = $adapter->defineVarMap(); |
58 | 48 | |
— | — | @@ -62,23 +52,34 @@ |
63 | 53 | $parsed = $adapter->getResponseData($xml); |
64 | 54 | $payments[$key]['parsed'] = $parsed; |
65 | 55 | $payments[$key]['unstaged'] = $adapter->unstage_data($parsed); |
66 | | - $payments[$key]['unstaged']['contribution_tracking_id'] = $payments['contribution_tracking_id']; |
| 56 | + $payments[$key]['unstaged']['contribution_tracking_id'] = $payments[$key]['contribution_tracking_id']; |
67 | 57 | $payments[$key]['unstaged']['i_order_id'] = $payments[$key]['unstaged']['order_id']; |
68 | | - } |
69 | | - //setCurrentTransaction |
70 | | - //then load the XML into a DomDocument, and run getResponseData. |
| 58 | + $payments[$key]['unstaged']['card_num'] = ''; |
| 59 | + } |
71 | 60 | |
72 | | - echo print_r($payments, true); |
| 61 | + //foreach dealie we have data for... do it. |
| 62 | + //probably damage the constructor, and do all the regular business on a data load. |
| 63 | + die(); //Not actually letting this work for another round or so. |
| 64 | + //Note to Self: |
| 65 | + //Before you actually get rid of that die there and fire this thing off, make sure that: |
| 66 | + // * Your STOMP server is pointing to the real STOMP server |
| 67 | + // ...and the same with the queues. |
| 68 | + // * Your AVS/CVV rules make The Sense. |
| 69 | + // ADDITIONAL: log out what you did here, to... somewhere. |
| 70 | + // Preferably *before* you rewrite the Order ID file. |
73 | 71 | |
74 | | - //careful after this bit. |
75 | | - die(); |
76 | | - |
77 | | - |
78 | | - |
79 | 72 | //we may need to unset some hooks out here. Like... recaptcha. Makes no sense. |
80 | | - $adapter = new GlobalCollectAdapter(array('external_data' => $data)); |
81 | 73 | error_log("\n\n\n"); |
82 | | - $results = $adapter->do_transaction('Confirm_CreditCard'); |
| 74 | + foreach($payments as $payment_data){ |
| 75 | + $adapter->loadDataAndReInit($payment_data['unstaged']); |
| 76 | + $results = $adapter->do_transaction('Confirm_CreditCard'); |
| 77 | + if ($results['status'] == true){ |
| 78 | + echo "\nWe were supposed to " . $results['action'] . "\n"; |
| 79 | + } else { |
| 80 | + echo "\nProblem Happened! \n"; |
| 81 | + } |
| 82 | + echo $results['message'] . "\n"; |
| 83 | + } |
83 | 84 | |
84 | 85 | |
85 | 86 | //$this->rewriteOrderIds(); |
— | — | @@ -89,7 +90,7 @@ |
90 | 91 | $files = array(); |
91 | 92 | if ($handle = opendir(dirname(__FILE__) . '/orphanlogs/')){ |
92 | 93 | while ( ($file = readdir($handle)) !== false ){ |
93 | | - if (trim($file, '.') != '' && $file != 'order_ids.txt'){ |
| 94 | + if (trim($file, '.') != '' && $file != 'order_ids.txt' && $file != '.svn'){ |
94 | 95 | $files[] = dirname(__FILE__) . '/orphanlogs/' . $file; |
95 | 96 | } |
96 | 97 | } |
— | — | @@ -120,7 +121,6 @@ |
121 | 122 | $pos2 = strpos($line_data, '</ORDERID>'); |
122 | 123 | if ($pos2 > $pos1){ |
123 | 124 | $tmp = substr($line_data, $pos1, $pos2-$pos1); |
124 | | - echo "$tmp\n"; |
125 | 125 | if (isset($this->order_ids[$tmp])){ |
126 | 126 | $orders[$tmp] = trim($line_data); |
127 | 127 | unset($this->order_ids[$tmp]); |
— | — | @@ -164,6 +164,43 @@ |
165 | 165 | fclose($file); |
166 | 166 | } |
167 | 167 | |
| 168 | + function getLogfileLines( $file ){ |
| 169 | + $array = array(); //surprise! |
| 170 | + $array = file($file, FILE_SKIP_EMPTY_LINES); |
| 171 | + //now, check about 50 lines to make sure we're not seeing any of that #012, #015 crap. |
| 172 | + $checkcount = 50; |
| 173 | + if (count($array) < $checkcount){ |
| 174 | + $checkcount = count($array); |
| 175 | + } |
| 176 | + $convert = false; |
| 177 | + for ($i=0; $i<$checkcount; ++$i){ |
| 178 | + if( strpos($array[$i], '#012') || strpos($array[$i], '#015') ){ |
| 179 | + $convert = true; |
| 180 | + break; |
| 181 | + } |
| 182 | + } |
| 183 | + if ($convert) { |
| 184 | + $array2 = array(); |
| 185 | + foreach ($array as $line){ |
| 186 | + if (strpos($line, '#012')){ |
| 187 | + $line = str_replace('#012', "\n", $line); |
| 188 | + } |
| 189 | + if (strpos($line, '#015') ){ |
| 190 | + $line = str_replace('#015', "\r", $line); |
| 191 | + } |
| 192 | + $array2[] = $line; |
| 193 | + } |
| 194 | + $newfile = implode("\n", $array2); |
| 195 | + |
| 196 | + $handle = fopen($file, 'w'); |
| 197 | + fwrite($handle, $newfile); |
| 198 | + fclose($handle); |
| 199 | + $array = file($file, FILE_SKIP_EMPTY_LINES); |
| 200 | + } |
| 201 | + |
| 202 | + return $array; |
| 203 | + } |
| 204 | + |
168 | 205 | } |
169 | 206 | |
170 | 207 | $maintClass = "GlobalCollectOrphanRectifier"; |
Property changes on: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphanlogs |
___________________________________________________________________ |
Modified: svn:ignore |
171 | 208 | - order_ids.txt |
2011-11-11:17:59:48-globalcollect |
172 | 209 | + globalcollect.2 |
globalcollect.1 |
globalcollect |
globalcollect.6 |
globalcollect.5 |
globalcollect.4 |
2011-11-11:17:59:48-globalcollect |
order_ids.txt |
globalcollect.3 |
globalcollect.7 |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php |
— | — | @@ -25,4 +25,37 @@ |
26 | 26 | } |
27 | 27 | return $unstaged; |
28 | 28 | } |
| 29 | + |
| 30 | + public function loadDataAndReInit( $data ){ |
| 31 | + |
| 32 | + $this->dataObj = new DonationData( get_called_class(), false, $data ); |
| 33 | + |
| 34 | + $this->raw_data = $this->dataObj->getData(); |
| 35 | + |
| 36 | + //this would be VERY BAD anywhere else. |
| 37 | + $this->raw_data['order_id'] = $this->raw_data['i_order_id']; |
| 38 | + $this->staged_data = $this->raw_data; |
| 39 | + |
| 40 | + $this->transaction_results = array(); |
| 41 | + |
| 42 | + $this->setPostDefaults(); |
| 43 | + $this->defineTransactions(); |
| 44 | + $this->defineErrorMap(); |
| 45 | + $this->defineVarMap(); |
| 46 | + $this->defineDataConstraints(); |
| 47 | + $this->defineAccountInfo(); |
| 48 | + $this->defineReturnValueMap(); |
| 49 | + |
| 50 | + $this->stageData(); |
| 51 | + } |
| 52 | + |
| 53 | + public function addData($dataArray){ |
| 54 | + $order_id = $this->raw_data['i_order_id']; |
| 55 | + parent::addData($dataArray); |
| 56 | + $this->raw_data['order_id'] = $order_id; |
| 57 | + $this->raw_data['i_order_id'] = $order_id; |
| 58 | + $this->staged_data['order_id'] = $order_id; |
| 59 | + $this->staged_data['i_order_id'] = $order_id; |
| 60 | + } |
| 61 | + |
29 | 62 | } |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -1090,7 +1090,7 @@ |
1091 | 1091 | break; |
1092 | 1092 | } |
1093 | 1093 | } |
1094 | | - |
| 1094 | + |
1095 | 1095 | //if we got here with no problemflag, |
1096 | 1096 | //confirm or cancel the payment based on $cancelflag |
1097 | 1097 | if ( !$problemflag ){ |
— | — | @@ -1268,7 +1268,9 @@ |
1269 | 1269 | break; |
1270 | 1270 | case 'GET_ORDERSTATUS': |
1271 | 1271 | $data = $this->xmlChildrenToArray( $response, 'STATUS' ); |
1272 | | - $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) ); |
| 1272 | + if (isset($data['STATUSID'])){ |
| 1273 | + $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) ); |
| 1274 | + } |
1273 | 1275 | $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' ); |
1274 | 1276 | break; |
1275 | 1277 | } |