r58868 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58867‎ | r58868 | r58869 >
Date:19:11, 10 November 2009
Author:diana
Status:ok (Comments)
Tags:
Comment:
javascript internationalization, database saving for tracking, amount field added, misc. other changes.
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/donate_interface/donate_interface.php (modified) (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/payflowpro_gateway/validate_input.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -1,16 +1,18 @@
22 //<![CDATA[
33
44 function validate_form( form ) {
5 - var msg = [ 'email address', 'first name', 'last name', 'street address', 'city', 'state', 'zip code', 'credit card number', 'the CVV from the back of your card' ];
 5+ var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
66
77 var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv"],
88 numFields = fields.length,
99 i,
10 - output = '';
 10+ output = '',
 11+ currField = '';
1112
1213 for( i = 0; i < numFields; i++ ) {
1314 if( document.getElementById( fields[i] ).value == '' ) {
14 - output += 'Please include a value for ' + msg[i] + '.\r\n';
 15+ currField = window['payflowproGatewayErrorMsg'+ msg[i]];
 16+ output += payflowproGatewayErrorMsgJs + currField + '.\r\n';
1517 }
1618 }
1719
@@ -19,7 +21,7 @@
2022 var dotpos = form.emailAdd.value.lastIndexOf(".");
2123
2224 if( apos < 1 || dotpos-apos < 2 ) {
23 - output += 'Please include a valid email address';
 25+ output += payflowproGatewayErrorMsgEmail;
2426 }
2527
2628 if( output ) {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -19,8 +19,27 @@
2020 global $wgRequest, $wgOut, $wgUser, $wgScriptPath;
2121
2222 $this->setHeaders();
 23+
 24+ //$wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" language="javascript" src="' . $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>' );
 25+
 26+ $scriptVars = array(
 27+ 'payflowproGatewayErrorMsgJs' => wfMsg( 'payflowpro_gateway-error-msg-js' ),
 28+ 'payflowproGatewayErrorMsgEmail' => wfMsg( 'payflowpro_gateway-error-msg-email' ),
 29+ 'payflowproGatewayErrorMsgAmount' => wfMsg( 'payflowpro_gateway-error-msg-amount' ),
 30+ 'payflowproGatewayErrorMsgEmailAdd' => wfMsg( 'payflowpro_gateway-error-msg-emailAdd' ),
 31+ 'payflowproGatewayErrorMsgFname' => wfMsg( 'payflowpro_gateway-error-msg-fname' ),
 32+ 'payflowproGatewayErrorMsgLname' => wfMsg( 'payflowpro_gateway-error-msg-lname' ),
 33+ 'payflowproGatewayErrorMsgStreet' => wfMsg( 'payflowpro_gateway-error-msg-street' ),
 34+ 'payflowproGatewayErrorMsgCity' => wfMsg( 'payflowpro_gateway-error-msg-city' ),
 35+ 'payflowproGatewayErrorMsgState' => wfMsg( 'payflowpro_gateway-error-msg-state' ),
 36+ 'payflowproGatewayErrorMsgZip' => wfMsg( 'payflowpro_gateway-error-msg-zip' ),
 37+ 'payflowproGatewayErrorMsgCardNum' => wfMsg( 'payflowpro_gateway-error-msg-card_num' ),
 38+ 'payflowproGatewayErrorMsgExpiration' => wfMsg( 'payflowpro_gateway-error-msg-expiration' ),
 39+ 'payflowproGatewayErrorMsgCvv' => wfMsg( 'payflowpro_gateway-error-msg-cvv' ),
 40+ );
 41+
2342
24 - $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" language="javascript" src="' . $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>' );
 43+ //$wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
2544
2645 // create token if one doesn't already exist
2746 $token = $wgUser->editToken( 'mrxc877668DwQQ' );
@@ -61,14 +80,17 @@
6281 if( isset( $_REQUEST['amount'] ) && preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount' ) ) ) {
6382 $amount = $wgRequest->getText( 'amount' );
6483 } elseif( isset( $_REQUEST['amount2'] ) && preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount2' ) ) ) {
65 - $amount = number_format( $wgRequest->getText( 'amount2' ), 2, '.', '' );
 84+ $amount = number_format( $wgRequest->getText( 'amount2' ), 2, '.', '' );
 85+ } elseif( isset( $_REQUEST['amount'] ) ) {
 86+ $amount = '0.00';
6687 } else {
67 - $wgOut->addHTML( wfMsg( 'payflowpro_gateway-accessible' ) );
68 - return;
 88+ $wgOut->addHTML( wfMsg( 'payflowpro_gateway-accessible' ) );
 89+ return;
6990 }
70 -
 91+
7192 // track the number of attempts the user has made
7293 $numAttempt = ( $wgRequest->getText( 'numAttempt' ) == '' ) ? '0' : $wgRequest->getText( 'numAttempt' );
 94+
7395 // Populate from data
7496 $data = array(
7597 'amount' => $amount,
@@ -87,7 +109,7 @@
88110 'cvv' => $wgRequest->getText( 'cvv' ),
89111 'currency' => $wgRequest->getText( 'currency_code' ),
90112 'payment_method' => $wgRequest->getText( 'payment_method' ),
91 - 'order-id' => null, //will be set with $payflow_data
 113+ 'order_id' => null, //will be set with $payflow_data
92114 'numAttempt' => $numAttempt,
93115 'referrer' => $wgRequest->getText( 'referrer' ),
94116 'utm_source' => $wgRequest->getText( 'utm_source' ),
@@ -99,6 +121,7 @@
100122 'optout' => $wgRequest->getText( 'email' ),
101123 'test_string' => $wgRequest->getText( 'process' ), //for showing payflow string during testing
102124 );
 125+
103126
104127 // Get array of default account values necessary for Payflow
105128 require_once( 'includes/payflowUser.inc' );
@@ -128,7 +151,8 @@
129152 //Display form for the first time
130153 $this->fnPayflowDisplayForm($data, $error);
131154 }
132 - }
 155+ }
 156+
