Index: branches/fundraising/extensions/DonationInterface/donationinterface.php |
— | — | @@ -20,10 +20,19 @@ |
21 | 21 | |
22 | 22 | $donationinterface_dir = dirname( __FILE__ ) . '/'; |
23 | 23 | |
| 24 | +//TODO: It may be a good idea to make all these stop behaving like they're independent extensions. |
| 25 | +//Better yet, we should decide if they're a required part of this or not, |
| 26 | +//and split 'em entirely off, or roll 'em all the way in to this file. |
24 | 27 | require_once( $donationinterface_dir . 'donate_interface/donate_interface.php' ); |
25 | 28 | require_once( $donationinterface_dir . 'activemq_stomp/activemq_stomp.php' ); |
26 | 29 | |
| 30 | +require_once( $donationinterface_dir . 'extras/extras.php' ); |
| 31 | +require_once( $donationinterface_dir . 'extras/custom_filters/custom_filters.php' ); |
| 32 | +require_once( $donationinterface_dir . 'extras/conversion_log/conversion_log.php' ); |
| 33 | +require_once( $donationinterface_dir . 'extras/minfraud/minfraud.php' ); |
| 34 | +require_once( $donationinterface_dir . 'extras/recaptcha/recaptcha.php' ); |
27 | 35 | |
| 36 | + |
28 | 37 | /** |
29 | 38 | * Global form dir and whitelist |
30 | 39 | */ |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -70,41 +70,16 @@ |
71 | 71 | if ( $form_errors ) { |
72 | 72 | $this->displayForm( $data, $this->errors ); |
73 | 73 | } else { // The submitted form data is valid, so process it |
74 | | - // allow any external validators to have their way with the data |
75 | | - self::log( $data['order_id'] . " Preparing to query MaxMind" ); |
76 | | - wfRunHooks( 'GatewayValidate', array( &$this->adapter ) ); |
77 | | - self::log( $data['order_id'] . ' Finished querying Maxmind' ); |
| 74 | + $result = $this->adapter->do_transaction( 'Card' ); |
78 | 75 | |
79 | | - // if the transaction was flagged for review |
80 | | - if ( $this->action == 'review' ) { |
81 | | - // expose a hook for external handling of trxns flagged for review |
82 | | - wfRunHooks( 'GatewayReview', array( &$this->adapter ) ); |
83 | | - } |
84 | | - |
85 | | - // if the transaction was flagged to be 'challenged' |
86 | | - if ( $this->action == 'challenge' ) { |
87 | | - // expose a hook for external handling of trxns flagged for challenge (eg captcha) |
88 | | - wfRunHooks( 'GatewayChallenge', array( &$this->adapter ) ); |
89 | | - } |
90 | | - |
91 | 76 | // if the transaction was flagged for rejection |
92 | | - if ( $this->action == 'reject' ) { |
93 | | - // expose a hook for external handling of trxns flagged for rejection |
94 | | - wfRunHooks( 'GatewayReject', array( &$this->adapter ) ); |
95 | | - |
| 77 | + if ( $this->adapter->action == 'reject' ) { |
96 | 78 | $this->fnPayflowDisplayDeclinedResults( '' ); |
97 | | - $this->fnPayflowUnsetEditToken(); |
98 | 79 | } |
99 | 80 | |
100 | | - // if the transaction was flagged for processing |
101 | | - if ( $this->action == 'process' ) { |
102 | | - // expose a hook for external handling of trxns ready for processing |
103 | | - wfRunHooks( 'GatewayProcess', array( &$this->adapter ) ); |
104 | | - $this->fnPayflowProcessTransaction( $data, $payflow_data ); |
| 81 | + if ( $this->adapter->action == 'process' ) { |
| 82 | + $this->fnPayflowDisplayResults( $result ); |
105 | 83 | } |
106 | | - |
107 | | - // expose a hook for any post processing |
108 | | - wfRunHooks( 'GatewayPostProcess', array( &$this->adapter ) ); |
109 | 84 | } |
110 | 85 | } else { |
111 | 86 | // Display form for the first time |
— | — | @@ -120,114 +95,6 @@ |
121 | 96 | } |
122 | 97 | |
123 | 98 | /** |
124 | | - * Sends a name-value pair string to Payflow gateway |
125 | | - * |
126 | | - * @param $data Array: array of user input |
127 | | - * @param $payflow_data Array: array of necessary Payflow variables to |
128 | | - * include in string (i.e. Vendor, password) |
129 | | - */ |
130 | | - private function fnPayflowProcessTransaction( $data, $payflow_data ) { |
131 | | - global $wgOut, $wgDonationTestingMode, $wgPayflowProGatewayUseHTTPProxy, $wgPayflowProGatewayHTTPProxy, $wgPayflowProTimeout; |
132 | | - |
133 | | - // update contribution tracking |
134 | | - $this->updateContributionTracking( $data, defined( 'OWA' ) ); |
135 | | - |
136 | | - // create payflow query string, include string lengths |
137 | | - $queryArray = array( |
138 | | - 'TRXTYPE' => $payflow_data['trxtype'], |
139 | | - 'TENDER' => $payflow_data['tender'], |
140 | | - 'USER' => $payflow_data['user'], |
141 | | - 'VENDOR' => $payflow_data['vendor'], |
142 | | - 'PARTNER' => $payflow_data['partner'], |
143 | | - 'PWD' => $payflow_data['password'], |
144 | | - 'ACCT' => $data['card_num'], |
145 | | - 'EXPDATE' => $data['expiration'], |
146 | | - 'AMT' => $data['amount'], |
147 | | - 'FIRSTNAME' => $data['fname'], |
148 | | - 'LASTNAME' => $data['lname'], |
149 | | - 'STREET' => $data['street'], |
150 | | - 'CITY' => $data['city'], |
151 | | - 'STATE' => $data['state'], |
152 | | - 'COUNTRY' => $data['country'], |
153 | | - 'ZIP' => $data['zip'], |
154 | | - 'INVNUM' => $data['order_id'], |
155 | | - 'CVV2' => $data['cvv'], |
156 | | - 'CURRENCY' => $data['currency'], |
157 | | - 'VERBOSITY' => $payflow_data['verbosity'], |
158 | | - 'CUSTIP' => $payflow_data['user_ip'], |
159 | | - ); |
160 | | - |
161 | | - foreach ( $queryArray as $name => $value ) { |
162 | | - $query[] = $name . '[' . strlen( $value ) . ']=' . $value; |
163 | | - } |
164 | | - |
165 | | - $queryString = implode( '&', $query ); |
166 | | - |
167 | | - $payflow_query = $queryString; |
168 | | - |
169 | | - // assign header data necessary for the curl_setopt() function |
170 | | - $user_agent = Http::userAgent(); |
171 | | - $headers[] = 'Content-Type: text/namevalue'; |
172 | | - $headers[] = 'Content-Length : ' . strlen( $payflow_query ); |
173 | | - $headers[] = 'X-VPS-Client-Timeout: 45'; |
174 | | - $headers[] = 'X-VPS-Request-ID:' . $data['order_id']; |
175 | | - $ch = curl_init(); |
176 | | - $paypalPostTo = isset( $wgDonationTestingMode ) ? 'testingurl' : 'paypalurl'; |
177 | | - curl_setopt( $ch, CURLOPT_URL, $payflow_data[$paypalPostTo] ); |
178 | | - curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); |
179 | | - curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent ); |
180 | | - curl_setopt( $ch, CURLOPT_HEADER, 1 ); |
181 | | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
182 | | - curl_setopt( $ch, CURLOPT_TIMEOUT, $wgPayflowProTimeout ); |
183 | | - curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 ); |
184 | | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
185 | | - curl_setopt( $ch, CURLOPT_POSTFIELDS, $payflow_query ); |
186 | | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 ); |
187 | | - curl_setopt( $ch, CURLOPT_FORBID_REUSE, true ); |
188 | | - curl_setopt( $ch, CURLOPT_POST, 1 ); |
189 | | - |
190 | | - // set proxy settings if necessary |
191 | | - if ( $wgPayflowProGatewayUseHTTPProxy ) { |
192 | | - curl_setopt( $ch, CURLOPT_HTTPPROXYTUNNEL, 1 ); |
193 | | - curl_setopt( $ch, CURLOPT_PROXY, $wgPayflowProGatewayHTTPProxy ); |
194 | | - } |
195 | | - |
196 | | - // As suggested in the PayPal developer forum sample code, try more than once to get a response |
197 | | - // in case there is a general network issue |
198 | | - $i = 1; |
199 | | - |
200 | | - while ( $i++ <= 3 ) { |
201 | | - self::log( $data['order_id'] . ' Preparing to send transaction to PayflowPro' ); |
202 | | - $result = curl_exec( $ch ); |
203 | | - $headers = curl_getinfo( $ch ); |
204 | | - |
205 | | - if ( $headers['http_code'] != 200 && $headers['http_code'] != 403 ) { |
206 | | - self::log( $data['order_id'] . ' Failed sending transaction to PayflowPro, retrying' ); |
207 | | - sleep( 1 ); |
208 | | - } elseif ( $headers['http_code'] == 200 || $headers['http_code'] == 403 ) { |
209 | | - self::log( $data['order_id'] . ' Finished sending transaction to PayflowPro' ); |
210 | | - break; |
211 | | - } |
212 | | - } |
213 | | - |
214 | | - if ( $headers['http_code'] != 200 ) { |
215 | | - $wgOut->addHTML( '<h3>No response from credit card processor. Please try again later!</h3><p>' ); |
216 | | - $when = time(); |
217 | | - self::log( $data['order_id'] . ' No response from credit card processor: ' . curl_error( $ch ) ); |
218 | | - curl_close( $ch ); |
219 | | - return; |
220 | | - } |
221 | | - |
222 | | - curl_close( $ch ); |
223 | | - |
224 | | - // get result string |
225 | | - $result = strstr( $result, 'RESULT' ); |
226 | | - |
227 | | - // parse string and display results to the user |
228 | | - $this->fnPayflowGetResults( $data, $result ); |
229 | | - } |
230 | | - |
231 | | - /** |
232 | 99 | * "Reads" the name-value pair result string returned by Payflow and creates corresponding error messages |
233 | 100 | * |
234 | 101 | * @param $data Array: array of user input |
— | — | @@ -235,124 +102,43 @@ |
236 | 103 | * |
237 | 104 | * Credit: code modified from payflowpro_example_EC.php posted (and supervised) on the PayPal developers message board |
238 | 105 | */ |
239 | | - private function fnPayflowGetResults( $data, $result ) { |
240 | | - // prepare NVP response for sorting and outputting |
241 | | - $responseArray = array( ); |
242 | | - |
243 | | - /** |
244 | | - * The result response string looks like: |
245 | | - * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1 |
246 | | - * We want to turn this into an array of key value pairs, so explode on '&' and then |
247 | | - * split up the resulting strings into $key => $value |
248 | | - */ |
249 | | - $result_arr = explode( "&", $result ); |
250 | | - foreach ( $result_arr as $result_pair ) { |
251 | | - list( $key, $value ) = preg_split( "/=/", $result_pair ); |
252 | | - $responseArray[$key] = $value; |
| 106 | + private function fnPayflowDisplayResults( $result ) { |
| 107 | + if ( is_array( $result ) && array_key_exists( 'errors', $result ) && is_array( $result['errors'] ) ) { |
| 108 | + foreach ( $result['errors'] as $key => $value ) { |
| 109 | + $errorCode = $key; |
| 110 | + $responseMsg = $value; |
| 111 | + break; //we just want the top, and this is probably the fastest way. |
| 112 | + } |
253 | 113 | } |
254 | 114 | |
255 | | - // store the response array as an object property for easy retrival/manipulation elsewhere |
256 | | - $this->payflow_response = $responseArray; |
| 115 | + $oid = $this->adapter->getData( 'order_id' ); |
| 116 | + $i_oid = $this->adapter->getData( 'i_order_id' ); |
| 117 | + $data = $this->adapter->getData(); |
257 | 118 | |
258 | | - // errors fall into three categories, "try again please", "sorry it didn't work out", and "approved" |
259 | | - // get the result code for response array |
260 | | - $resultCode = $responseArray['RESULT']; |
261 | | - |
262 | | - // initialize response message |
263 | | - $responseMsg = ''; |
264 | | - |
265 | | - // interpret result code, return |
266 | | - // approved (1), denied (2), try again (3), general error (4) |
267 | | - $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg ); |
268 | | - |
269 | | - // log that the transaction is essentially complete |
270 | | - self::log( $data['order_id'] . " Transaction complete." ); |
271 | | - |
272 | 119 | // if approved, display results and send transaction to the queue |
273 | 120 | if ( $errorCode == '1' ) { |
274 | | - self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction approved.", 'payflowpro_gateway', LOG_DEBUG ); |
| 121 | + self::log( $oid . " " . $i_oid . " Transaction approved.", LOG_DEBUG ); |
275 | 122 | $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ); |
276 | 123 | // give user a second chance to enter incorrect data |
277 | 124 | } elseif ( ( $errorCode == '3' ) && ( $data['numAttempt'] < '5' ) ) { |
278 | | - self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction unsuccessful (invalid info).", 'payflowpro_gateway', LOG_DEBUG ); |
| 125 | + self::log( $oid . " " . $i_oid . " Transaction unsuccessful (invalid info).", LOG_DEBUG ); |
279 | 126 | // pass responseMsg as an array key as required by displayForm |
280 | 127 | $this->errors['retryMsg'] = $responseMsg; |
281 | 128 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
282 | 129 | // if declined or if user has already made two attempts, decline |
283 | 130 | } elseif ( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '3' ) ) { |
284 | | - self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction declined.", 'payflowpro_gateway', LOG_DEBUG ); |
| 131 | + self::log( $oid . " " . $i_oid . " Transaction declined.", LOG_DEBUG ); |
285 | 132 | $this->fnPayflowDisplayDeclinedResults( $responseMsg ); |
286 | 133 | } elseif ( ( $errorCode == '4' ) ) { |
287 | | - self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction unsuccessful.", 'payflowpro_gateway', LOG_DEBUG ); |
| 134 | + self::log( $oid . " " . $i_oid . " Transaction unsuccessful.", LOG_DEBUG ); |
288 | 135 | $this->fnPayflowDisplayOtherResults( $responseMsg ); |
289 | 136 | } elseif ( ( $errorCode == '5' ) ) { |
290 | | - self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction pending.", 'payflowpro_gateway', LOG_DEBUG ); |
| 137 | + self::log( $oid . " " . $i_oid . " Transaction pending.", LOG_DEBUG ); |
291 | 138 | $this->fnPayflowDisplayPending( $data, $responseArray, $responseMsg ); |
292 | 139 | } |
293 | 140 | } |
294 | 141 | |
295 | | -// end display results |
296 | | - |
297 | 142 | /** |
298 | | - * Interpret response code, return |
299 | | - * 1 if approved |
300 | | - * 2 if declined |
301 | | - * 3 if invalid data was submitted by user |
302 | | - * 4 all other errors |
303 | | - */ |
304 | | - function fnPayflowGetResponseMsg( $resultCode, &$responseMsg ) { |
305 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-default' ); |
306 | | - |
307 | | - switch ( $resultCode ) { |
308 | | - case '0': |
309 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-0' ); |
310 | | - $errorCode = '1'; |
311 | | - break; |
312 | | - case '126': |
313 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-126-2' ); |
314 | | - $errorCode = '5'; |
315 | | - break; |
316 | | - case '12': |
317 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-12' ); |
318 | | - $errorCode = '2'; |
319 | | - break; |
320 | | - case '13': |
321 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-13' ); |
322 | | - $errorCode = '2'; |
323 | | - break; |
324 | | - case '114': |
325 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-114' ); |
326 | | - $errorCode = '2'; |
327 | | - break; |
328 | | - case '4': |
329 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-4' ); |
330 | | - $errorCode = '3'; |
331 | | - break; |
332 | | - case '23': |
333 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-23' ); |
334 | | - $errorCode = '3'; |
335 | | - break; |
336 | | - case '24': |
337 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-24' ); |
338 | | - $errorCode = '3'; |
339 | | - break; |
340 | | - case '112': |
341 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-112' ); |
342 | | - $errorCode = '3'; |
343 | | - break; |
344 | | - case '125': |
345 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-125-2' ); |
346 | | - $errorCode = '3'; |
347 | | - break; |
348 | | - default: |
349 | | - $responseMsg = wfMsg( 'payflowpro_gateway-response-default' ); |
350 | | - $errorCode = '4'; |
351 | | - } |
352 | | - |
353 | | - return $errorCode; |
354 | | - } |
355 | | - |
356 | | - /** |
357 | 143 | * Display response message to user with submitted user-supplied data |
358 | 144 | * |
359 | 145 | * @param $data Array: array of posted data from form |
— | — | @@ -391,8 +177,6 @@ |
392 | 178 | // if we want to show the response |
393 | 179 | $wgOut->addHTML( Xml::buildTable( $rows, array( 'class' => 'submitted-response' ) ) ); |
394 | 180 | } |
395 | | - // unset edit token |
396 | | - $this->fnPayflowUnsetEditToken(); |
397 | 181 | } |
398 | 182 | |
399 | 183 | /** |
— | — | @@ -408,9 +192,6 @@ |
409 | 193 | |
410 | 194 | // display response message |
411 | 195 | $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . ' ' . $responseMsg . '</h3>' ); |
412 | | - |
413 | | - // unset edit token |
414 | | - $this->fnPayflowUnsetEditToken(); |
415 | 196 | } |
416 | 197 | |
417 | 198 | /** |
— | — | @@ -426,9 +207,6 @@ |
427 | 208 | |
428 | 209 | // display response message |
429 | 210 | $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . ' ' . $responseMsg . '</h3>' ); |
430 | | - |
431 | | - // unset edit token |
432 | | - $this->fnPayflowUnsetEditToken(); |
433 | 211 | } |
434 | 212 | |
435 | 213 | function fnPayflowDisplayPending( $data, $responseArray, $responseMsg ) { |
— | — | @@ -444,9 +222,6 @@ |
445 | 223 | // display response message |
446 | 224 | $wgOut->addHTML( '<h2 class="response_message">' . $thankyou . '</h2>' ); |
447 | 225 | $wgOut->addHTML( '<p>' . $responseMsg ); |
448 | | - |
449 | | - // unset edit token |
450 | | - $this->fnPayflowUnsetEditToken(); |
451 | 226 | } |
452 | 227 | |
453 | 228 | //TODO: Remember why the heck I decided to leave this here... |
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | static $instance; |
26 | 26 | |
27 | 27 | public function __construct( &$gateway_adapter ) { |
28 | | - parent::__construct( &$gateway_adapter ); //gateway_adapter is set in there. |
| 28 | + parent::__construct( $gateway_adapter ); //gateway_adapter is set in there. |
29 | 29 | // load user action ranges and risk score |
30 | 30 | $this->action_ranges = $this->getGlobal( 'CustomFiltersActionRanges' ); |
31 | 31 | $this->risk_score = $this->getGlobal( 'CustomFiltersRiskScore' ); |
— | — | @@ -63,12 +63,13 @@ |
64 | 64 | } |
65 | 65 | |
66 | 66 | static function onValidate( &$gateway_adapter ) { |
67 | | - return self::singleton( &$gateway_adapter )->validate(); |
| 67 | + $gateway_adapter->debugarray[] = 'custom filters onValidate hook!'; |
| 68 | + return self::singleton( $gateway_adapter )->validate(); |
68 | 69 | } |
69 | 70 | |
70 | 71 | static function singleton( &$gateway_adapter ) { |
71 | 72 | if ( !self::$instance ) { |
72 | | - self::$instance = new self( &$gateway_adapter ); |
| 73 | + self::$instance = new self( $gateway_adapter ); |
73 | 74 | } |
74 | 75 | return self::$instance; |
75 | 76 | } |
Index: branches/fundraising/extensions/DonationInterface/extras/minfraud/ccfd/CreditCardFraudDetection.php |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | var $API_VERSION; |
30 | 30 | |
31 | 31 | function __construct( &$gateway_adapter ) { |
32 | | - parent::__construct( &$gateway_adapter ); |
33 | | - $this->isSecure = 1; // use HTTPS by default |
| 32 | + parent::__construct( $gateway_adapter ); |
| 33 | + $this->isSecure = 1; // use HTTPS by default |
34 | 34 | // set the allowed_fields hash |
35 | 35 | $this->allowed_fields["i"] = 1; |
36 | 36 | $this->allowed_fields["domain"] = 1; |
Index: branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.body.php |
— | — | @@ -39,10 +39,10 @@ |
40 | 40 | static $instance; |
41 | 41 | |
42 | 42 | function __construct( &$gateway_adapter, $license_key = NULL ) { |
43 | | - parent::__construct( &$gateway_adapter ); |
| 43 | + parent::__construct( $gateway_adapter ); |
44 | 44 | $dir = dirname( __FILE__ ) . '/'; |
45 | 45 | require_once( $dir . "ccfd/CreditCardFraudDetection.php" ); |
46 | | - require_once( $dir . "../../includes/countryCodes.inc" ); |
| 46 | + //require_once( $dir . "../../includes/countryCodes.inc" ); |
47 | 47 | global $wgMinFraudLicenseKey, $wgMinFraudActionRanges; |
48 | 48 | |
49 | 49 | // set the minfraud license key, go no further if we don't have it |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | */ |
149 | 149 | public function get_ccfd() { |
150 | 150 | if ( !$this->ccfd ) { |
151 | | - $this->ccfd = new CreditCardFraudDetection( &$this->gateway_adapter ); |
| 151 | + $this->ccfd = new CreditCardFraudDetection( $this->gateway_adapter ); |
152 | 152 | } |
153 | 153 | return $this->ccfd; |
154 | 154 | } |
— | — | @@ -270,12 +270,13 @@ |
271 | 271 | } |
272 | 272 | |
273 | 273 | static function onValidate( &$gateway_adapter ) { |
274 | | - return self::singleton( &$gateway_adapter )->validate(); |
| 274 | + $gateway_adapter->debugarray[] = "Running an onValidate hook!"; |
| 275 | + return self::singleton( $gateway_adapter )->validate(); |
275 | 276 | } |
276 | 277 | |
277 | 278 | static function singleton( &$gateway_adapter ) { |
278 | 279 | if ( !self::$instance ) { |
279 | | - self::$instance = new self( &$gateway_adapter ); |
| 280 | + self::$instance = new self( $gateway_adapter ); |
280 | 281 | } |
281 | 282 | return self::$instance; |
282 | 283 | } |
Index: branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.php |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | * |
36 | 36 | * Default to settings in DonationInterface |
37 | 37 | */ |
38 | | -$wgDonationInterfaceRecaptchaUseHTTPProxy = $wgDonationInterfaceUseHTTPProxy; |
39 | | -$wgDonationInterfaceRecaptchaHTTPProxy = $wgDonationInterfaceHTTPProxy; |
| 38 | +//TODO: I think we can get rid of these entirely, due to the way we are now checking for globals in the extras. |
| 39 | +//$wgDonationInterfaceRecaptchaUseHTTPProxy = $wgDonationInterfaceUseHTTPProxy; |
| 40 | +//$wgDonationInterfaceRecaptchaHTTPProxy = $wgDonationInterfaceHTTPProxy; |
40 | 41 | |
41 | 42 | /** |
42 | 43 | * Use SSL to communicate with reCaptcha |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | //TODO: This is short-circuiting what I really want to do here. |
63 | 63 | //so stop it. |
64 | 64 | $data = $this->adapter->getDisplayData(); |
65 | | - |
| 65 | + |
66 | 66 | /* |
67 | 67 | * The $transactionType should default to false. |
68 | 68 | * |
— | — | @@ -71,14 +71,14 @@ |
72 | 72 | */ |
73 | 73 | $transactionType = false; |
74 | 74 | $transactionType = 'INSERT_ORDERWITHPAYMENT'; |
75 | | - $data['transaction_type'] = isset( $data['transaction_type'] ) ? $data['transaction_type'] : $transactionType; |
| 75 | + $data['transaction_type'] = (isset( $data['transaction_type'] ) && !empty( $data['transaction_type'] ) ) ? $data['transaction_type'] : $transactionType; |
76 | 76 | $this->adapter->setTransactionType( $data['transaction_type'] ); |
77 | 77 | unset( $transactionType ); |
78 | | - |
| 78 | + |
79 | 79 | $this->adapter->log( '$transactionType: Default is set to: INSERT_ORDERWITHPAYMENT, this is a temporary hack for backwards compatibility.' ); |
80 | | - $this->adapter->log( 'Setting transaction type: ' . (string) $data['transaction_type'] ); |
81 | | - |
82 | | - |
| 80 | + $this->adapter->log( 'Setting transaction type: ' . ( string ) $data['transaction_type'] ); |
| 81 | + |
| 82 | + |
83 | 83 | // dispatch forms/handling |
84 | 84 | if ( $this->adapter->checkTokens() ) { |
85 | 85 | if ( $this->adapter->posted && $data['payment_method'] == 'processed' ) { |
— | — | @@ -86,54 +86,51 @@ |
87 | 87 | $this->adapter->log( "Form posted and payment method set." ); |
88 | 88 | |
89 | 89 | // Check form for errors |
90 | | - |
91 | | - $options = array(); |
| 90 | + |
| 91 | + $options = array( ); |
92 | 92 | switch ( $this->adapter->getTransactionType() ) { |
93 | | - |
| 93 | + |
94 | 94 | case 'BANK_TRANSFER': |
95 | 95 | $options['creditCard'] = false; |
96 | 96 | break; |
97 | | - |
| 97 | + |
98 | 98 | case 'INSERT_ORDERWITHPAYMENT': |
99 | 99 | $options['creditCard'] = true; |
100 | 100 | break; |
101 | | - |
| 101 | + |
102 | 102 | default: |
103 | 103 | $options['creditCard'] = true; |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | $form_errors = $this->validateForm( $data, $this->errors, $options ); |
107 | 107 | unset( $options ); |
108 | 108 | |
109 | 109 | //$form_errors = $this->fnValidateForm( $data, $this->errors ); |
110 | | - |
111 | 110 | // If there were errors, redisplay form, otherwise proceed to next step |
112 | 111 | if ( $form_errors ) { |
113 | 112 | |
114 | 113 | $this->displayForm( $data, $this->errors ); |
115 | 114 | } else { // The submitted form data is valid, so process it |
116 | 115 | // allow any external validators to have their way with the data |
117 | | - |
118 | 116 | // Execute the proper transaction code: |
119 | 117 | switch ( $this->adapter->getTransactionType() ) { |
120 | | - |
| 118 | + |
121 | 119 | case 'BANK_TRANSFER': |
122 | 120 | $this->executeBankTransfer( $wgOut ); |
123 | 121 | break; |
124 | | - |
| 122 | + |
125 | 123 | case 'INSERT_ORDERWITHPAYMENT': |
126 | 124 | $this->executeInsertOrderWithPayment( $wgOut ); |
127 | 125 | break; |
128 | | - |
| 126 | + |
129 | 127 | default: |
130 | | - |
131 | | - $message = 'The transaction type [ ' . $this->adapter->getTransactionType() . ' ] was not found.'; |
| 128 | + |
| 129 | + $message = 'The transaction type [ ' . $this->adapter->getTransactionType() . ' ] was not found.'; |
132 | 130 | throw new Exception( $message ); |
133 | 131 | } |
134 | 132 | |
135 | 133 | |
136 | 134 | //TODO: add all the hooks back in. |
137 | | - |
138 | 135 | } |
139 | 136 | } else { |
140 | 137 | // Display form for the first time |
— | — | @@ -200,66 +197,7 @@ |
201 | 198 | } |
202 | 199 | } |
203 | 200 | } |
204 | | - |
205 | | - /** |
206 | | - * Interpret response code, return |
207 | | - * 1 if approved |
208 | | - * 2 if declined |
209 | | - * 3 if invalid data was submitted by user |
210 | | - * 4 all other errors |
211 | | - */ |
212 | | - function fnPayflowGetResponseMsg( $resultCode, &$responseMsg ) { |
213 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-default' ); |
214 | 201 | |
215 | | - switch ( $resultCode ) { |
216 | | - case '0': |
217 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-0' ); |
218 | | - $errorCode = '1'; |
219 | | - break; |
220 | | - case '126': |
221 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-126-2' ); |
222 | | - $errorCode = '5'; |
223 | | - break; |
224 | | - case '12': |
225 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-12' ); |
226 | | - $errorCode = '2'; |
227 | | - break; |
228 | | - case '13': |
229 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-13' ); |
230 | | - $errorCode = '2'; |
231 | | - break; |
232 | | - case '114': |
233 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-114' ); |
234 | | - $errorCode = '2'; |
235 | | - break; |
236 | | - case '4': |
237 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-4' ); |
238 | | - $errorCode = '3'; |
239 | | - break; |
240 | | - case '23': |
241 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-23' ); |
242 | | - $errorCode = '3'; |
243 | | - break; |
244 | | - case '24': |
245 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-24' ); |
246 | | - $errorCode = '3'; |
247 | | - break; |
248 | | - case '112': |
249 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-112' ); |
250 | | - $errorCode = '3'; |
251 | | - break; |
252 | | - case '125': |
253 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-125-2' ); |
254 | | - $errorCode = '3'; |
255 | | - break; |
256 | | - default: |
257 | | - $responseMsg = wfMsg( 'globalcollect_gateway-response-default' ); |
258 | | - $errorCode = '4'; |
259 | | - } |
260 | | - |
261 | | - return $errorCode; |
262 | | - } |
263 | | - |
264 | 202 | //TODO: Remember why the heck I decided to leave this here... |
265 | 203 | //arguably, it's because it's slightly more "view" related, but... still, shouldn't you get stashed |
266 | 204 | //in the new GatewayForm class so we can override in chlidren if we feel like it? Odd. |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | protected $accountInfo; |
84 | 84 | protected $url; |
85 | 85 | protected $transactions; |
86 | | - |
| 86 | + |
87 | 87 | /** |
88 | 88 | * $transaction_type will be set in the GatewayForm::execute() |
89 | 89 | * |
— | — | @@ -91,7 +91,6 @@ |
92 | 92 | * @see GatewayForm::execute() |
93 | 93 | */ |
94 | 94 | protected $transaction_type = false; |
95 | | - |
96 | 95 | protected $return_value_map; |
97 | 96 | protected $postdata; |
98 | 97 | protected $postdatadefaults; |
— | — | @@ -100,6 +99,8 @@ |
101 | 100 | protected $transaction_results; |
102 | 101 | protected $form_class; |
103 | 102 | protected $validation_errors; |
| 103 | + public $action; //Currently, hooks need to be able to set this directly. |
| 104 | + public $debugarray; //TODO: Take me out. |
104 | 105 | |
105 | 106 | //ALL OF THESE need to be redefined in the children. Much voodoo depends on the accuracy of these constants. |
106 | 107 | const GATEWAY_NAME = 'Donation Gateway'; |
— | — | @@ -332,6 +333,28 @@ |
333 | 334 | $this->currentTransaction( $transaction ); |
334 | 335 | //update the contribution tracking data |
335 | 336 | $this->incrementNumAttempt(); |
| 337 | + |
| 338 | + $this->runPreProcess(); //many hooks get fired here... |
| 339 | + //TODO: Uhmmm... what if none of the validate hooks are enabled? |
| 340 | + //Currently, I think that means the transaction stops here, and that's not quite right. |
| 341 | + //...is it? |
| 342 | + // if the transaction was NOT flagged for processing by something in runPreProcess()... |
| 343 | + if ( $this->action != 'process' ) { |
| 344 | + self::log( "Transaction failed pre-process checks." . print_r( $this->getData(), true ) ); |
| 345 | + return array( |
| 346 | + 'status' => false, |
| 347 | + //TODO: appropriate messages. |
| 348 | + 'message' => "$transaction : Failed failed pre-process checks. Somebody PLEASE override me!", |
| 349 | + 'errors' => array( |
| 350 | + '1000000' => 'pre-process failed you.' //...stupid code. |
| 351 | + ), |
| 352 | + 'action' => $this->action, |
| 353 | + ); |
| 354 | + } |
| 355 | + |
| 356 | + // expose a hook for external handling of trxns ready for processing |
| 357 | + wfRunHooks( 'GatewayProcess', array( &$this ) ); //don't think anybody is using this yet, but you could! |
| 358 | + |
336 | 359 | $this->dataObj->updateContributionTracking( defined( 'OWA' ) ); |
337 | 360 | if ( $this->getCommunicationType() === 'xml' ) { |
338 | 361 | $this->getStopwatch( "buildRequestXML" ); |
— | — | @@ -369,13 +392,20 @@ |
370 | 393 | $this->setTransactionResult( $this->getResponseStatus( $formatted ), 'status' ); |
371 | 394 | |
372 | 395 | //set errors |
| 396 | + //TODO: This "errors" business is becoming a bit of a misnomer, as the result code and message |
| 397 | + //are frequently packaged togther in the same place, whether the transaction passed or failed. |
373 | 398 | $this->setTransactionResult( $this->getResponseErrors( $formatted ), 'errors' ); |
374 | 399 | |
375 | 400 | //if we're still okay (hey, even if we're not), get relevent dataz. |
376 | | - $this->setTransactionResult( $this->getResponseData( $formatted ), 'data' ); |
| 401 | + $pulled_data = $this->getResponseData( $formatted ); |
| 402 | + $this->setTransactionResult( $pulled_data, 'data' ); |
377 | 403 | |
378 | | - $this->processResponse( $formatted ); |
| 404 | + // expose a hook for any post processing |
| 405 | + wfRunHooks( 'GatewayPostProcess', array( &$this ) ); //conversion log (at least) |
379 | 406 | |
| 407 | + $this->processResponse( $pulled_data ); |
| 408 | + $this->dataObj->unsetEditToken(); |
| 409 | + |
380 | 410 | //TODO: Actually pull these from somewhere legit. |
381 | 411 | if ( $this->getTransactionStatus() === true ) { |
382 | 412 | $this->setTransactionResult( "$transaction Transaction Successful!", 'message' ); |
— | — | @@ -385,6 +415,9 @@ |
386 | 416 | $this->setTransactionResult( "$transaction Transaction... weird. I have no idea what happened there.", 'message' ); |
387 | 417 | } |
388 | 418 | |
| 419 | + // log that the transaction is essentially complete |
| 420 | + self::log( $this->getData( 'order_id' ) . " Transaction complete." ); |
| 421 | + |
389 | 422 | return $this->getTransactionAllResults(); |
390 | 423 | |
391 | 424 | //speaking of universal form: |
— | — | @@ -821,7 +854,7 @@ |
822 | 855 | * @return string|false |
823 | 856 | */ |
824 | 857 | public function getTransactionType() { |
825 | | - |
| 858 | + |
826 | 859 | return $this->transaction_type; |
827 | 860 | } |
828 | 861 | |
— | — | @@ -831,12 +864,12 @@ |
832 | 865 | * @param string|false $transaction_type |
833 | 866 | */ |
834 | 867 | public function setTransactionType( $transaction_type ) { |
835 | | - |
| 868 | + |
836 | 869 | $transaction_type = empty( $transaction_type ) ? false : $transaction_type; |
837 | | - |
| 870 | + |
838 | 871 | $this->transaction_type = $transaction_type; |
839 | 872 | } |
840 | | - |
| 873 | + |
841 | 874 | public function getTransactionAllResults() { |
842 | 875 | if ( !empty( $this->transaction_results ) && is_array( $this->transaction_results ) ) { |
843 | 876 | return $this->transaction_results; |
— | — | @@ -932,5 +965,33 @@ |
933 | 966 | |
934 | 967 | public function unsetActionHash() { |
935 | 968 | $this->dataObj->expunge( 'action' ); |
936 | | - } |
| 969 | + } |
| 970 | + |
| 971 | + function runPreProcess() { |
| 972 | + |
| 973 | + // allow any external validators to have their way with the data |
| 974 | + self::log( $this->getData( 'order_id' ) . " Preparing to query MaxMind" ); |
| 975 | + wfRunHooks( 'GatewayValidate', array( &$this ) ); |
| 976 | + self::log( $this->getData( 'order_id' ) . ' Finished querying Maxmind' ); |
| 977 | + |
| 978 | + // if the transaction was flagged for review |
| 979 | + if ( $this->action == 'review' ) { |
| 980 | + // expose a hook for external handling of trxns flagged for review |
| 981 | + wfRunHooks( 'GatewayReview', array( &$this ) ); |
| 982 | + } |
| 983 | + |
| 984 | + // if the transaction was flagged to be 'challenged' |
| 985 | + if ( $this->action == 'challenge' ) { |
| 986 | + // expose a hook for external handling of trxns flagged for challenge (eg captcha) |
| 987 | + wfRunHooks( 'GatewayChallenge', array( &$this ) ); |
| 988 | + } |
| 989 | + |
| 990 | + // if the transaction was flagged for rejection |
| 991 | + if ( $this->action == 'reject' ) { |
| 992 | + // expose a hook for external handling of trxns flagged for rejection |
| 993 | + wfRunHooks( 'GatewayReject', array( &$this ) ); |
| 994 | + $this->dataObj->unsetEditToken(); |
| 995 | + } |
| 996 | + } |
| 997 | + |
937 | 998 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/GatewayForm.php |
— | — | @@ -137,19 +137,19 @@ |
138 | 138 | * |
139 | 139 | * @see GatewayForm::fnValidateForm() |
140 | 140 | */ |
141 | | - public function validateForm( &$data, &$error, $options = array() ) { |
| 141 | + public function validateForm( &$data, &$error, $options = array( ) ) { |
142 | 142 | |
143 | 143 | extract( $options ); |
144 | | - |
| 144 | + |
145 | 145 | // Set which items will be validated |
146 | | - $address = isset( $address ) ? (boolean) $address : true ; |
147 | | - $amount = isset( $amount ) ? (boolean) $amount : true ; |
148 | | - $creditCard = isset( $creditCard ) ? (boolean) $creditCard : false ; |
149 | | - $email = isset( $email ) ? (boolean) $email : true ; |
150 | | - $name = isset( $name ) ? (boolean) $name : true ; |
| 146 | + $address = isset( $address ) ? ( boolean ) $address : true; |
| 147 | + $amount = isset( $amount ) ? ( boolean ) $amount : true; |
| 148 | + $creditCard = isset( $creditCard ) ? ( boolean ) $creditCard : false; |
| 149 | + $email = isset( $email ) ? ( boolean ) $email : true; |
| 150 | + $name = isset( $name ) ? ( boolean ) $name : true; |
151 | 151 | |
152 | 152 | // These are set in the order they will most likely appear on the form. |
153 | | - |
| 153 | + |
154 | 154 | if ( $name ) { |
155 | 155 | $this->validateName( $data, $error ); |
156 | 156 | } |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | } |
165 | 165 | |
166 | 166 | if ( $email ) { |
167 | | - $this->validateEmail( $data, $error ); |
| 167 | + $this->validateEmail( $data, $error ); |
168 | 168 | } |
169 | 169 | |
170 | 170 | if ( $creditCard ) { |
— | — | @@ -175,9 +175,9 @@ |
176 | 176 | * |
177 | 177 | * This is done for backward compatibility. |
178 | 178 | */ |
179 | | - return $this->getValidateFormResult() ? 0 : 1 ; |
| 179 | + return $this->getValidateFormResult() ? 0 : 1; |
180 | 180 | } |
181 | | - |
| 181 | + |
182 | 182 | /** |
183 | 183 | * Validates the address |
184 | 184 | * |
— | — | @@ -187,32 +187,32 @@ |
188 | 188 | * @see GatewayForm::validateForm() |
189 | 189 | */ |
190 | 190 | public function validateAddress( &$data, &$error ) { |
191 | | - |
| 191 | + |
192 | 192 | if ( empty( $data['street'] ) ) { |
193 | | - |
| 193 | + |
194 | 194 | $error['street'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-street' ); |
195 | | - |
| 195 | + |
196 | 196 | $this->setValidateFormResult( false ); |
197 | 197 | } |
198 | | - |
| 198 | + |
199 | 199 | if ( empty( $data['city'] ) ) { |
200 | | - |
| 200 | + |
201 | 201 | $error['city'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-city' ); |
202 | | - |
| 202 | + |
203 | 203 | $this->setValidateFormResult( false ); |
204 | 204 | } |
205 | | - |
| 205 | + |
206 | 206 | if ( empty( $data['state'] ) ) { |
207 | | - |
| 207 | + |
208 | 208 | $error['state'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-state' ); |
209 | | - |
| 209 | + |
210 | 210 | $this->setValidateFormResult( false ); |
211 | 211 | } |
212 | | - |
| 212 | + |
213 | 213 | if ( empty( $data['zip'] ) ) { |
214 | | - |
| 214 | + |
215 | 215 | $error['zip'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-zip' ); |
216 | | - |
| 216 | + |
217 | 217 | $this->setValidateFormResult( false ); |
218 | 218 | } |
219 | 219 | } |
— | — | @@ -226,14 +226,14 @@ |
227 | 227 | * @see GatewayForm::validateForm() |
228 | 228 | */ |
229 | 229 | public function validateAmount( &$data, &$error ) { |
230 | | - |
| 230 | + |
231 | 231 | if ( empty( $data['amount'] ) ) { |
232 | | - |
| 232 | + |
233 | 233 | $error['amount'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-amount' ); |
234 | | - |
| 234 | + |
235 | 235 | $this->setValidateFormResult( false ); |
236 | 236 | } |
237 | | - |
| 237 | + |
238 | 238 | // check amount |
239 | 239 | $priceFloor = $this->adapter->getGlobal( 'PriceFloor' ); |
240 | 240 | $priceCeiling = $this->adapter->getGlobal( 'PriceCeiling' ); |
— | — | @@ -256,49 +256,40 @@ |
257 | 257 | * @see GatewayForm::validateForm() |
258 | 258 | */ |
259 | 259 | public function validateCreditCard( &$data, &$error ) { |
260 | | - |
| 260 | + |
261 | 261 | if ( empty( $data['card_num'] ) ) { |
262 | 262 | |
263 | 263 | $error['card_num'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-card_num' ); |
264 | 264 | |
265 | 265 | $this->setValidateFormResult( false ); |
266 | 266 | } |
267 | | - |
| 267 | + |
268 | 268 | if ( empty( $data['cvv'] ) ) { |
269 | 269 | |
270 | 270 | $error['cvv'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-cvv' ); |
271 | 271 | |
272 | 272 | $this->setValidateFormResult( false ); |
273 | 273 | } |
274 | | - |
| 274 | + |
275 | 275 | if ( empty( $data['expiration'] ) ) { |
276 | 276 | |
277 | 277 | $error['expiration'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-expiration' ); |
278 | 278 | |
279 | 279 | $this->setValidateFormResult( false ); |
280 | 280 | } |
281 | | - |
| 281 | + |
282 | 282 | // validate that credit card number entered is correct and set the card type |
283 | 283 | if ( preg_match( '/^3[47][0-9]{13}$/', $data['card_num'] ) ) { // american express |
284 | | - |
285 | 284 | $data['card'] = 'american'; |
286 | | - |
287 | 285 | } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data['card_num'] ) ) { // mastercard |
288 | | - |
289 | 286 | $data['card'] = 'mastercard'; |
290 | | - |
291 | 287 | } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data['card_num'] ) ) {// visa |
292 | | - |
293 | 288 | $data['card'] = 'visa'; |
294 | | - |
295 | 289 | } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data['card_num'] ) ) { // discover |
296 | | - |
297 | 290 | $data['card'] = 'discover'; |
298 | | - |
299 | 291 | } else { // an invalid credit card number was entered |
| 292 | + $error['card_num'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-card-num' ); |
300 | 293 | |
301 | | - $error[ 'card_num' ] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-card-num' ); |
302 | | - |
303 | 294 | $this->setValidateFormResult( false ); |
304 | 295 | } |
305 | 296 | } |
— | — | @@ -312,14 +303,14 @@ |
313 | 304 | * @see GatewayForm::validateForm() |
314 | 305 | */ |
315 | 306 | public function validateEmail( &$data, &$error ) { |
316 | | - |
| 307 | + |
317 | 308 | if ( empty( $data['email'] ) ) { |
318 | 309 | |
319 | 310 | $error['email'] = wfMsg( $gateway_identifier . '_gateway-error-email-empty' ); |
320 | 311 | |
321 | 312 | $this->setValidateFormResult( false ); |
322 | 313 | } |
323 | | - |
| 314 | + |
324 | 315 | // is email address valid? |
325 | 316 | $isEmail = User::isValidEmailAddr( $data['email'] ); |
326 | 317 | |
— | — | @@ -340,22 +331,22 @@ |
341 | 332 | * @see GatewayForm::validateForm() |
342 | 333 | */ |
343 | 334 | public function validateName( &$data, &$error ) { |
344 | | - |
| 335 | + |
345 | 336 | if ( empty( $data['fname'] ) ) { |
346 | | - |
| 337 | + |
347 | 338 | $error['fname'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-fname' ); |
348 | | - |
| 339 | + |
349 | 340 | $this->setValidateFormResult( false ); |
350 | 341 | } |
351 | | - |
| 342 | + |
352 | 343 | if ( empty( $data['lname'] ) ) { |
353 | | - |
| 344 | + |
354 | 345 | $error['lname'] = wfMsg( $this->adapter->getIdentifier() . '_gateway-error-msg-lname' ); |
355 | | - |
| 346 | + |
356 | 347 | $this->setValidateFormResult( false ); |
357 | 348 | } |
358 | 349 | } |
359 | | - |
| 350 | + |
360 | 351 | /** |
361 | 352 | * Build and display form to user |
362 | 353 | * |
— | — | @@ -452,6 +443,16 @@ |
453 | 444 | } else { |
454 | 445 | $wgOut->addHTML( "No Session Donor Vars:<ul>" ); |
455 | 446 | } |
| 447 | + |
| 448 | + if ( is_array( $this->adapter->debugarray ) ) { |
| 449 | + $wgOut->addHTML( "Debug Array:<ul>" ); |
| 450 | + foreach ( $this->adapter->debugarray as $val ) { |
| 451 | + $wgOut->addHTML( "<li>$val" ); |
| 452 | + } |
| 453 | + $wgOut->addHTML( "</ul>" ); |
| 454 | + } else { |
| 455 | + $wgOut->addHTML( "No Debug Array<ul>" ); |
| 456 | + } |
456 | 457 | } |
457 | 458 | |
458 | 459 | public function getPossibleErrors() { |
— | — | @@ -575,8 +576,7 @@ |
576 | 577 | // submit the data to the paypal redirect URL |
577 | 578 | $wgOut->redirect( $this->adapter->getPaypalRedirectURL() ); |
578 | 579 | } |
579 | | - |
580 | | - |
| 580 | + |
581 | 581 | /** |
582 | 582 | * Fetch the array of iso country codes => country names |
583 | 583 | * @return array |
— | — | @@ -592,8 +592,8 @@ |
593 | 593 | * @return boolean |
594 | 594 | */ |
595 | 595 | public function getValidateFormResult() { |
596 | | - |
597 | | - return (boolean) $this->validateFormResult; |
| 596 | + |
| 597 | + return ( boolean ) $this->validateFormResult; |
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
— | — | @@ -602,8 +602,8 @@ |
603 | 603 | * @param boolean $validateFormResult |
604 | 604 | */ |
605 | 605 | public function setValidateFormResult( $validateFormResult ) { |
606 | | - |
607 | | - $this->validateFormResult = empty( $validateFormResult ) ? false : (boolean) $validateFormResult; |
| 606 | + |
| 607 | + $this->validateFormResult = empty( $validateFormResult ) ? false : ( boolean ) $validateFormResult; |
608 | 608 | } |
609 | 609 | |
610 | 610 | } |