Index: trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php |
— | — | @@ -41,7 +41,6 @@ |
42 | 42 | $this->risk_score = 0; |
43 | 43 | if ( $this->risk_score > 100 ) |
44 | 44 | $this->risk_score = 100; |
45 | | -// error_log("Risk score: " . $this->risk_score ); |
46 | 45 | foreach ( $this->action_ranges as $action => $range ) { |
47 | 46 | if ( $this->risk_score >= $range[0] && $this->risk_score <= $range[1] ) { |
48 | 47 | return $action; |
— | — | @@ -73,7 +72,7 @@ |
74 | 73 | } |
75 | 74 | |
76 | 75 | static function singleton( &$gateway_adapter ) { |
77 | | - if ( !self::$instance ) { |
| 76 | + if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) { |
78 | 77 | self::$instance = new self( $gateway_adapter ); |
79 | 78 | } |
80 | 79 | return self::$instance; |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | } |
58 | 58 | |
59 | 59 | static function singleton( &$gateway_adapter, &$custom_filter_object ) { |
60 | | - if ( !self::$instance ) { |
| 60 | + if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) { |
61 | 61 | self::$instance = new self( $gateway_adapter, $custom_filter_object ); |
62 | 62 | } |
63 | 63 | return self::$instance; |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | } |
39 | 39 | |
40 | 40 | static function singleton( &$gateway_adapter ) { |
41 | | - if ( !self::$instance ) { |
| 41 | + if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) { |
42 | 42 | self::$instance = new self( $gateway_adapter ); |
43 | 43 | } |
44 | 44 | return self::$instance; |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | static function singleton( &$gateway_adapter, &$custom_filter_object ) { |
58 | | - if ( !self::$instance ) { |
| 58 | + if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) { |
59 | 59 | self::$instance = new self( $gateway_adapter, $custom_filter_object ); |
60 | 60 | } |
61 | 61 | return self::$instance; |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | } |
58 | 58 | |
59 | 59 | static function singleton( &$gateway_adapter, &$custom_filter_object ) { |
60 | | - if ( !self::$instance ) { |
| 60 | + if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) { |
61 | 61 | self::$instance = new self( $gateway_adapter, $custom_filter_object ); |
62 | 62 | } |
63 | 63 | return self::$instance; |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php |
— | — | @@ -25,7 +25,8 @@ |
26 | 26 | foreach ($order_ids as $id){ |
27 | 27 | $this->order_ids[$id] = $id; //easier to unset this way. |
28 | 28 | } |
29 | | - echo "Order ID count: " . count($this->order_ids) . "\n"; |
| 29 | + $outstanding_count = count($this->order_ids); |
| 30 | + echo "Order ID count: " . $outstanding_count . "\n"; |
30 | 31 | |
31 | 32 | $files = $this->getAllLogFileNames(); |
32 | 33 | foreach ($files as $file){ |
— | — | @@ -56,34 +57,26 @@ |
57 | 58 | $payments[$key]['unstaged']['i_order_id'] = $payments[$key]['unstaged']['order_id']; |
58 | 59 | $payments[$key]['unstaged']['card_num'] = ''; |
59 | 60 | } |
60 | | - |
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. |
| 61 | + |
69 | 62 | // ADDITIONAL: log out what you did here, to... somewhere. |
70 | 63 | // Preferably *before* you rewrite the Order ID file. |
71 | 64 | |
72 | 65 | //we may need to unset some hooks out here. Like... recaptcha. Makes no sense. |
73 | | - error_log("\n\n\n"); |
74 | 66 | foreach($payments as $payment_data){ |
75 | 67 | $adapter->loadDataAndReInit($payment_data['unstaged']); |
76 | 68 | $results = $adapter->do_transaction('Confirm_CreditCard'); |
77 | 69 | if ($results['status'] == true){ |
78 | | - echo "\nWe were supposed to " . $results['action'] . "\n"; |
| 70 | + $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": FINAL: " . $results['action']); |
| 71 | + unset($this->order_ids[$payments[$key]['unstaged']['order_id']]); |
79 | 72 | } else { |
80 | | - echo "\nProblem Happened! \n"; |
| 73 | + $adapter->log( $payment_data['unstaged']['contribution_tracking_id'] . ": ERROR: " . $results['message']); |
81 | 74 | } |
82 | 75 | echo $results['message'] . "\n"; |
83 | 76 | } |
84 | 77 | |
85 | | - |
86 | | - //$this->rewriteOrderIds(); |
87 | | - //and don't forget to kill the logs we don't care about anymore. |
| 78 | + if ($outstanding_count != count($this->order_ids)){ |
| 79 | + $this->rewriteOrderIds(); |
| 80 | + } |
88 | 81 | } |
89 | 82 | |
90 | 83 | function getAllLogFileNames(){ |
— | — | @@ -113,6 +106,7 @@ |
114 | 107 | } |
115 | 108 | } |
116 | 109 | |
| 110 | + $order_ids = $this->order_ids; |
117 | 111 | foreach ($lines as $line_no=>$line_data){ |
118 | 112 | if (count($orders) >= $this->max_per_execute){ |
119 | 113 | continue; |
— | — | @@ -121,9 +115,9 @@ |
122 | 116 | $pos2 = strpos($line_data, '</ORDERID>'); |
123 | 117 | if ($pos2 > $pos1){ |
124 | 118 | $tmp = substr($line_data, $pos1, $pos2-$pos1); |
125 | | - if (isset($this->order_ids[$tmp])){ |
| 119 | + if (isset($order_ids[$tmp])){ |
126 | 120 | $orders[$tmp] = trim($line_data); |
127 | | - unset($this->order_ids[$tmp]); |
| 121 | + unset($order_ids[$tmp]); |
128 | 122 | } |
129 | 123 | } |
130 | 124 | } |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class GlobalCollectOrphanAdapter extends GlobalCollectAdapter { |
| 5 | + |
5 | 6 | public function unstage_data( $data = array(), $final = true ){ |
6 | 7 | $unstaged = array(); |
7 | 8 | foreach ( $data as $key=>$val ){ |
— | — | @@ -27,7 +28,8 @@ |
28 | 29 | } |
29 | 30 | |
30 | 31 | public function loadDataAndReInit( $data ){ |
31 | | - |
| 32 | + $this->batch = true; //or the hooks will accumulate badness. |
| 33 | + |
32 | 34 | $this->dataObj = new DonationData( get_called_class(), false, $data ); |
33 | 35 | |
34 | 36 | $this->raw_data = $this->dataObj->getData(); |
— | — | @@ -58,4 +60,33 @@ |
59 | 61 | $this->staged_data['i_order_id'] = $order_id; |
60 | 62 | } |
61 | 63 | |
| 64 | + public function do_transaction($transaction){ |
| 65 | + switch ($transaction){ |
| 66 | + case 'SET_PAYMENT': |
| 67 | + case 'CANCEL_PAYMENT': |
| 68 | + self::log($this->getData_Raw('contribution_tracking_id') . ": CVV: " . $this->getData_Raw('cvv_result') . ": AVS: " . $this->getData_Raw('avs_result')); |
| 69 | + //and then go on, unless you're testing, in which case: |
| 70 | + //return "NOPE"; |
| 71 | + //break; |
| 72 | + default: |
| 73 | + return parent::do_transaction($transaction); |
| 74 | + break; |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + public static function log( $msg, $log_level = LOG_INFO, $nothing = null ) { |
| 79 | + $identifier = 'orphans:' . self::getIdentifier() . "_gateway_trxn"; |
| 80 | + |
| 81 | + // if we're not using the syslog facility, use wfDebugLog |
| 82 | + if ( !self::getGlobal( 'UseSyslog' ) ) { |
| 83 | + wfDebugLog( $identifier, $msg ); |
| 84 | + return; |
| 85 | + } |
| 86 | + |
| 87 | + // otherwise, use syslogging |
| 88 | + openlog( $identifier, LOG_ODELAY, LOG_SYSLOG ); |
| 89 | + syslog( $log_level, $msg ); |
| 90 | + closelog(); |
| 91 | + } |
| 92 | + |
62 | 93 | } |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -173,6 +173,7 @@ |
174 | 174 | protected $current_transaction; |
175 | 175 | protected $action; |
176 | 176 | public $debugarray; |
| 177 | + protected $batch = false; |
177 | 178 | |
178 | 179 | //ALL OF THESE need to be redefined in the children. Much voodoo depends on the accuracy of these constants. |
179 | 180 | const GATEWAY_NAME = 'Donation Gateway'; |
— | — | @@ -1989,5 +1990,18 @@ |
1990 | 1991 | public function hasDonorDataInSession( $key = false, $value= '' ){ |
1991 | 1992 | return $this->dataObj->hasDonorDataInSession( $key, $value ); |
1992 | 1993 | } |
| 1994 | + |
| 1995 | + /** |
| 1996 | + * Lets the outside world (particularly hooks that accumulate points scores) |
| 1997 | + * know if we are a batch processor. |
| 1998 | + * @return type |
| 1999 | + */ |
| 2000 | + public function isBatchProcessor(){ |
| 2001 | + if (!property_exists($this, 'batch')){ |
| 2002 | + return false; |
| 2003 | + } else { |
| 2004 | + return $this->batch; |
| 2005 | + } |
| 2006 | + } |
1993 | 2007 | |
1994 | 2008 | } |
\ No newline at end of file |