133157 }
134158
135159 /**
@@ -144,24 +168,14 @@
145169 require_once( 'includes/countryCodes.inc' );
146170
147171 global $wgOut, $wgLang;
148 -
 172+
149173 $form = Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ) .
150174 Xml::openElement( 'div', array( 'id' => 'mw-creditcard-intro' ) ) .
151175 Xml::tags( 'p', array( 'class' => 'mw-creditcard-intro-msg' ), wfMsg( 'payflowpro_gateway-form-message' ) ) .
152176 Xml::tags( 'p', array( 'class' => 'mw-creditcard-intro-msg' ), wfMsg( 'payflowpro_gateway-form-message-2' ) ) .
153177 Xml::closeElement( 'div' );
154178
155 - // add hidden fields
156 - $form .= Xml::hidden( 'utm_source', $data['utm_source'] ) .
157 - Xml::hidden( 'utm_medium', $data['utm_medium'] ) .
158 - Xml::hidden( 'utm_campaign', $data['utm_campaign'] ) .
159 - Xml::hidden( 'language', $data['language'] ) .
160 - Xml::hidden( 'referrer', $data['referrer'] ) .
161 - Xml::hidden( 'comment', $data['comment'] ) .
162 - Xml::hidden( 'comment-option', $data['anonymous'] ) .
163 - Xml::hidden( 'email', $data['optout'] );
164 -
165 - // create drop down of countries
 179+ // create drop down of countries
166180 $countries = countryCodes();
167181
168182 foreach( $countries as $value => $fullName ) {
@@ -170,11 +184,20 @@
171185
172186 // Form
173187 $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ) .
174 - Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)' ) ) .
175 - Xml::element( 'legend', array( 'class' => 'mw-creditcard-amount' ), wfMsg( 'payflowpro_gateway-amount-legend' ) . $data['amount'] ) .
176 - Xml::hidden( 'amount', $data['amount'] );
 188+ Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)' ) );
 189+
 190+ // add hidden fields
 191+ $form .= Xml::hidden( 'utm_source', $data['utm_source'] ) .
 192+ Xml::hidden( 'utm_medium', $data['utm_medium'] ) .
 193+ Xml::hidden( 'utm_campaign', $data['utm_campaign'] ) .
 194+ Xml::hidden( 'language', $data['language'] ) .
 195+ Xml::hidden( 'referrer', $data['referrer'] ) .
 196+ Xml::hidden( 'comment', $data['comment'] ) .
 197+ Xml::hidden( 'comment-option', $data['anonymous'] ) .
 198+ Xml::hidden( 'email', $data['optout'] );
177199
178200 $donorInput = array(
 201+ Xml::inputLabel(wfMsg( 'payflowpro_gateway-amount-legend' ), 'amount', 'input_amount_other', '7', $data['amount'] ) . '<span class="creditcard_error_msg">' . ' ' . $error['invalidamount'] . '</span>',
179202 Xml::inputLabel( wfMsg( 'payflowpro_gateway-donor-email' ), 'emailAdd', 'emailAdd', '30', $data['email'], array( 'maxlength' => '64' ) ) . '<span class="creditcard_error_msg">' . ' ' . $error['emailAdd'] . '</span>',
180203 Xml::inputLabel( wfMsg( 'payflowpro_gateway-donor-fname' ), 'fname', 'fname', '20', $data['fname'], array( 'maxlength' => '15', 'class' => 'required' ) ) . '<span class="creditcard_error_msg">' . ' ' . $error['fname'] . '</span>',
181204 Xml::inputLabel( wfMsg( 'payflowpro_gateway-donor-mname' ), 'mname', 'mname', '20', $data['mname'], array( 'maxlength' => '15' ) ),
@@ -272,7 +295,7 @@
273296 wfMsg( 'payflowpro_gateway-donor-currency-msg', $data['currency'] )
274297 );
275298 // Theming
276 - global $wgDonationInterfaceTomasSkin;
 299+ /*global $wgDonationInterfaceTomasSkin;
277300
278301 if ( $wgDonationInterfaceTomasSkin ) {
279302 $language = 'en';
@@ -297,6 +320,8 @@
298321 } else {
299322 $wgOut->addHTML( $form );
300323 }
 324+ */
 325+ $wgOut->addHTML( $form );
