r58314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58313‎ | r58314 | r58315 >
Date:14:40, 29 October 2009
Author:diana
Status:ok
Tags:
Comment:
Code review changes - more to come
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/donate_interface/donate_interface.i18n.php (modified) (history)
  • /trunk/extensions/DonationInterface/donate_interface/donate_interface.php (modified) (history)
  • /trunk/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)
  • /trunk/extensions/DonationInterface/paypal_gateway/paypal_gateway.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -9,9 +9,6 @@
1010
1111 function execute( $par ) {
1212 global $wgRequest, $wgOut, $wgUser;
13 -
14 - global $wgParser;
15 - $wgParser->disableCache();
1613
1714 $this->setHeaders();
1815
@@ -53,12 +50,12 @@
5451 $error[] = '';
5552
5653 //find out if amount was a radio button or textbox, set amount
57 - if (isset($_REQUEST['amount'])) {
 54+ if (isset($_REQUEST['amount'])&& preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount'))) {
5855 $amount = $wgRequest->getText('amount');
59 - } else if (isset($_REQUEST['amount2'])) {
 56+ } else if (isset($_REQUEST['amount2']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount2'))) {
6057 $amount = number_format($wgRequest->getText('amount2'), 2, '.', '');
6158 } else {
62 - $wgOut->addHTML(wfMsg( 'pfp-accessible' ));
 59+ $wgOut->addHTML(wfMsg( 'payflowpro_gateway-accessible' ));
6360 return;
6461 }
6562
@@ -111,17 +108,17 @@
112109 if ($success) {
113110 if ($data['payment_method'] == "processed") {
114111 // Check form for errors and redisplay with messages
115 - if ($form_errors = $this->validateForm($data, $error)) {
116 - $this->displayForm($data, $error);
 112+ if ($form_errors = $this->fnPayflowValidateForm($data, $error)) {
 113+ $this->fnPayflowDisplayForm($data, $error);
117114 } else {
118115 // The submitted data is valid, so process it
119116 //increase the count of attempts
120117 ++$data['numAttempt'];
121 - $this->processTransaction($data, $payflow_data);
 118+ $this->fnPayflowProcessTransaction($data, $payflow_data);
122119 }
123120 } else {
124121 //Display form for the first time
125 - $this->displayForm($data, $error);
 122+ $this->fnPayflowDisplayForm($data, $error);
126123 }
127124 } // end $success
128125
@@ -136,16 +133,16 @@
137134 *
138135 * The message at the top of the form can be edited in the payflow_gateway.i18.php file
139136 */
140 - private function displayForm($data, &$error) {
 137+ private function fnPayflowDisplayForm($data, &$error) {
141138 require_once('includes/stateAbbreviations.inc');
142139 require_once('includes/countryCodes.inc');
143140
144 - global $wgOut;
 141+ global $wgOut, $wgLang;
145142
146143 $form = XML::openElement('div', array('id' => 'mw-creditcard')) .
147144 XML::openElement('div', array('id' => 'mw-creditcard-intro')) .
148 - XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message' )) .
149 - XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message-2' )) .
 145+ XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'payflowpro_gateway-form-message' )) .
 146+ XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'payflowpro_gateway-form-message-2' )) .
150147 XML::closeElement('div');
151148
152149 //add hidden fields
@@ -168,22 +165,22 @@
169166 //Form
170167 $form .= XML::openElement('div', array('id' => 'mw-creditcard-form')) .
171168 XML::openElement('form', array('name' => "payment", 'method' => "post", 'action' => "", 'onsubmit' => 'return validate_form(this)')) .
172 - XML::element('legend', array('class' => 'mw-creditcard-amount'), wfMsg( 'pfp-amount-legend' ) .$data['amount']) .
 169+ XML::element('legend', array('class' => 'mw-creditcard-amount'), wfMsg( 'payflowpro_gateway-amount-legend' ) .$data['amount']) .
173170 XML::hidden('amount', $data['amount']);
174171
175172 $donorInput = array(
176 - XML::inputLabel(wfMsg( 'pfp-donor-email' ), "emailAdd", "emailAdd", "30", $data['email'], array('maxlength' => "150")) . '<span class="creditcard_error_msg">'. " " . $error['emailAdd'].'</span>',
177 - XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')) . '<span class="creditcard_error_msg">'. " " . $error['fname'].'</span>',
178 - XML::inputLabel(wfMsg( 'pfp-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")),
179 - XML::inputLabel(wfMsg( 'pfp-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['lname'].'</span>',
180 - XML::inputLabel(wfMsg( 'pfp-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['street'].'</span>',
181 - XML::inputLabel(wfMsg( 'pfp-donor-city' ), "city", "city", "20", $data['city'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['city'].'</span>',
182 - XML::label(wfMsg( 'pfp-donor-state' ), "state") .
 173+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-email' ), "emailAdd", "emailAdd", "30", $data['email'], array('maxlength' => "150")) . '<span class="creditcard_error_msg">'. " " . $error['emailAdd'].'</span>',
 174+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')) . '<span class="creditcard_error_msg">'. " " . $error['fname'].'</span>',
 175+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")),
 176+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['lname'].'</span>',
 177+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['street'].'</span>',
 178+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-city' ), "city", "city", "20", $data['city'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['city'].'</span>',
 179+ XML::label(wfMsg( 'payflowpro_gateway-donor-state' ), "state") .
183180 XML::openElement('select', array('name' => "state", 'id' => "state", 'value' => $data['state'])) .
184181 statesMenuXML() .
185182 XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['state'].'</span>',
186 - XML::inputLabel(wfMsg( 'pfp-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "18")) . '<span class="creditcard_error_msg">'. " " . $error['zip'].'</span>',
187 - XML::label(wfMsg( 'pfp-donor-country' ), "country") .
 183+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "18")) . '<span class="creditcard_error_msg">'. " " . $error['zip'].'</span>',
 184+ XML::label(wfMsg( 'payflowpro_gateway-donor-country' ), "country") .
188185 XML::openElement('select', array('name' => "country", 'id' => "country", 'value' => $data['country'])) .
189186 $countryMenu .
190187 XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['country'].'</span>'
@@ -195,7 +192,7 @@
196193 $donorField .= '<p>' . $value . '</p>';
197194 }
198195
199 - $form .= XML::fieldset(wfMsg( 'pfp-donor-legend' ), $donorField, array('class' => "mw-creditcard-donor"));
 196+ $form .= XML::fieldset(wfMsg( 'payflowpro_gateway-donor-legend' ), $donorField, array('class' => "mw-creditcard-donor"));
200197
201198 $cardOptions = array(
202199 'visa' => "Visa",
@@ -208,7 +205,7 @@
209206 }
210207
211208 $cardInput =
212 - XML::label(wfMsg( 'pfp-donor-card' ), "card") .
 209+ XML::label(wfMsg( 'payflowpro_gateway-donor-card' ), "card") .
213210 XML::openElement('select', array('name' => "card", 'id' => "card")) .
214211 $cardOptionsMenu .
215212 XML::closeElement('select');
@@ -216,11 +213,13 @@
217214 $expMos = '';
218215
219216 for($i=1; $i<13; $i++) {
220 - $expMos .= XML::option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT));
 217+ //$expMos .= XML::option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT));
 218+ $expMos .= XML::option($wgLang->getMonthName( $i ), str_pad($i, 2, '0', STR_PAD_LEFT));
 219+
221220 }
222221
223222 $expMosMenu =
224 - XML::label(wfMsg( 'pfp-donor-expiration' ), "expiration") .
 223+ XML::label(wfMsg( 'payflowpro_gateway-donor-expiration' ), "expiration") .
225224 XML::openElement('select', array('name' => "mos", 'id' => "mos")) .
226225 $expMos .
227226 XML::closeElement('select');
@@ -237,33 +236,33 @@
238237 XML::closeElement('select');
239238
240239 $cardInput = array(
241 - XML::label(wfMsg( 'pfp-donor-card' ), "card") .
 240+ XML::label(wfMsg( 'payflowpro_gateway-donor-card' ), "card") .
242241 XML::openElement('select', array('name' => "card", 'id' => "card")) .
243242 $cardOptionsMenu .
244243 XML::closeElement('select'),
245 - XML::inputLabel(wfMsg( 'pfp-donor-card-num' ), "card_num", "card_num", "30", '', array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['card_num'].'</span>' . '<span class="creditcard_error_msg">'. " " . $error['card'].'</span>',
 244+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-card-num' ), "card_num", "card_num", "30", '', array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['card_num'].'</span>' . '<span class="creditcard_error_msg">'. " " . $error['card'].'</span>',
246245 $expMosMenu . $expYrMenu,
247 - XML::inputLabel(wfMsg( 'pfp-donor-security' ), "cvv", "cvv", "5", '', array('maxlength' => "10")) . '<span class="creditcard_error_msg">'. " " . $error['cvv'].'</span>',
 246+ XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-security' ), "cvv", "cvv", "5", '', array('maxlength' => "10")) . '<span class="creditcard_error_msg">'. " " . $error['cvv'].'</span>',
248247 );
249248
250249 foreach($cardInput as $value) {
251250 $cardField .= '<p>' . $value . '</p>';
252251 }
253252
254 - $form .= XML::fieldset(wfMsg( 'pfp-card-legend' ), $cardField, array('class' => "mw-creditcard-card")) .
 253+ $form .= XML::fieldset(wfMsg( 'payflowpro_gateway-card-legend' ), $cardField, array('class' => "mw-creditcard-card")) .
255254 XML::hidden('process', 'CreditCard') .
256255 XML::hidden('payment_method', 'processed') .
257256 XML::hidden('token', $data['token']) .
258257 XML::hidden('currency_code', $data['currency']) .
259258 XML::hidden('orderid', $data['order_id']) .
260259 XML::hidden('numAttempt', $data['numAttempt']) .
261 - XML::submitButton("Donate") .
 260+ XML::submitButton(wfMsg( 'payflowpro_gateway-submit-button' )) .
262261 XML::closeElement('form') .
263262 XML::closeElement('div');
264263
265264
266265 $form .= XML::closeElement('div') .
267 - XML::Element('p', array('class' => "mw-creditcard-submessage"), wfMsg( 'pfp-donor-currency-msg', $data['currency'] ) );
 266+ XML::Element('p', array('class' => "mw-creditcard-submessage"), wfMsg( 'payflowpro_gateway-donor-currency-msg', $data['currency'] ) );
268267 $wgOut->addHTML( $form );
269268 }
270269
@@ -271,7 +270,7 @@
272271 /*
273272 * Checks posted form data for errors and returns array of messages
274273 */
275 - private function validateForm($data, &$error) {
 274+ private function fnPayflowValidateForm($data, &$error) {
276275 global $wgOut;
277276
278277 //begin with no errors
@@ -298,18 +297,19 @@
299298 if ($value == '') {
300299 //ignore fields that are not required
301300 if ($msg[$key]) {
302 - $error[$key] = "**" . wfMsg( 'pfp-error-msg', $msg[$key] ) . "**<br />";
 301+ $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />";
303302 $error_result = '1';
304303 }
305304 }
306305 }
307306
308307 //is email address valid?
309 - $isEmail = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email']);
 308+ //$isEmail = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email']);
 309+ $isEmail = User::isValidEmailAddr($data['email']);
310310
311311 //create error message (supercedes empty field message)
312312 if (!$isEmail) {
313 - $error['emailAdd'] = wfMsg ( 'pfp-error-msg-email' );
 313+ $error['emailAdd'] = wfMsg ( 'payflowpro_gateway-error-msg-email' );
314314 $error_result = '1';
315315 }
316316
@@ -323,7 +323,7 @@
324324 //if the pattern doesn't match
325325 if (!preg_match($pattern,$data['card_num'])) {
326326 $error_result = '1';
327 - $error['card'] = wfMsg( 'pfp-error-msg-amex' );
 327+ $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-amex' );
328328 }
329329
330330 break;
@@ -335,7 +335,7 @@
336336 //if pattern doesn't match
337337 if (!preg_match($pattern,$data['card_num'])) {
338338 $error_result = '1';
339 - $error['card'] = wfMsg( 'pfp-error-msg-mc' );
 339+ $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-mc' );
340340 }
341341
342342 break;
@@ -347,7 +347,7 @@
348348 //if pattern doesn't match
349349 if (!preg_match($pattern,$data['card_num'])) {
350350 $error_result = '1';
351 - $error['card'] = wfMsg( 'pfp-error-msg-visa' );
 351+ $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-visa' );
352352 }
353353
354354 break;
@@ -365,14 +365,12 @@
366366 * $payflow_data array of necessary Payflow variables to include in string (ie Vendor, password)
367367 *
368368 */
369 - private function processTransaction($data, $payflow_data) {
 369+ private function fnPayflowProcessTransaction($data, $payflow_data) {
370370 global $wgOut;
371371
372372 /* Create name-value pair query string */
373373 $payflow_query = "TRXTYPE=$payflow_data[trxtype]&TENDER=$payflow_data[tender]&USER=$payflow_data[user]&VENDOR=$payflow_data[vendor]&PARTNER=$payflow_data[partner]&PWD=$payflow_data[password]&ACCT=$data[card_num]&EXPDATE=$data[expiration]&AMT=$data[amount]&FIRSTNAME=$data[fname]&LASTNAME=$data[lname]&STREET=$data[street]&ZIP=$data[zip]&INVNUM=$payflow_data[order_id]&CVV2=$data[cvv]&CURRENCY=$data[currency]&VERBOSITY=$payflow_data[verbosity]&CUSTIP=$payflow_data[user_ip]";
374374
375 - //NOTE: for testing
376 - //var_dump($payflow_query);
377375
378376 // assign header data necessary for the curl_setopt() function
379377 $user_agent = $_SERVER['HTTP_USER_AGENT'];
@@ -422,7 +420,7 @@
423421 $result = strstr($result, "RESULT");
424422
425423 // parse string and display results to the user
426 - $this->getResults($data, $result);
 424+ $this->fnPayflowGetResults($data, $result);
427425
428426 }
429427
@@ -436,12 +434,9 @@
437435 *
438436 * Credit:code modified from payflowpro_example_EC.php posted (and supervised) on the PayPal developers message board
439437 */
440 - private function getResults($data, $result) {
 438+ private function fnPayflowGetResults($data, $result) {
441439 global $wgOut;
442440
443 - //NOTE for testing
444 - //var_dump($result);
445 -
446441 //prepare NVP response for sorting and outputting
447442 $responseArray = array();
448443
@@ -467,19 +462,19 @@
468463
469464 //interpret result code, return
470465 //approved (1), denied (2), try again (3), general error (4)
471 - $errorCode = $this->getResponseMsg($resultCode, $responseMsg);
 466+ $errorCode = $this->fnPayflowGetResponseMsg($resultCode, $responseMsg);
472467
473468 //if approved, display results and send transaction to the queue
474469 if ($errorCode == '1') {
475 - $this->displayApprovedResults($data, $responseArray, $responseMsg);
 470+ $this->fnPayflowDisplayApprovedResults($data, $responseArray, $responseMsg);
476471 //give user a second chance to enter incorrect data
477472 } else if (($errorCode == '3') && ($data['numAttempt'] < '2')) {
478473 //pass responseMsg as an array key as required by displayForm
479474 $tryAgainResponse[$responseMsg] = $responseMsg;
480 - $this->displayForm($data, $tryAgainResponse);
 475+ $this->fnPayflowDisplayForm($data, $tryAgainResponse);
481476 // if declined or if user has already made two attempts, decline
482477 } else if (($errorCode == '2') || ($data['numAttempt'] >= '2')) {
483 - $this->displayDeclinedResults($responseMsg);
 478+ $this->fnPayflowDisplayDeclinedResults($responseMsg);
484479 }
485480
486481 }// end display results
@@ -491,53 +486,53 @@
492487 * 3 if invalid data was submitted by user
493488 * 4 all other errors
494489 */
495 - function getResponseMsg($resultCode, &$responseMsg) {
496 - $responseMsg = wfMsg( 'pfp-response-default' );
 490+ function fnPayflowGetResponseMsg($resultCode, &$responseMsg) {
 491+ $responseMsg = wfMsg( 'payflowpro_gateway-response-default' );
497492 $errorCode = "0";
498493
499494 switch ($resultCode) {
500495 case '0':
501 - $responseMsg = wfMsg( 'pfp-response-0' );
 496+ $responseMsg = wfMsg( 'payflowpro_gateway-response-0' );
502497 $errorCode = "1";
503498 break;
504499 case '126':
505 - $responseMsg = wfMsg( 'pfp-response-126' );
 500+ $responseMsg = wfMsg( 'payflowpro_gateway-response-126' );
506501 $errorCode = "1";
507502 break;
508503 case '12':
509 - $responseMsg = wfMsg( 'pfp-response-12' );
 504+ $responseMsg = wfMsg( 'payflowpro_gateway-response-12' );
510505 $errorCode = "2";
511506 break;
512507 case '13':
513 - $responseMsg = wfMsg( 'pfp-response-13' );
 508+ $responseMsg = wfMsg( 'payflowpro_gateway-response-13' );
514509 $errorCode = "2";
515510 break;
516511 case '114':
517 - $responseMsg = wfMsg( 'pfp-response-114' );
 512+ $responseMsg = wfMsg( 'payflowpro_gateway-response-114' );
518513 $errorCode = "2";
519514 break;
520515 case '4':
521 - $responseMsg = wfMsg( 'pfp-response-4' );
 516+ $responseMsg = wfMsg( 'payflowpro_gateway-response-4' );
522517 $errorCode = "3";
523518 break;
524519 case '23':
525 - $responseMsg = wfMsg( 'pfp-response-23' );
 520+ $responseMsg = wfMsg( 'payflowpro_gateway-response-23' );
526521 $errorCode = "3";
527522 break;
528523 case '24':
529 - $responseMsg = wfMsg( 'pfp-response-24' );
 524+ $responseMsg = wfMsg( 'payflowpro_gateway-response-24' );
530525 $errorCode = "3";
531526 break;
532527 case '112':
533 - $responseMsg = wfMsg( 'pfp-response-112' );
 528+ $responseMsg = wfMsg( 'payflowpro_gateway-response-112' );
534529 $errorCode = "3";
535530 break;
536531 case '125':
537 - $responseMsg = wfMsg( 'pfp-response-125' );
 532+ $responseMsg = wfMsg( 'payflowpro_gateway-response-125' );
538533 $errorCode = "3";
539534 break;
540535 default:
541 - $responseMsg = wfMsg( 'pfp-response-default' );
 536+ $responseMsg = wfMsg( 'payflowpro_gateway-response-default' );
542537 $errorCode = "4";
543538
544539 }
@@ -553,7 +548,7 @@
554549 * $responseMsg message supplied by getResults function
555550 *
556551 */
557 - function displayApprovedResults($data, $responseArray, $responseMsg) {
 552+ function fnPayflowDisplayApprovedResults($data, $responseArray, $responseMsg) {
558553 global $wgOut;
559554 $transaction = '';
560555
@@ -567,11 +562,11 @@
568563 $countries = countryCodes();
569564
570565 $rows = array(
571 - 'title' => array(wfMsg( 'pfp-post-transaction' )),
572 - 'amount' => array(wfMsg( 'pfp-donor-amount' ), $data['amount']),
573 - 'email' => array(wfMsg( 'pfp-donor-email' ), $data['email']),
574 - 'name' => array(wfMsg( 'pfp-donor-name' ), $data['fname'], $data['mname'], $data['lname']),
575 - 'address' => array(wfMsg( 'pfp-donor-address' ), $data['street'], $data['city'], $data['state'], $data['zip'],$countries[$data['country']]),
 566+ 'title' => array(wfMsg( 'payflowpro_gateway-post-transaction' )),
 567+ 'amount' => array(wfMsg( 'payflowpro_gateway-donor-amount' ), $data['amount']),
 568+ 'email' => array(wfMsg( 'payflowpro_gateway-donor-email' ), $data['email']),
 569+ 'name' => array(wfMsg( 'payflowpro_gateway-donor-name' ), $data['fname'], $data['mname'], $data['lname']),
 570+ 'address' => array(wfMsg( 'payflowpro_gateway-donor-address' ), $data['street'], $data['city'], $data['state'], $data['zip'],$countries[$data['country']]),
576571 );
577572
578573 //if we want to show the response
@@ -602,7 +597,7 @@
603598 * $responseMsg message supplied by getResults function
604599 *
605600 */
606 - function displayDeclinedResults($responseMsg) {
 601+ function fnPayflowDisplayDeclinedResults($responseMsg) {
607602 global $wgOut;
608603
609604 //general decline message
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -10,50 +10,51 @@
1111 $messages['en'] = array(
1212 'payflowprogateway' => 'Support Wikimedia',
1313 'payflowpro_gateway-desc' => 'PayPal Payflow Pro credit card processing',
14 - 'pfp-accessible' => 'This page is only accessible from the donation page.',
15 - 'pfp-form-message' => 'Contribute with your credit card.
 14+ 'payflowpro_gateway-accessible' => 'This page is only accessible from the donation page.',
 15+ 'payflowpro_gateway-form-message' => 'Contribute with your credit card.
1616 There are <a href="http://wikimediafoundation.org/wiki/Donate/WaysToGive/en">other ways to give, including PayPal, check, or mail</a>.',
17 - 'pfp-form-message-2' => 'To change amount or currency, return to <a href="https://www.mediawiki.org/index.php?title=Donate">the donation page</a>',
18 - 'pfp-donor-legend' => 'Donor information',
19 - 'pfp-card-legend' => 'Credit card information',
20 - 'pfp-amount-legend' => 'Donation amount:',
21 - 'pfp-donor-amount' => 'Amount:',
22 - 'pfp-donor-email' => 'E-mail address:',
23 - 'pfp-donor-fname' => 'First name:',
24 - 'pfp-donor-mname' => 'Middle name:',
25 - 'pfp-donor-lname' => 'Last name:',
26 - 'pfp-donor-name' => 'Name:',
27 - 'pfp-donor-street' => 'Street:',
28 - 'pfp-donor-city' => 'City:',
29 - 'pfp-donor-state' => 'State:',
30 - 'pfp-donor-postal' => 'Postal code:',
31 - 'pfp-donor-country' => 'Country/Region:',
32 - 'pfp-donor-address'=> 'Address:',
33 - 'pfp-donor-card' => 'Credit card:',
34 - 'pfp-donor-card-num' => 'Card number:',
35 - 'pfp-donor-expiration' => 'Expiration date:',
36 - 'pfp-donor-security' => 'Security code:',
37 - 'pfp-donor-submit' => 'Donate',
38 - 'pfp-donor-currency-msg' => 'This donation is being made in $1',
39 - 'pfp-error-msg' => 'Please enter your $1',
40 - 'pfp-error-msg-email' => '**Please enter a valid e-mail address**',
41 - 'pfp-error-msg-amex' => '**Please enter a correct card number for American Express.**',
42 - 'pfp-error-msg-mc' => '**Please enter a correct card number for Mastercard.**',
43 - 'pfp-error-msg-visa' => '**Please enter a correct card number for Visa.**',
44 - 'pfp-response-0' => 'Your transaction has been approved.
 17+ 'payflowpro_gateway-form-message-2' => 'To change amount or currency, return to <a href="https://www.mediawiki.org/index.php?title=Donate">the donation page</a>',
 18+ 'payflowpro_gateway-donor-legend' => 'Donor information',
 19+ 'payflowpro_gateway-card-legend' => 'Credit card information',
 20+ 'payflowpro_gateway-amount-legend' => 'Donation amount:',
 21+ 'payflowpro_gateway-donor-amount' => 'Amount:',
 22+ 'payflowpro_gateway-donor-email' => 'E-mail address:',
 23+ 'payflowpro_gateway-donor-fname' => 'First name:',
 24+ 'payflowpro_gateway-donor-mname' => 'Middle name:',
 25+ 'payflowpro_gateway-donor-lname' => 'Last name:',
 26+ 'payflowpro_gateway-donor-name' => 'Name:',
 27+ 'payflowpro_gateway-donor-street' => 'Street:',
 28+ 'payflowpro_gateway-donor-city' => 'City:',
 29+ 'payflowpro_gateway-donor-state' => 'State:',
 30+ 'payflowpro_gateway-donor-postal' => 'Postal code:',
 31+ 'payflowpro_gateway-donor-country' => 'Country/Region:',
 32+ 'payflowpro_gateway-donor-address'=> 'Address:',
 33+ 'payflowpro_gateway-donor-card' => 'Credit card:',
 34+ 'payflowpro_gateway-donor-card-num' => 'Card number:',
 35+ 'payflowpro_gateway-donor-expiration' => 'Expiration date:',
 36+ 'payflowpro_gateway-donor-security' => 'Security code:',
 37+ 'payflowpro_gateway-donor-submit' => 'Donate',
 38+ 'payflowpro_gateway-donor-currency-msg' => 'This donation is being made in $1',
 39+ 'payflowpro_gateway-error-msg' => 'Please enter your $1',
 40+ 'payflowpro_gateway-error-msg-email' => '**Please enter a valid e-mail address**',
 41+ 'payflowpro_gateway-error-msg-amex' => '**Please enter a correct card number for American Express.**',
 42+ 'payflowpro_gateway-error-msg-mc' => '**Please enter a correct card number for Mastercard.**',
 43+ 'payflowpro_gateway-error-msg-visa' => '**Please enter a correct card number for Visa.**',
 44+ 'payflowpro_gateway-response-0' => 'Your transaction has been approved.
4545 Thank you for your donation!',
46 - 'pfp-response-126' => 'Your transaction is pending approval.',
47 - 'pfp-response-12' => 'Please contact your credit card company for further information.',
48 - 'pfp-response-13' => 'Your transaction requires voice authorization.
 46+ 'payflowpro_gateway-response-126' => 'Your transaction is pending approval.',
 47+ 'payflowpro_gateway-response-12' => 'Please contact your credit card company for further information.',
 48+ 'payflowpro_gateway-response-13' => 'Your transaction requires voice authorization.
4949 Please contact us to continue your transaction.', // This will not apply to Wikimedia accounts
50 - 'pfp-response-114' => 'Please contact your credit card company for further information.',
51 - 'pfp-response-23' => 'Your credit card number or expiration date is incorrect.',
52 - 'pfp-response-4' => 'Invalid amount.',
53 - 'pfp-response-24' => 'Your credit card number or expiration date is incorrect.',
54 - 'pfp-response-112' => 'Your address or CVV number (security code) is incorrect.',
55 - 'pfp-response-125' => 'Your transaction has been declined by Fraud Prevention Services.',
56 - 'pfp-response-default' => 'There was an error processing your transaction.
 50+ 'payflowpro_gateway-response-114' => 'Please contact your credit card company for further information.',
 51+ 'payflowpro_gateway-response-23' => 'Your credit card number or expiration date is incorrect.',
 52+ 'payflowpro_gateway-response-4' => 'Invalid amount.',
 53+ 'payflowpro_gateway-response-24' => 'Your credit card number or expiration date is incorrect.',
 54+ 'payflowpro_gateway-response-112' => 'Your address or CVV number (security code) is incorrect.',
 55+ 'payflowpro_gateway-response-125' => 'Your transaction has been declined by Fraud Prevention Services.',
 56+ 'payflowpro_gateway-response-default' => 'There was an error processing your transaction.
5757 Please try again later.',
5858 'php-response-declined' => 'Your transaction has been declined.',
59 - 'pfp-post-transaction' => 'Transaction details',
 59+ 'payflowpro_gateway-post-transaction' => 'Transaction details',
 60+ 'payflowpro_gateway-submit-button' => "Donate",
6061 );
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -26,15 +26,25 @@
2727 $wgExtensionAliasesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.alias.php';
2828 $wgSpecialPages['PayflowProGateway'] = 'PayflowProGateway'; # Let MediaWiki know about your new special page.
2929
 30+// set defaults, these should be assigned in LocalSettings.php
 31+$wgPayflowProURL = 'https://payflowpro.paypal.com';
 32+$wgPayflowProTestingURL = 'https://pilot-payflowpro.paypal.com'; // Payflow testing URL
3033
 34+$wgPayflowProPartnerID = ''; //PayPal or original authorized reseller
 35+$wgPayflowProVendorID = ''; // paypal merchant login ID
 36+$wgPayflowProUserID = ''; //if one or more users are set up, authorized user ID, else same as VENDOR
 37+$wgPayflowProPassword = ''; //merchant login password
 38+
 39+
 40+
3141 /**
3242 * Hooks required to interface with the donation extension (include <donate> on page)
3343 *
3444 * gwValue supplies the value of the form option, the name that appears on the form
3545 * and the currencies supported by the gateway in the $values array
3646 */
37 -$wgHooks['gwValue'][] = 'pfpGatewayValue';
38 -$wgHooks['gwPage'][] = 'pfpGatewayPage';
 47+$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue';
 48+$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage';
3949
4050 /*
4151 * Hook to register form value and display name of this gateway
Index: trunk/extensions/DonationInterface/paypal_gateway/paypal_gateway.php
@@ -21,14 +21,17 @@
2222
2323 $wgExtensionMessagesFiles['PaypalGateway'] = $dir . 'paypal_gateway.i18n.php';
2424
 25+//default variables that should be set in LocalSettings
 26+$wgPaypalEmail = "";
 27+
2528 /**
2629 * Hooks required to interface with the donation extension (include <donate> on page)
2730 *
2831 * gwValue supplies the value of the form option, the name that appears on the form
2932 * and the currencies supported by the gateway in the $values array
3033 */
31 -$wgHooks['gwValue'][] = 'paypalGatewayValue';
32 -$wgHooks['gwPage'][] = 'paypalGatewayPage';
 34+$wgHooks['DonationInterface_Value'][] = 'paypalGatewayValue';
 35+$wgHooks['DonationInterface_Page'][] = 'paypalGatewayPage';
3336
3437 /*
3538 * Hook to register form value and display name of this gateway
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php
@@ -12,12 +12,13 @@
1313 }
1414
1515 // Extension credits that will show up on Special:Version
 16+
1617 $wgExtensionCredits['specialpage'][] = array(
1718 'path' => __FILE__,
1819 'name' => 'DonateInterface',
1920 //'author' => array( 'diana' ), // FIXME: Committer does not have details in http://svn.wikimedia.org/viewvc/mediawiki/USERINFO/
2021 'description' => 'Donate interface',
21 - 'descriptionmsg' => 'donor-desc',
 22+ 'descriptionmsg' => 'donate_interface-desc',
2223 'url' => 'http://www.mediawiki.org/wiki/Extension:DonateInterface',
2324 );
2425
@@ -26,68 +27,26 @@
2728 $wgExtensionMessagesFiles['DonateInterface'] = $dir . 'donate_interface.i18n.php';
2829
2930 $wgHooks['ParserFirstCallInit'][] = 'efDonateSetup';
 31+$wgHooks['MediaWikiPerformAction'][] = 'fnProcessDonateForm';
 32+
3033 /**
3134 * Create <donate /> tag to include landing page donation form
3235 */
3336 function efDonateSetup( &$parser ) {
34 - global $wgParser, $wgOut, $wgRequest;
 37+ global $wgHooks;
 38+
 39+ //load extension messages
 40+ wfLoadExtensionMessages( 'donate_interface' );
3541
36 - // Load extension messages
37 - wfLoadExtensionMessages( 'DonateInterface' );
 42+ $parser->disableCache();
3843
39 - $parser->disableCache();
 44+ $parser->setHook( 'donate', 'efDonateRender' );
 45+
 46+ //process form
 47+ wfRunHooks( 'MediaWikiPerformAction', array( $output,
 48+$article, $title, $user, $request, $this));
4049
41 - $wgParser->setHook( 'donate', 'efDonateRender' );
42 -
43 - // declare variables used to hold post data
44 - $userInput = array (
45 - 'currency' => 'USD',
46 - 'amount' => '0.00',
47 - 'payment_method' => '',
48 - 'referrer' => '',
49 - 'utm_source' => '',
50 - 'utm_medium' => '',
51 - 'utm_campaign' => '',
52 - 'language' => '',
53 - 'comment' => '',
54 - 'comment-option' => '',
55 - 'email' => '',
56 - );
57 -
58 - // if form has been submitted, assign data and redirect user to chosen payment gateway
59 - if ( isset( $_POST['process'] ) ) {
60 - if ( $_POST['process'] == '_yes_' ) {
61 - // find out which amount option was chosen for amount, redefined buttons or text box
62 - if( isset( $_POST['amount'] ) ) {
63 - $amount = number_format( $wgRequest->getText( 'amount' ), 2 );
64 - } else {
65 - $amount = number_format( $wgRequest->getText( 'amount2' ), 2, '.', '' );
66 - }
67 -
68 - // create array of user input from post data
69 - $userInput = array(
70 - 'currency' => $wgRequest->getText( 'currency_code' ),
71 - 'amount' => $amount,
72 - 'payment_method' => $wgRequest->getText( 'payment_method' ),
73 - 'referrer' => $wgRequest->getText( 'referrer' ),
74 - 'utm_source' => $wgRequest->getText( 'utm_source' ),
75 - 'utm_medium' => $wgRequest->getText( 'utm_medium' ),
76 - 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ),
77 - 'language' => $wgRequest->getText( 'language' ),
78 - 'comment' => $wgRequest->getText( 'comment' ),
79 - 'comment-option' => $wgRequest->getText( 'comment-option' ),
80 - 'email' => $wgRequest->getText( 'opt' ),
81 - );
82 -
83 - // ask payment processor extensions for their URL/page title
84 - wfRunHooks( 'gwPage', array( &$url ) );
85 -
86 - // send user to correct page for payment
87 - redirectToProcessorPage( $userInput, $url );
88 - } // end if form has been submitted
89 - }
90 -
91 - return true;
 50+ return true;
9251 }
9352
9453 /**
@@ -98,19 +57,20 @@
9958 */
10059 function efDonateRender( $input, $args, &$parser ) {
10160 global $wgOut, $wgScriptPath;
102 -
103 - $parser->disableCache();
104 -
105 - // if chapter exists for user's country, redirect
106 - $chapter = fnDonateChapterRedirect();
107 -
108 - // add JavaScript validation to <head>
109 - $wgOut->addScriptFile( $wgScriptPath . '/extensions/DonationInterface/donate_interface/validate_donation.js' );
110 -
111 - // display form to gather data from user
112 - $output = createOutput();
113 -
114 - return $output;
 61+
 62+ $parser->disableCache();
 63+
 64+ // if chapter exists for user's country, redirect
 65+ $chapter = fnDonateChapterRedirect();
 66+
 67+ // add JavaScript validation to <head>
 68+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js' );
 69+
 70+
 71+ //display form to gather data from user
 72+ $output = fnDonateCreateOutput();
 73+
 74+ return $output;
11575 }
11676
11777 /**
@@ -119,158 +79,152 @@
12080 * Payment gateway options are created with the hook "gwValue". Each potential payment
12181 * option supplies it's value and name for the form, as well as currencies it supports.
12282 */
123 -function createOutput() {
124 - global $wgOut, $wgRequest;
 83+function fnDonateCreateOutput() {
 84+ global $wgOut, $wgRequest;
12585
126 - // declare variable
 86+ // declare variable
12787 $utm_source = '';
12888 $utm_medium = '';
12989 $utm_campaign = '';
13090 $referrer = '';
 91+
 92+ // set them equal to post data
 93+ $utm_source = $wgRequest->getText( 'utm_source' );
 94+ $utm_medium = $wgRequest->getText( 'utm_medium' );
 95+ $utm_campaign = $wgRequest->getText( 'utm_campaign' );
 96+ $referrer = $_SERVER['HTTP_REFERER'];
 97+
 98+ //get language from URL
 99+ $url = $_SERVER['REQUEST_URI'];
 100+
 101+ if ($url) {
 102+ $getLang = explode('/', $url);
 103+ $language = substr($getLang[3], 0, 2);
 104+ }
 105+
 106+ // error check and set "en" as default
 107+ if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
 108+ $language = 'en';
 109+ }
131110
132 - // set them equal to post data
133 - $utm_source = $wgRequest->getText( 'utm_source' );
134 - $utm_medium = $wgRequest->getText( 'utm_medium' );
135 - $utm_campaign = $wgRequest->getText( 'utm_campaign' );
136 - $referrer = $_SERVER['HTTP_REFERER'];
 111+ //get payment method gateway value and name from each gateway and create menu of options
 112+ $values = '';
 113+ wfRunHooks('DonationInterface_Value', array(&$values));
 114+
 115+ $gatewayMenu = '';
 116+
 117+ foreach($values as $current) {
 118+ $gatewayMenu .= Xml::option($current['display_name'], $current['form_value']);
 119+ }
 120+
 121+ //get available currencies
 122+ foreach($values as $key) {
 123+ $currencies = $key['currencies'];
 124+ }
137125
138 - // Get language from URL
139 - $url = $_SERVER['REQUEST_URI'];
140 -
141 - if( $url ) {
142 - $getLang = explode( '/', $url );
143 - $language = substr( $getLang[3], 0, 2 );
144 - }
145 -
146 - // error check and set "en" as default
147 - if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
148 - $language = 'en';
149 - }
150 -
151 - // Get payment method gateway value and name from each gateway and create menu of options
152 - $values = '';
153 - wfRunHooks( 'gwValue', array( &$values ) );
154 -
155 - $gatewayMenu = '';
156 -
157 - foreach( $values as $current ) {
158 - $gatewayMenu .= Xml::option( $current['display_name'], $current['form_value'] );
159 - }
160 -
161 - // Get available currencies
162 - // NOTE: currently all available currencies are accepted by all developed gateways
163 - // the next version will include gateway/currency checking
164 - // and inform user of gateways that aren't an option for that currency
165 - foreach( $values as $key ) {
166 - $currencies = $key['currencies'];
167 - }
168 -
169126 $currencyMenu = '';
170127
171 - foreach( $currencies as $value => $fullName ) {
172 - $currencyMenu .= Xml::option( $fullName, $value );
173 - }
174 -
175 - $output = Xml::openElement( 'form', array( 'name' => 'donate', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validateForm(this)' ) ) .
176 - Xml::openElement( 'div', array( 'id' => 'mw-donation-intro' ) ) .
177 - Xml::element( 'p', array( 'class' => 'mw-donation-intro-text' ), wfMsg( 'donor-intro' ) ) .
178 - Xml::closeElement( 'div' );
179 -
180 - $output .= Xml::hidden( 'utm_source', $utm_source ) .
181 - Xml::hidden( 'utm_medium', $utm_medium ) .
182 - Xml::hidden( 'utm_campaign', $utm_campaign ) .
183 - Xml::hidden( 'language', $language ) .
184 - Xml::hidden( 'referrer', $referrer );
185 -
186 - $amount = array(
187 - Xml::radioLabel( '$100', 'amount', '100', 'input_amount_3', false, array( '' ) ),
188 - Xml::radioLabel( '$75', 'amount', '75', 'input_amount_2', false, array( '' ) ),
189 - Xml::radioLabel( '$30', 'amount', '30', 'input_amount_1', false, array( '' ) ),
190 - Xml::inputLabel( wfMsg( 'donor-other-amount' ), 'amount2', 'input_amount_other', '5' ),
191 - );
192 -
193 - $amountFields = '<table><tr>';
194 - foreach( $amount as $value ) {
195 - $amountFields .= '<td>' . $value . '</td>';
196 - }
197 - $amountFields .= '</tr></table>';
198 -
199 - $output .= Xml::fieldset( wfMsg( 'donor-amount' ), $amountFields, array( 'class' => 'mw-donation-amount' ) );
200 -
201 - //$output .= '<p>Some test IPs: 91.189.90.211 (uk), 217.70.184.38 (fr)</p>';
202 -
203 - // Build currency options
204 - $default_currency = fnDonateDefaultCurrency();
205 -
206 - $currency_options = '';
207 - foreach( $currencies as $code => $name ) {
208 - $selected = '';
209 - if( $code == $default_currency ) {
210 - $selected = ' selected="selected"';
211 - }
212 - $currency_options .= '<option value="' . $code . '"' . $selected . '>' . $name . '</option>';
213 - }
214 -
215 - $currencyFields = Xml::openElement( 'select', array( 'name' => 'currency_code', 'id' => 'input_currency_code' ) ) .
216 - $currency_options .
217 - Xml::closeElement( 'select' );
218 -
219 - $output .= Xml::fieldset( wfMsg( 'donor-currency' ), $currencyFields, array( 'class' => 'mw-donation-currency' ) );
220 -
221 - $gatewayFields = Xml::openElement( 'select', array( 'name' => 'payment_method', 'id' => 'select_payment_method' ) ) .
222 - $gatewayMenu .
223 - Xml::closeElement( 'select' );
224 -
225 - $output .= Xml::fieldset( wfMsg( 'donor-gateway' ), $gatewayFields, array( 'class' => 'mw-donation-gateway' ) );
226 -
227 - $publicComment = Xml::element( 'div', array( 'class' => 'mw-donation-comment-message' ), wfMsg( 'donor-comment-message' ) ) .
228 - Xml::inputLabel(wfMsg( 'donor-comment-label' ), 'comment', 'comment', '30', '', array( 'maxlength' => '200' ) ) .
229 - Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' ) ) .
230 - Xml::checkLabel( wfMsg( 'donor-anon-message' ), 'comment-option', 'input_comment-option', true ) .
231 - Xml::closeElement( 'div' ) .
232 - Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' ) ) .
233 - Xml::check( 'opt', true ) .
234 - Xml::tags( 'span', array( 'class' => 'mw-email-agreement' ), wfMsg( 'donor-email-agreement' ) ) .
235 - Xml::closeElement( 'div' );
236 -
237 - $output .= Xml::fieldset( wfMsg( 'donor-comment-title' ), $publicComment, array( 'class' => 'mw-donation-public-comment' ) );
238 -
239 - $output .= Xml::hidden( 'process', '_yes_' ) .
240 - Xml::submitButton( wfMsg( 'donor-submit-button' ) );
241 -
242 - $output .= Xml::closeElement( 'form' );
243 -
244 -
245 - // NOTE: For testing: show country of origin
246 - //$country = fnDonateGetCountry();
247 - //$output .= Xml::element( 'p', array( 'class' => 'mw-donation-test-message' ), 'Country:' . $country );
248 -
249 - // NOTE: for testing: show default currency
250 - //$currencyTest = fnDonateDefaultCurrency();
251 - //$output .= Xml::element( 'p', array( 'class' => 'mw-donation-test-message' ), wfMsg( 'donor-currency' ) . $currencyTest );
252 -
253 - // NOTE: for testing: show IP address
254 - //$referrer = $_SERVER['HTTP_REFERER'];
255 - //$output .= '<p>' . 'Referrer:' . $referrer . '</p>';
256 -
257 - // for testing to show language culled from URL
258 - //$output .= '<p>' . ' Language: ' . $language . '</p>';
259 -
260 - return $output;
 128+ foreach( $currencies as $value => $fullName ) {
 129+ $currencyMenu .= Xml::option( $fullName, $value );
 130+ }
 131+
 132+ $output = Xml::openElement( 'form', array( 'name' => "donate", 'method' => "post", 'action' => "", 'onsubmit' => 'return DonateValidateForm(this)' )) .
 133+ Xml::openElement( 'div', array('id' => 'mw-donation-intro' )) .
 134+ Xml::element( 'p', array( 'class' => 'mw-donation-intro-text' ), wfMsg( 'donate_interface-intro' )) .
 135+ Xml::closeElement( 'div' );
 136+
 137+ $output .= Xml::hidden( 'utm_source', $utm_source ) .
 138+ Xml::hidden( 'utm_medium', $utm_medium ) .
 139+ Xml::hidden( 'utm_campaign', $utm_campaign ) .
 140+ Xml::hidden( 'language', $language ) .
 141+ Xml::hidden( 'referrer', $referrer );
 142+
 143+ $amount = array(
 144+ Xml::radioLabel(wfMsg( 'donate_interface-big-amount-display' ), 'amount', wfMsg( 'donate_interface-big-amount-value' ), 'input_amount_3', false ),
 145+ Xml::radioLabel(wfMsg( 'donate_interface-medium-amount-display' ), 'amount', wfMsg( 'donate_interface-medium-amount-value' ), 'input_amount_2', false ),
 146+ Xml::radioLabel(wfMsg( 'donate_interface-small-amount-display' ), 'amount', wfMsg( 'donate_interface-small-amount-value' ), 'input_amount_1', false ),
 147+ Xml::inputLabel(wfMsg( 'donate_interface-other-amount' ), 'amount2', 'input_amount_other', '5'),
 148+ );
 149+
 150+ $amountFields = '<table><tr>';
 151+ foreach( $amount as $value ) {
 152+ $amountFields .= '<td>' . $value . '</td>';
 153+ }
 154+ $amountFields .= '</tr></table>';
 155+
 156+ $output .= Xml::fieldset(wfMsg( 'donate_interface-amount' ), $amountFields, array('class' => "mw-donation-amount"));
 157+
 158+ // Build currency options
 159+ $default_currency = fnDonateDefaultCurrency();
 160+
 161+ $currency_options = '';
 162+ foreach ( $currencies as $code => $name ) {
 163+ $selected = '';
 164+ if ( $code == $default_currency ) {
 165+ $selected = ' selected="selected"';
 166+ }
 167+ $currency_options .= '<option value="' . $code . '"' . $selected . '>' . $name . '</option>';
 168+ }
 169+
 170+ $currencyFields = Xml::openElement( 'select', array( 'name' => 'currency_code', 'id' => "input_currency_code" )) .
 171+ $currency_options .
 172+ Xml::closeElement( 'select' );
 173+
 174+ $output .= Xml::fieldset(wfMsg( 'donate_interface-currency' ), $currencyFields, array('class' => "mw-donation-currency" ));
 175+
 176+ $gatewayFields = Xml::openElement( 'select', array('name' => 'payment_method', 'id' => 'select_payment_method')) .
 177+ $gatewayMenu .
 178+ Xml::closeElement('select');
 179+
 180+ $output .= Xml::fieldset(wfMsg( 'donate_interface-gateway' ), $gatewayFields, array( 'class' => 'mw-donation-gateway' ));
 181+
 182+ $publicComment = Xml::element( 'div', array( 'class' => 'mw-donation-comment-message'), wfMsg( 'donate_interface-comment-message' )) .
 183+ Xml::inputLabel(wfMsg( 'donate_interface-comment-label' ), 'comment', 'comment', '30', '', array( 'maxlength' => '200' )) .
 184+ Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' )) .
 185+ Xml::checkLabel( wfMsg( 'donate_interface-anon-message' ), 'comment-option', 'input_comment-option', TRUE ) .
 186+ Xml::closeElement( 'div' ) .
 187+ Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' )) .
 188+ Xml::check( 'opt', TRUE ) .
 189+ Xml::tags( 'span', array( 'class' => 'mw-email-agreement' ), wfMsg( 'donate_interface-email-agreement' )) .
 190+ Xml::closeElement( 'div' );
 191+
 192+ $output .= Xml::fieldset(wfMsg( 'donate_interface-comment-title' ), $publicComment, array( 'class' => 'mw-donation-public-comment'));
 193+
 194+ $output .= Xml::hidden( 'process', '_yes_' ) .
 195+ Xml::submitButton(wfMsg( 'donate_interface-submit-button' ));
 196+
 197+ $output .= Xml::closeElement( 'form' );
 198+
 199+ // NOTE: For testing: show country of origin
 200+ //$country = fnDonateGetCountry();
 201+ //$output .= Xml::element('p', array('class' => 'mw-donation-test-message'), 'Country:' . $country);
 202+
 203+ // NOTE: for testing: show default currency
 204+ //$currencyTest = fnDonateDefaultCurrency();
 205+ //$output .= Xml::element('p', array('class' => 'mw-donation-test-message'), wfMsg( 'donate_interface-currency' ) . $currencyTest);
 206+
 207+ // NOTE: for testing: show IP address
 208+ //$referrer = $_SERVER['HTTP_REFERER'];
 209+ //$output .= '<p>' . 'Referrer:' . $referrer . '</p>';
 210+
 211+ //for testing to show language culled from URL
 212+ $output .= '<p>' . ' Language: ' . $language . '</p>';
 213+
 214+ return $output;
261215 }
262216
263 -/**
264 - * Redirects user to their chosen payment processor
265 - *
266 - * Includes the user's input passed as GET
267 - * $url for the gateway was supplied with the gwPage hook and the key
268 - * matches the form value (also supplied by the gateway)
269 - */
270 -function redirectToProcessorPage( $userInput, $url ) {
271 - global $wgOut, $wgPaymentGatewayHost;
 217+/*
 218+* Redirects user to their chosen payment processor
 219+*
 220+* Includes the user's input passed as GET
 221+* $url for the gateway was supplied with the gwPage hook and the key
 222+* matches the form value (also supplied by the gateway)
 223+*/
 224+function fnDonateRedirectToProcessorPage($userInput, $url) {
 225+ global $wgOut,$wgPaymentGatewayHost;
 226+
 227+ $chosenGateway = $userInput['payment_method'];
272228
273 - $chosenGateway = $userInput['payment_method'];
274 -
275229 $wgOut->redirect(
276230 $wgPaymentGatewayHost . $url[$chosenGateway] . '&amount=' .
277231 $userInput['amount'] . '&currency_code=' . $userInput['currency'] .
@@ -329,9 +283,9 @@
330284 */
331285 function fnDonateChapterRedirect() {
332286 require_once( 'chapters.inc' );
 287+
 288+ $country_code = null;
333289
334 - $country_code = null;
335 -
336290 if( function_exists( 'fnGetCountry' ) ) {
337291 $country_code = fnDonateGetCountry();
338292 }
@@ -346,3 +300,66 @@
347301 }
348302
349303 }
 304+
 305+function fnProcessDonateForm( $output, $article, $title, $user, $request, $wiki ) {
 306+ global $wgRequest, $wgOut;
 307+
 308+ // declare variables used to hold post data
 309+ $userInput = array (
 310+ 'currency' => 'USD',
 311+ 'amount' => '0.00',
 312+ 'payment_method' => '',
 313+ 'referrer' => '',
 314+ 'utm_source' => '',
 315+ 'utm_medium' => '',
 316+ 'utm_campaign' => '',
 317+ 'language' => '',
 318+ 'comment' => '',
 319+ 'comment-option' => '',
 320+ 'email' => '',
 321+ );
 322+
 323+ // if form has been submitted, assign data and redirect user to chosen payment gateway
 324+ if ( isset($_POST['process']) && $_POST['process'] == "_yes_" ) {
 325+ //find out which amount option was chosen for amount, redefined buttons or text box
 326+ if ( isset($_POST['amount']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount')) ) {
 327+ $amount = number_format( $wgRequest->getText('amount'), 2 );
 328+ } elseif ( preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount2') )) {
 329+ $amount = number_format( $wgRequest->getText('amount2'), 2, '.', '' );
 330+ } else {
 331+ $wgOut->addHTML( wfMsg( 'donate_interface-amount-error' ) );
 332+ return true;
 333+ }
 334+
 335+ // create array of user input from post data
 336+ $userInput = array (
 337+ 'currency' => $wgRequest->getText( 'currency_code', 'USD' ),
 338+ 'amount' => $amount,
 339+ 'payment_method' => $wgRequest->getText( 'payment_method', 'payflow' ),
 340+ 'referrer' => $wgRequest->getText( 'referrer', '' ),
 341+ 'utm_source' => $wgRequest->getText( 'utm_source', '' ),
 342+ 'utm_medium' => $wgRequest->getText( 'utm_medium', '' ),
 343+ 'utm_campaign' => $wgRequest->getText( 'utm_campaign', '' ),
 344+ 'language' => $wgRequest->getText( 'language', 'en' ),
 345+ 'comment' => $wgRequest->getText( 'comment', '' ),
 346+ 'comment-option' => $wgRequest->getText( 'comment-option', '1' ),
 347+ 'email' => $wgRequest->getText( 'opt', '1' ),
 348+ );
 349+
 350+ // ask payment processor extensions for their URL/page title
 351+ $url = '';
 352+
 353+ if ( wfRunHooks('DonationInterface_Page', array(&$url)) ) {
 354+
 355+ // send user to correct page for payment
 356+ fnDonateRedirectToProcessorPage( $userInput, $url );
 357+
 358+ } else {
 359+ $wgOut->addHTML( wfMsg( 'donate_interface-processing-error' ) );
 360+ }
 361+
 362+ }// end if form has been submitted
 363+
 364+ return true;
 365+}
 366+
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js
@@ -0,0 +1,53 @@
 2+//<![CDATA[
 3+function DonateValidateForm( form ) {
 4+
 5+ var minimums = {
 6+ 'USD' : 1,
 7+ 'GBP' : 1, // $1.26
 8+ 'EUR' : 1, // $1.26
 9+ 'AUD' : 2, // $1.35
 10+ 'CAD' : 1, // $0.84
 11+ 'CHF' : 1, // $0.85
 12+ 'CZK' : 20, // $1.03
 13+ 'DKK' : 5, // $0.85
 14+ 'HKD' : 10, // $1.29
 15+ 'HUF' : 200, // $0.97
 16+ 'JPY' : 100, // $1
 17+ 'NZD' : 2, // $1.18
 18+ 'NOK' : 10, // $1.44
 19+ 'PLN' : 5, // $1.78
 20+ 'SGD' : 2, // $1.35
 21+ 'SEK' : 10, // $1.28
 22+ };
 23+
 24+ var error = true;
 25+
 26+ // Get amount selection
 27+ var amount = null;
 28+ for ( var i = 0; i < form.amount.length; i++ ) {
 29+ if ( form.amount[i].checked ) {
 30+ amount = form.amount[i].value;
 31+ }
 32+ }
 33+ if ( form.amount2.value != "" ) {
 34+ amount = form.amount2.value;
 35+ }
 36+ // Check amount is a real number
 37+ error = ( amount == null || isNaN( amount ) || amount.value <= 0 );
 38+ if ( error ) {
 39+ alert( 'You must enter a valid amount.' );
 40+ }
 41+
 42+ // Check amount is at least the minimum
 43+ var currency = form.currency_code[form.currency_code.selectedIndex].value;
 44+ if ( typeof( minimums[currency] ) == 'undefined' ) {
 45+ minimums[currency] = 1;
 46+ }
 47+ if ( amount < minimums[currency] ) {
 48+ alert( 'You must contribute at least $1'.replace('$1', minimums[currency] + ' ' + currency ) );
 49+ error = true;
 50+ }
 51+
 52+ return !error;
 53+}
 54+//]]>
Property changes on: trunk/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js
___________________________________________________________________
Added: svn:eol-style
155 + native
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.i18n.php
@@ -11,18 +11,26 @@
1212 /** English */
1313 $messages['en'] = array(
1414 'donate_interface' => 'Support Wikimedia',
15 - 'donate-desc' => 'Donation landing page that integrates gateway extensions',
16 - 'donor-intro' => 'Please choose a payment method, amount, and currency.',
17 - 'donor-amount' => 'Donation amount:',
18 - 'donor-other-amount' => 'Other amount',
19 - 'donor-currency' => 'Currency:',
20 - 'donor-gateway' => 'Payment method:',
21 - 'donor-submit-button' => 'Donate',
22 - 'donor-comment-message' => 'Have a thought to share with the world? Put up to 200 characters here:',
23 - 'donor-comment-label' => 'Comment:',
24 - 'donor-anon-message' => 'Please list my name (next to my comment) on the public donor list.',
25 - 'donor-email-agreement' => "I agree to receive future Wikimedia Foundation newsletters or e-mails.
 15+ 'donate_interface-desc' => 'Donation landing page that integrates gateway extensions',
 16+ 'donate_interface-intro' => 'Please choose a payment method, amount, and currency.',
 17+ 'donate_interface-amount' => 'Donation amount:',
 18+ 'donate_interface-other-amount' => 'Other amount',
 19+ 'donate_interface-currency' => 'Currency:',
 20+ 'donate_interface-gateway' => 'Payment method:',
 21+ 'donate_interface-submit-button' => 'Donate',
 22+ 'donate_interface-comment-message' => 'Have a thought to share with the world? Put up to 200 characters here:',
 23+ 'donate_interface-comment-label' => 'Comment:',
 24+ 'donate_interface-anon-message' => 'Please list my name (next to my comment) on the public donor list.',
 25+ 'donate_interface-email-agreement' => "I agree to receive future Wikimedia Foundation newsletters or e-mails.
2626 We will never sell or trade your information.
2727 Our donor privacy policy can be found <a title='Donate/Donor Privacy' href='/wiki/Donate/Donor_Privacy'>here</a>",
28 - 'donor-comment-title' => 'Public comment',
 28+ 'donate_interface-comment-title' => 'Public comment',
 29+ 'donate_interface-big-amount-display' => '$100',
 30+ 'donate_interface-medium-amount-display' => '$75',
 31+ 'donate_interface-small-amount-display' => '$30',
 32+ 'donate_interface-big-amount-value' => '100',
 33+ 'donate_interface-medium-amount-value' => '75',
 34+ 'donate_interface-small-amount-value' => '30',
 35+ 'donate_interface-amount-error' => '**Please enter a correct amount**',
 36+ 'donate_interface-processing-error' => 'There has been an error processing your request. No processor are available.',
2937 );
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -21,8 +21,10 @@
2222 $dir = dirname(__FILE__) . '/';
2323
2424 $wgAutoloadClasses['activemq_stomp'] = $dir . 'activemq_stomp.php'; # Tell MediaWiki to load the extension body.
25 -#$wgExtensionMessagesFiles['ActiveMQSTOMP'] = $dir . 'activemq_stomp.il8n.php';
2625
 26+//default variables that should be set in LocalSettings
 27+$wgStompServer = "";
 28+
2729 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
2830 $wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
2931 } else { // Otherwise do things the old fashioned way

Follow-up revisions

RevisionCommit summaryAuthorDate
r58315Follow-up to r58314siebrand14:51, 29 October 2009

Status & tagging log