Index: branches/fundraising/deployment/payments_1.17/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; |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
81 | 80 | Merged /trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php:r103024,103076,103246,103288,103385,103416,103491,103499,103501,103506 |
Index: branches/fundraising/deployment/payments_1.17/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: branches/fundraising/deployment/payments_1.17/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: branches/fundraising/deployment/payments_1.17/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: branches/fundraising/deployment/payments_1.17/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: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | public function can_bypass_minfraud() { |
114 | 114 | // if the data bits data_hash and action are not set, we need to hit minFraud |
115 | 115 | $localdata = $this->gateway_adapter->getData_Raw(); |
116 | | - if ( !strlen( $localdata['data_hash'] ) || !strlen( $localdata['action'] ) ) { |
| 116 | + if ( !isset($localdata['data_hash']) || !strlen( $localdata['data_hash'] ) || !isset($localdata['action']) || !strlen( $localdata['action'] ) ) { |
117 | 117 | return FALSE; |
118 | 118 | } |
119 | 119 | |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras |
___________________________________________________________________ |
Modified: svn:mergeinfo |
120 | 120 | Merged /trunk/extensions/DonationInterface/extras:r103024,103076,103246,103288,103385,103416,103491,103499,103501,103506 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -976,22 +976,50 @@ |
977 | 977 | $addme[$ourkey] = $tmp; |
978 | 978 | } |
979 | 979 | } |
980 | | - if ( count( $addme ) ){ |
| 980 | + |
| 981 | + $post_status_check = false; |
| 982 | + if ( count( $addme ) ){ //nothing unusual here. |
981 | 983 | $this->addData( $addme ); |
| 984 | + $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': '; |
| 985 | + $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' ); |
| 986 | + $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' ); |
| 987 | + self::log( $logmsg ); |
| 988 | + } else { //this is an orphan transaction. |
| 989 | + $this->staged_data['order_id'] = $this->staged_data['i_order_id']; |
| 990 | + $post_status_check = true; |
982 | 991 | } |
983 | | - $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': '; |
984 | | - $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' ); |
985 | | - $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' ); |
986 | | - self::log( $logmsg ); |
987 | 992 | |
988 | 993 | $status_result = $this->do_transaction( 'GET_ORDERSTATUS' ); |
989 | 994 | |
990 | | - //error_log( "GET_ORDERSTATUS result: " . $status_result ); |
991 | | - |
992 | 995 | $cancelflag = false; //this will denote the thing we're trying to do with the donation attempt |
993 | 996 | $problemflag = false; //this will get set to true, if we can't continue and need to give up and just log the hell out of it. |
994 | 997 | $problemmessage = ''; //to be used in conjunction with the flag. |
| 998 | + |
995 | 999 | |
| 1000 | + if ( $post_status_check ){ |
| 1001 | + if ( array_key_exists('data', $status_result) ) { |
| 1002 | + foreach ( $pull_vars as $theirkey => $ourkey) { |
| 1003 | + if ( array_key_exists($theirkey, $status_result['data']) ) { |
| 1004 | + $addme[$ourkey] = $status_result['data'][$theirkey]; |
| 1005 | + } |
| 1006 | + } |
| 1007 | + } |
| 1008 | + |
| 1009 | + if ( count( $addme ) ){ |
| 1010 | + $this->addData( $addme ); |
| 1011 | + $this->staged_data['order_id'] = $this->staged_data['i_order_id']; |
| 1012 | + $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': '; |
| 1013 | + $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' ); |
| 1014 | + $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' ); |
| 1015 | + self::log( $logmsg ); |
| 1016 | + $this->runPreProcessHooks(); |
| 1017 | + $status_result['action'] = $this->getValidationAction(); |
| 1018 | + } else { |
| 1019 | + $problemflag = true; //nothing to be done. |
| 1020 | + $problemmessage = "Unable to retrieve orphan cvv/avs results (Communication problem?)."; |
| 1021 | + } |
| 1022 | + } |
| 1023 | + |
996 | 1024 | //we filtered |
997 | 1025 | if ( array_key_exists( 'action', $status_result ) && $status_result['action'] != 'process' ){ |
998 | 1026 | $cancelflag = true; |
— | — | @@ -1014,9 +1042,13 @@ |
1015 | 1043 | case 'revised' : |
1016 | 1044 | $cancelflag = true; //makes sure we don't try to confirm. |
1017 | 1045 | break; |
1018 | | - } |
| 1046 | + case 'complete' : |
| 1047 | + $problemflag = true; //nothing to be done. |
| 1048 | + $problemmessage = "GET_ORDERSTATUS reports that the payment is already complete."; |
| 1049 | + break; |
| 1050 | + } |
1019 | 1051 | } |
1020 | | - |
| 1052 | + |
1021 | 1053 | //if we got here with no problemflag, |
1022 | 1054 | //confirm or cancel the payment based on $cancelflag |
1023 | 1055 | if ( !$problemflag ){ |
— | — | @@ -1194,7 +1226,9 @@ |
1195 | 1227 | break; |
1196 | 1228 | case 'GET_ORDERSTATUS': |
1197 | 1229 | $data = $this->xmlChildrenToArray( $response, 'STATUS' ); |
1198 | | - $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) ); |
| 1230 | + if (isset($data['STATUSID'])){ |
| 1231 | + $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) ); |
| 1232 | + } |
1199 | 1233 | $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' ); |
1200 | 1234 | break; |
1201 | 1235 | } |
— | — | @@ -1548,23 +1582,34 @@ |
1549 | 1583 | protected function stage_language( $type = 'request' ) { |
1550 | 1584 | $language = strtolower( $this->staged_data['language'] ); |
1551 | 1585 | |
1552 | | - $count = 0; |
1553 | | - //Count's just there making sure we don't get stuck here. |
1554 | | - while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){ |
1555 | | - // Get the fallback language |
1556 | | - $language = Language::getFallbackFor( $language ); |
1557 | | - $count += 1; |
| 1586 | + switch ( $type ) { |
| 1587 | + case 'request': |
| 1588 | + $count = 0; |
| 1589 | + //Count's just there making sure we don't get stuck here. |
| 1590 | + while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){ |
| 1591 | + // Get the fallback language |
| 1592 | + $language = Language::getFallbackFor( $language ); |
| 1593 | + $count += 1; |
| 1594 | + } |
| 1595 | + |
| 1596 | + if ( !in_array( $language, $this->getAvailableLanguages() ) ){ |
| 1597 | + $language = 'en'; |
| 1598 | + } |
| 1599 | + |
| 1600 | + if ( $language === 'zh' ) { //Handles GC's mutant Chinese code. |
| 1601 | + $language = 'sc'; |
| 1602 | + } |
| 1603 | + |
| 1604 | + break; |
| 1605 | + case 'response': |
| 1606 | + if ( $language === 'sc' ){ |
| 1607 | + $language = 'zh'; |
| 1608 | + } |
| 1609 | + break; |
1558 | 1610 | } |
1559 | 1611 | |
1560 | | - if ( !in_array( $language, $this->getAvailableLanguages() ) ){ |
1561 | | - $language = 'en'; |
1562 | | - } |
1563 | | - |
1564 | | - if ( $language === 'zh' ) { //Handles GC's mutant Chinese code. |
1565 | | - $language = 'sc'; |
1566 | | - } |
1567 | | - |
1568 | 1612 | $this->staged_data['language'] = $language; |
| 1613 | + |
1569 | 1614 | } |
1570 | 1615 | |
1571 | 1616 | /** |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -162,6 +162,7 @@ |
163 | 163 | protected $current_transaction; |
164 | 164 | protected $action; |
165 | 165 | public $debugarray; |
| 166 | + protected $batch = false; |
166 | 167 | |
167 | 168 | //ALL OF THESE need to be redefined in the children. Much voodoo depends on the accuracy of these constants. |
168 | 169 | const GATEWAY_NAME = 'Donation Gateway'; |
— | — | @@ -194,24 +195,26 @@ |
195 | 196 | extract( $options ); |
196 | 197 | |
197 | 198 | $testData = isset( $testData ) ? $testData : false; |
| 199 | + $external_data = isset( $external_data ) ? $external_data : false; //not test data: Regular type. |
198 | 200 | $postDefaults = isset( $postDefaults ) ? $postDefaults : false; |
199 | | - |
| 201 | + |
200 | 202 | if ( !self::getGlobal( 'Test' ) ) { |
201 | 203 | $this->url = self::getGlobal( 'URL' ); |
202 | | - |
203 | 204 | // Only submit test data if we are in test mode. |
204 | | - $testData = false; |
205 | 205 | } else { |
206 | 206 | $this->url = self::getGlobal( 'TestingURL' ); |
| 207 | + if ( $testData ){ |
| 208 | + $external_data = $testData; |
| 209 | + } |
207 | 210 | } |
| 211 | + |
| 212 | + $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $external_data ); |
208 | 213 | |
209 | | - $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $testData ); |
210 | | - |
211 | 214 | $this->raw_data = $this->dataObj->getData(); |
212 | 215 | $this->staged_data = $this->raw_data; |
| 216 | + |
| 217 | + $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) ); |
213 | 218 | |
214 | | - $this->posted = ( $wgRequest->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) ); |
215 | | - |
216 | 219 | $this->setPostDefaults( $postDefaults ); |
217 | 220 | $this->defineTransactions(); |
218 | 221 | $this->defineErrorMap(); |
— | — | @@ -1653,7 +1656,7 @@ |
1654 | 1657 | * @return mixed Transaction results status, or false if not set. |
1655 | 1658 | */ |
1656 | 1659 | public function getTransactionStatus() { |
1657 | | - if ( array_key_exists( 'status', $this->transaction_results ) ) { |
| 1660 | + if ( is_array( $this->transaction_results ) && array_key_exists( 'status', $this->transaction_results ) ) { |
1658 | 1661 | return $this->transaction_results['status']; |
1659 | 1662 | } else { |
1660 | 1663 | return false; |
— | — | @@ -1973,5 +1976,18 @@ |
1974 | 1977 | public function hasDonorDataInSession( $key = false, $value= '' ){ |
1975 | 1978 | return $this->dataObj->hasDonorDataInSession( $key, $value ); |
1976 | 1979 | } |
| 1980 | + |
| 1981 | + /** |
| 1982 | + * Lets the outside world (particularly hooks that accumulate points scores) |
| 1983 | + * know if we are a batch processor. |
| 1984 | + * @return type |
| 1985 | + */ |
| 1986 | + public function isBatchProcessor(){ |
| 1987 | + if (!property_exists($this, 'batch')){ |
| 1988 | + return false; |
| 1989 | + } else { |
| 1990 | + return $this->batch; |
| 1991 | + } |
| 1992 | + } |
1977 | 1993 | |
1978 | 1994 | } |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | 'iban' => $wgRequest->getText( 'iban', null ), |
103 | 103 | 'transaction_type' => $wgRequest->getText( 'transaction_type', null ), |
104 | 104 | ); |
105 | | - if ( !$wgRequest->wasPosted() ) { |
| 105 | + if ( !$this->wasPosted() ) { |
106 | 106 | $this->setVal( 'posted', false ); |
107 | 107 | } |
108 | 108 | } |
— | — | @@ -1004,6 +1004,23 @@ |
1005 | 1005 | ); |
1006 | 1006 | return $stomp_fields; |
1007 | 1007 | } |
| 1008 | + |
| 1009 | + /** |
| 1010 | + * Basically, this is a wrapper for the $wgRequest wasPosted function that |
| 1011 | + * won't give us notices if we weren't even a web request. |
| 1012 | + * I realize this is pretty lame. |
| 1013 | + * Notices, however, are more lame. |
| 1014 | + * @global type $wgRequest |
| 1015 | + * @staticvar string $posted Keeps track so we don't have to figure it out twice. |
| 1016 | + */ |
| 1017 | + public function wasPosted(){ |
| 1018 | + global $wgRequest; |
| 1019 | + static $posted = null; |
| 1020 | + if ($posted === null){ |
| 1021 | + $posted = (array_key_exists('REQUEST_METHOD', $_SERVER) && $wgRequest->wasPosted()); |
| 1022 | + } |
| 1023 | + return $posted; |
| 1024 | + } |
1008 | 1025 | } |
1009 | 1026 | |
1010 | 1027 | ?> |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1011 | 1028 | Merged /trunk/extensions/DonationInterface/gateway_common/DonationData.php:r103024,103076,103246,103288,103385,103416,103491,103499,103501,103506 |