301326 }
302327
303328 /**
@@ -304,6 +329,8 @@
305330 */
306331 private function fnPayflowValidateForm( $data, &$error ) {
307332 global $wgOut;
 333+
 334+ $error = '';
308335
309336 // begin with no errors
310337 $error_result = '0';
@@ -311,17 +338,17 @@
312339 // create the human-speak message for required fields
313340 // does not include fields that are not required
314341 $msg = array(
315 - 'amount' => 'donation amount',
316 - 'emailAdd' => 'email address',
317 - 'fname' => 'first name',
318 - 'lname' => 'last name',
319 - 'street' => 'street address',
320 - 'city' => 'city',
321 - 'state' => 'state',
322 - 'zip' => 'zip code',
323 - 'card_num' => 'credit card number',
324 - 'expiration' => "card's expiration date",
325 - 'cvv' => 'the CVV from the back of your card',
 342+ 'amount' => wfMsg( 'payflowpro_gateway-error-msg-amount' ),
 343+ 'emailAdd' => wfMsg( 'payflowpro_gateway-error-msg-emailAdd' ),
 344+ 'fname' => wfMsg( 'payflowpro_gateway-error-msg-fname' ),
 345+ 'lname' => wfMsg( 'payflowpro_gateway-error-msg-lname' ),
 346+ 'street' => wfMsg( 'payflowpro_gateway-error-msg-street' ),
 347+ 'city' => wfMsg( 'payflowpro_gateway-error-msg-city' ),
 348+ 'state' => wfMsg( 'payflowpro_gateway-error-msg-state' ),
 349+ 'zip' => wfMsg( 'payflowpro_gateway-error-msg-zip' ),
 350+ 'card_num' => wfMsg( 'payflowpro_gateway-error-msg-card_num' ),
 351+ 'expiration' => wfMsg( 'payflowpro_gateway-error-msg-expiration' ),
 352+ 'cvv' => wfMsg( 'payflowpro_gateway-error-msg-cvv' ),
326353 );
327354
328355 // find all empty fields and create message
@@ -334,7 +361,13 @@
335362 }
336363 }
337364 }
338 -
 365+
 366+ //check amount
 367+ if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data['amount'] ) || $data['amount'] == "0.00" ) {
 368+ $error['invalidamount'] = wfMsg( 'payflowpro_gateway-error-msg-invalid-amount' );
 369+ $error_result = '1';
 370+ }
 371+
339372 // is email address valid?
340373 $isEmail = User::isValidEmailAddr( $data['email'] );
341374
@@ -343,15 +376,15 @@
344377 $error['emailAdd'] = wfMsg( 'payflowpro_gateway-error-msg-email' );
345378 $error_result = '1';
346379 }
347 -
 380+
348381 // validate that credit card number entered is correct for the brand
349382 switch( $data['card'] ) {
350383 case 'american':
351384 // pattern for Amex
352 - $pattern = "/^3[47][0-9]{13}$/";
 385+ $pattern = '/^3[47][0-9]{13}$/';
353386
354387 // if the pattern doesn't match
355 - if( !preg_match( $pattern, $data['card_num'] ) ) {
 388+ if( !preg_match( $pattern, $data['card_num'] ) ) {
356389 $error_result = '1';
357390 $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-amex' );
358391 }
@@ -360,7 +393,7 @@
361394
362395 case 'mastercard':
363396 // pattern for Mastercard
364 - $pattern = "/^5[1-5][0-9]{14}$/";
 397+ $pattern = '/^5[1-5][0-9]{14}$/';
365398
366399 // if pattern doesn't match
367400 if( !preg_match( $pattern, $data['card_num'] ) ) {
@@ -372,7 +405,7 @@
373406
374407 case 'visa':
375408 // pattern for Visa
376 - $pattern = "/^4[0-9]{12}(?:[0-9]{3})?$/";
 409+ $pattern = '/^4[0-9]{12}(?:[0-9]{3})?$/';
377410
378411 // if pattern doesn't match
379412 if( !preg_match( $pattern, $data['card_num'] ) ) {
@@ -381,8 +414,9 @@
382415 }
383416
384417 break;
 418+
385419 } // end switch
386 -
 420+
387421 return $error_result;
388422 }
389423
@@ -398,24 +432,24 @@
399433
400434 // create payflow query string, include string lengths
401435 $queryArray = array(
402 - 'TRXTYPE' => $payflow_data[trxtype],
403 - 'TENDER' => $payflow_data[tender],
404 - 'USER' => $payflow_data[user],
405 - 'VENDOR' => $payflow_data[vendor],
406 - 'PARTNER' => $payflow_data[partner],
407 - 'PWD' => $payflow_data[password],
408 - 'ACCT' => $data[card_num],
409 - 'EXPDATE' => $data[expiration],
410 - 'AMT' => $data[amount],
411 - 'FIRSTNAME' => $data[fname],
412 - 'LASTNAME' => $data[lname],
413 - 'STREET' => $data[street],
414 - 'ZIP' => $data[zip],
415 - 'INVNUM' => $payflow_data[order_id],
416 - 'CVV2' => $data[cvv],
417 - 'CURRENCY' => $data[currency],
418 - 'VERBOSITY' => $payflow_data[verbosity],
419 - 'CUSTIP' => $payflow_data[user_ip],
 436+ 'TRXTYPE' => $payflow_data['trxtype'],
 437+ 'TENDER' => $payflow_data['tender'],
 438+ 'USER' => $payflow_data['user'],
 439+ 'VENDOR' => $payflow_data['vendor'],
 440+ 'PARTNER' => $payflow_data['partner'],
 441+ 'PWD' => $payflow_data['password'],
 442+ 'ACCT' => $data['card_num'],
 443+ 'EXPDATE' => $data['expiration'],
 444+ 'AMT' => $data['amount'],
 445+ 'FIRSTNAME' => $data['fname'],
 446+ 'LASTNAME' => $data['lname'],
 447+ 'STREET' => $data['street'],
 448+ 'ZIP' => $data['zip'],
 449+ 'INVNUM' => $payflow_data['order_id'],
 450+ 'CVV2' => $data['cvv'],
 451+ 'CURRENCY' => $data['currency'],
 452+ 'VERBOSITY' => $payflow_data['verbosity'],
 453+ 'CUSTIP' => $payflow_data['user_ip'],
420454 );
421455
422456 foreach( $queryArray as $name => $value ) {
@@ -436,10 +470,10 @@
437471 $headers[] = 'Content-Length : ' . strlen( $payflow_query );
438472 $headers[] = 'X-VPS-Client-Timeout: 45';
439473 $headers[] = 'X-VPS-Request-ID:' . $payflow_data['order_id'];
440 -
441474 $ch = curl_init();
442475 $paypalPostTo = isset ( $wgDonationTestingMode ) ? 'testingurl' : 'paypalurl';
443 - curl_setopt( $ch, CURLOPT_URL, $payflow_data[ $paypalPostTo ] );
 476+ //curl_setopt( $ch, CURLOPT_URL, $payflow_data[ $paypalPostTo ] );
 477+ curl_setopt($ch, CURLOPT_URL, $payflow_data['testingurl']);
444478 curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
445479 curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent );
446480 curl_setopt( $ch, CURLOPT_HEADER, 1 );
@@ -528,13 +562,13 @@
529563 // give user a second chance to enter incorrect data
530564 } elseif( ( $errorCode == '3' ) && ( $data['numAttempt'] < '2' ) ) {
531565 // pass responseMsg as an array key as required by displayForm
532 - $tryAgainResponse[$responseMsg] = $responseMsg;
533 - $this->fnPayflowDisplayForm( $data, $tryAgainResponse );
 566+ $tryAgainResponse[$responseMsg] = $responseMsg;
 567+ $this->fnPayflowDisplayForm( $data, $tryAgainResponse );
534568 // if declined or if user has already made two attempts, decline
535569 } elseif( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '2' ) ) {
536 - $this->fnPayflowDisplayDeclinedResults( $responseMsg );
 570+ $this->fnPayflowDisplayDeclinedResults( $responseMsg );
537571 } elseif( ( $errorCode == '4' ) ) {
538 - $this->fnPayflowDisplayOtherResults( $responseMsg );
 572+ $this->fnPayflowDisplayOtherResults( $responseMsg );
539573 }
540574
541575 }// end display results
@@ -608,8 +642,16 @@
609643 function fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ) {
610644 global $wgOut;
611645 $transaction = '';
 646+ $tracked = '';
612647
613648 require_once( 'includes/countryCodes.inc' );
 649+
 650+ //save data to the contribution tracking database
 651+ if ( !$tracked = $this->fnPayflowSaveContributionTracking( $data ) ) {
 652+ $when = time();
 653+ wfDebugLog( 'payflowpro_gateway', 'Unable to save data to the contribution_tracking table ' . $when );
 654+ }
 655+
614656
615657 // display response message
616658 $wgOut->addHTML( '<h3 class="response_message">' . $responseMsg . '</h3>' );
@@ -638,6 +680,10 @@
639681 $transaction['country_code'] = $data['country'];
640682 // put all data into one array
641683 $transaction += array_merge( $data, $responseArray );
 684+
 685+ //enable if we need this to get the Civi data to display correctly
 686+ $transaction['optout'] = ($transaction['optout'] == "1") ? '0' : '1';
 687+ $transaction['anonymous'] = ($transaction['anonymous'] == "1") ? '0' : '1';
642688
643689 // hook to call stomp functions
644690 wfRunHooks( 'gwStomp', array( &$transaction ) );
@@ -672,5 +718,39 @@
673719 // display response message
674720 $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . $responseMsg . '</h3>' );
675721 }
 722+
 723+ function fnPayflowSaveContributionTracking( $data ) {
 724+ $db = payflowGatewayConnection();
 725+
 726+ if (!$db) { return true ; }
676727
 728+ $ts = $db->timestamp();
 729+
 730+ $tracked_contribution = array(
 731+ 'note' => $data['comment'],
 732+ 'referrer' => $data['referrer'],
 733+ 'anonymous' => $data['anonymous'],
 734+ 'utm_source' => $data['utm_source'],
 735+ 'utm_medium' => $data['utm_medium'],
 736+ 'utm_campaign' => $data['utm_campaign'],
 737+ 'optout' => $data['optout'],
 738+ 'language' => $data['language'],
 739+ 'ts' => $ts,
 740+ );
 741+
 742+ // Make all empty strings NULL
 743+ foreach ($tracked_contribution as $key => $value) {
 744+ if ($value === '') {
 745+ $tracked_contribution[$key] = NULL;
 746+ }
 747+ }
 748+
 749+ // Store the contribution data
 750+ if ($db->insert( 'contribution_tracking', $tracked_contribution ) ) {
 751+ return true;
 752+ } else { return false; }
 753+
 754+ }
 755+
 756+
677757 } // end class
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -38,10 +38,23 @@
3939 'payflowpro_gateway-donor-submit' => 'Donate',
4040 'payflowpro_gateway-donor-currency-msg' => 'This donation is being made in $1',
4141 'payflowpro_gateway-error-msg' => 'Please enter your $1',
 42+ 'payflowpro_gateway-error-msg-js' => 'Please enter your ',
 43+ 'payflowpro_gateway-error-msg-invalid-amount' => '**Please enter a valid amount**',
4244 'payflowpro_gateway-error-msg-email' => '**Please enter a valid e-mail address**',
4345 'payflowpro_gateway-error-msg-amex' => '**Please enter a correct card number for American Express.**',
4446 'payflowpro_gateway-error-msg-mc' => '**Please enter a correct card number for MasterCard.**',
4547 'payflowpro_gateway-error-msg-visa' => '**Please enter a correct card number for Visa.**',
 48+ 'payflowpro_gateway-error-msg-amount' => 'donation amount',
 49+ 'payflowpro_gateway-error-msg-emailAdd' => 'email address',
 50+ 'payflowpro_gateway-error-msg-fname' => 'first name',
 51+ 'payflowpro_gateway-error-msg-lname' => 'last name',
 52+ 'payflowpro_gateway-error-msg-street' => 'street address',
 53+ 'payflowpro_gateway-error-msg-city' => 'city',
 54+ 'payflowpro_gateway-error-msg-state' => 'state',
 55+ 'payflowpro_gateway-error-msg-zip' => 'zip code',
 56+ 'payflowpro_gateway-error-msg-card_num' => 'credit card number',
 57+ 'payflowpro_gateway-error-msg-expiration' => "card's expiration date",
 58+ 'payflowpro_gateway-error-msg-cvv' => 'the CVV from the back of your card',
4659 'payflowpro_gateway-response-0' => 'Your transaction has been approved.
4760 Thank you for your donation!',
4861 'payflowpro_gateway-response-126' => 'Your transaction is pending approval.',
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -35,6 +35,29 @@
3636 $wgPayflowProUserID = ''; //if one or more users are set up, authorized user ID, else same as VENDOR
3737 $wgPayflowProPassword = ''; //merchant login password
3838
 39+$wgPayflowGatewayDBserver = $wgDBserver;
 40+$wgPayflowGatewayDBname = $wgDBname;
 41+$wgPayflowGatewayDBuser = $wgDBuser;
 42+$wgPayflowGatewayDBpassword = $wgDBpassword;
 43+
 44+function payflowGatewayConnection() {
 45+ global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
 46+ global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
 47+
 48+ static $db;
 49+
 50+ if ( !$db ) {
 51+ $db = new DatabaseMysql(
 52+ $wgPayflowGatewayDBserver,
 53+ $wgPayflowGatewayDBuser,
 54+ $wgPayflowGatewayDBpassword,
 55+ $wgPayflowGatewayDBname );
 56+ $db->query( "SET names utf8" );
 57+ }
 58+
 59+ return $db;
 60+}
 61+
3962 /**
4063 * Hooks required to interface with the donation extension (include <donate> on page)
4164 *
@@ -88,7 +111,8 @@
89112 function pfpGatewayPage( &$url ) {
90113 global $wgScript;
91114
92 - $url['payflow'] = 'https://payments.wikimedia.org/index.php' . '?title=Special:PayflowProGateway';
93 -
 115+ //$url['payflow'] = 'https://payments.wikimedia.org/index.php' . '?title=Special:PayflowProGateway';
 116+ //$url['payflow'] = 'http://c2p2.fkbuild.com/index.php?title=Special:PayflowProGateway';
 117+ $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
94118 return true;
95119 }
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php
@@ -27,13 +27,13 @@
2828 $wgExtensionMessagesFiles['DonateInterface'] = $dir . 'donate_interface.i18n.php';
2929
3030 $wgHooks['ParserFirstCallInit'][] = 'efDonateSetup';
31 -$wgHooks['MediaWikiPerformAction'][] = 'fnProcessDonateForm';
 31+$wgHooks['DonationInterface_DisplayForm'][] = 'fnProcessDonationForm';
3232
3333 /**
3434 * Create <donate /> tag to include landing page donation form
3535 */
3636 function efDonateSetup( &$parser ) {
37 - global $wgHooks;
 37+ global $wgHooks, $wgRequest;
3838
3939 //load extension messages
4040 wfLoadExtensionMessages( 'DonateInterface' );
@@ -41,14 +41,15 @@
4242 $parser->disableCache();
4343
4444 $parser->setHook( 'donate', 'efDonateRender' );
45 -
 45+
4646 //process form
47 - wfRunHooks( 'MediaWikiPerformAction', array( $output,
48 -$article, $title, $user, $request, $this));
 47+ wfRunHooks( 'DonationInterface_DisplayForm' );
4948
5049 return true;
5150 }
5251
 52+
 53+
5354 /**
5455 * Function called by the <donate> parser tag
5556 *
@@ -61,7 +62,8 @@
6263 $parser->disableCache();
6364
6465 // if chapter exists for user's country, redirect
65 - $chapter = fnDonateChapterRedirect();
 66+ //not currently in use - in place for adding it when ready
 67+ //$chapter = fnDonateChapterRedirect();
6668
6769 // add JavaScript validation to <head>
6870 $wgOut->addScriptFile( $wgScriptPath . '/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js' );
@@ -139,7 +141,8 @@
140142 Xml::hidden( 'utm_medium', $utm_medium ) .
141143 Xml::hidden( 'utm_campaign', $utm_campaign ) .
142144 Xml::hidden( 'language', $language ) .
143 - Xml::hidden( 'referrer', $referrer );
 145+ Xml::hidden( 'referrer', $referrer ) .
 146+ XML::hidden('process', '_yes_');
144147
145148 $amount = array(
146149 Xml::radioLabel(wfMsg( 'donate_interface-big-amount-display' ), 'amount', wfMsg( 'donate_interface-big-amount-value' ), 'input_amount_3', false ),
@@ -234,8 +237,8 @@
235238
236239 $wgOut->redirect(
237240 $url[$chosenGateway] . '&' . $redirectionData
238 - );
239 -
 241+ );
 242+
240243 }
241244
242245 /**
@@ -302,7 +305,7 @@
303306
304307 }
305308
306 -function fnProcessDonateForm( $output, $article, $title, $user, $request, $wiki ) {
 309+function fnProcessDonationForm( ) {
307310 global $wgRequest, $wgOut;
308311
309312 // declare variables used to hold post data
@@ -320,8 +323,8 @@
321324 'email' => '',
322325 );
323326
324 - // if form has been submitted, assign data and redirect user to chosen payment gateway
325 - if ( $wgRequest->wasPosted() ) {
 327+ // if form has been submitted, assign data and redirect user to chosen payment gateway
 328+ if ($_POST['process'] == "_yes_") {
326329 //find out which amount option was chosen for amount, redefined buttons or text box
327330 if ( isset($_POST['amount']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount')) ) {
328331 $amount = number_format( $wgRequest->getText('amount'), 2 );
@@ -351,7 +354,7 @@
352355 $url = '';
353356
354357 if ( wfRunHooks('DonationInterface_Page', array(&$url)) ) {
355 -
 358+
356359 // send user to correct page for payment
357360 fnDonateRedirectToProcessorPage( $userInput, $url );
358361
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -71,6 +71,7 @@
7272 global $wgStompServer, $wgStompQueueName;
7373
7474 $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test';
 75+
7576 // include a library
7677 require_once("Stomp.php");
7778

Follow-up revisions

RevisionCommit summaryAuthorDate
r58869Follow-up r58868: i18n tweak for consistency....raymond19:22, 10 November 2009

Comments

#Comment by Tim Starling (talk | contribs)   05:06, 17 December 2009

The code commented out here was restored in r58922.

Status & tagging log