r57999 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57998‎ | r57999 | r58000 >
Date:13:03, 22 October 2009
Author:diana
Status:resolved (Comments)
Tags:
Comment:
Added more data collection to process, get lang from URL, Paypal submits to ContributionTracking, tweaks
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/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (modified) (history)
  • /trunk/extensions/DonationInterface/paypal_gateway/paypal_gateway.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -4,7 +4,7 @@
55 {
66 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' ];
77
8 - var fields = ["email","fname","lname","street","city","state","zip","card_num","cvv"],
 8+ var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv"],
99 numFields = fields.length,
1010 i,
1111 output = '';
@@ -19,8 +19,8 @@
2020 }
2121
2222 // validate email address
23 - var apos=form.email.value.indexOf("@");
24 - var dotpos=form.email.value.lastIndexOf(".");
 23+ var apos=form.emailAdd.value.indexOf("@");
 24+ var dotpos=form.emailAdd.value.lastIndexOf(".");
2525
2626 if (apos<1||dotpos-apos<2)
2727 {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -39,6 +39,14 @@
4040 'payment_method' => '',
4141 'order_id' => '',
4242 'numAttempt' => '',
 43+ 'referrer' => '',
 44+ 'utm_source' => '',
 45+ 'utm_medium' => '',
 46+ 'utm_campaign' => '',
 47+ 'language' => '',
 48+ 'comment' => '',
 49+ 'anonymous' => '',
 50+ 'optout' => '',
4351 'token' => $token,
4452 );
4553
@@ -59,7 +67,7 @@
6068 // Populate from data
6169 $data = array(
6270 'amount' => $amount,
63 - 'email' => $wgRequest->getText('email'),
 71+ 'email' => $wgRequest->getText('emailAdd'),
6472 'fname' => $wgRequest->getText('fname'),
6573 'mname' => $wgRequest->getText('mname'),
6674 'lname' => $wgRequest->getText('lname'),
@@ -76,6 +84,14 @@
7785 'payment_method' => $wgRequest->getText('payment_method'),
7886 'order-id' => NULL, //will be set with $payflow_data
7987 'numAttempt' => $numAttempt,
 88+ 'referrer' => $wgRequest->getText('referrer'),
 89+ 'utm_source' => $wgRequest->getText('utm_source'),
 90+ 'utm_medium' => $wgRequest->getText('utm_medium'),
 91+ 'utm_campaign' => $wgRequest->getText('utm_campaign'),
 92+ 'language' => $wgRequest->getText('language'),
 93+ 'comment' => $wgRequest->getText('comment'),
 94+ 'anonymous' => $wgRequest->getText('comment-option'),
 95+ 'optout' => $wgRequest->getText('email'),
8096 'test_string' => $wgRequest->getText('process'), //for showing payflow string during testing
8197 );
8298
@@ -131,19 +147,17 @@
132148 XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message' )) .
133149 XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message-2' )) .
134150 XML::closeElement('div');
135 -
136 - //show error messages if they exist
137 - if (!empty($error)) {
138 - //add styling
139 - $form .= '<div class="creditcard_error">';
140 -
141 - foreach($error as $key) {
142 - $form .= '<p class="creditcard_error_msg">'.$key.'</p>';
143 - }
144 -
145 - $form .= '</div>';
146 - }
147 -
 151+
 152+ //add hidden fields
 153+ $form .= XML::hidden("utm_source", $data['utm_source']) .
 154+ XML::hidden("utm_medium", $data['utm_medium']) .
 155+ XML::hidden("utm_campaign", $data['utm_campaign']) .
 156+ XML::hidden("language", $data['language']) .
 157+ XML::hidden("referrer", $data['referrer']) .
 158+ XML::hidden("comment", $data['comment']) .
 159+ XML::hidden("comment-option", $data['anonymous']) .
 160+ XML::hidden("email", $data['optout']);
 161+
148162 //create drop down of countries
149163 $countries = countryCodes();
150164
@@ -158,21 +172,21 @@
159173 XML::hidden('amount', $data['amount']);
160174
161175 $donorInput = array(
162 - XML::inputLabel(wfMsg( 'pfp-donor-email' ), "email", "email", "30", $data['email'], array('maxlength' => "150")),
163 - XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')),
 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>',
164178 XML::inputLabel(wfMsg( 'pfp-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")),
165 - XML::inputLabel(wfMsg( 'pfp-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")),
166 - XML::inputLabel(wfMsg( 'pfp-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")),
167 - XML::inputLabel(wfMsg( 'pfp-donor-city' ), "city", "city", "20", $data['city'], 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>',
168182 XML::label(wfMsg( 'pfp-donor-state' ), "state") .
169183 XML::openElement('select', array('name' => "state", 'id' => "state", 'value' => $data['state'])) .
170184 statesMenuXML() .
171 - XML::closeElement('select'),
172 - XML::inputLabel(wfMsg( 'pfp-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "18")),
 185+ 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>',
173187 XML::label(wfMsg( 'pfp-donor-country' ), "country") .
174188 XML::openElement('select', array('name' => "country", 'id' => "country", 'value' => $data['country'])) .
175189 $countryMenu .
176 - XML::closeElement('select')
 190+ XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['country'].'</span>'
177191 );
178192
179193 $donorField = "";
@@ -227,9 +241,9 @@
228242 XML::openElement('select', array('name' => "card", 'id' => "card")) .
229243 $cardOptionsMenu .
230244 XML::closeElement('select'),
231 - XML::inputLabel(wfMsg( 'pfp-donor-card-num' ), "card_num", "card_num", "30", '', array('maxlength' => "100")),
 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>',
232246 $expMosMenu . $expYrMenu,
233 - XML::inputLabel(wfMsg( 'pfp-donor-security' ), "cvv", "cvv", "5", '', array('maxlength' => "10")),
 247+ XML::inputLabel(wfMsg( 'pfp-donor-security' ), "cvv", "cvv", "5", '', array('maxlength' => "10")) . '<span class="creditcard_error_msg">'. " " . $error['cvv'].'</span>',
234248 );
235249
236250 foreach($cardInput as $value) {
@@ -267,7 +281,7 @@
268282 //does not include fields that are not required
269283 $msg = array(
270284 'amount' => "donation amount",
271 - 'email' => "email address",
 285+ 'emailAdd' => "email address",
272286 'fname' => "first name",
273287 'lname' => "last name",
274288 'street' => "street address",
@@ -295,7 +309,7 @@
296310
297311 //create error message (supercedes empty field message)
298312 if (!$isEmail) {
299 - $error['email'] = wfMsg ( 'pfp-error-msg-email' );
 313+ $error['emailAdd'] = wfMsg ( 'pfp-error-msg-email' );
300314 $error_result = '1';
301315 }
302316
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -8,52 +8,49 @@
99 $messages = array();
1010
1111 $messages['en'] = array(
12 - 'payflowprogateway' => 'Support Wikimedia',
13 - '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.
16 -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.
45 -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.
49 -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.
57 -Please try again later.',
58 - 'php-response-declined' => 'Your transaction has been declined.',
59 - 'pfp-post-transaction' => 'Transaction details',
 12+ 'payflowprogateway' => 'Support Wikimedia',
 13+ '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.
 16+Th ere 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. Thank you for your donation!',
 45+ 'pfp-response-126' => 'Your transaction is pending approval.',
 46+ 'pfp-response-12' => 'Please contact your credit card company for further information.',
 47+ 'pfp-response-13' => 'Your transaction requires voice authorization. Please contact us to continue your transaction.', // This will not apply to WikiMedia accounts
 48+ 'pfp-response-114' => 'Please contact your credit card company for further information.',
 49+ 'pfp-response-23' => 'Your credit card number or expiration date is incorrect.',
 50+ 'pfp-response-4' => 'Invalid amount.',
 51+ 'pfp-response-24' => 'Your credit card number or expiration date is incorrect.',
 52+ 'pfp-response-112' => 'Your address or CVV number (security code) is incorrect.',
 53+ 'pfp-response-125' => 'Your transaction has been declined by Fraud Prevention Services.',
 54+ 'pfp-response-default' => 'There was an error processing your transaction. Please try again later.',
 55+ 'php-response-declined' => 'Your transaction has been declined.',
 56+ 'pfp-post-transaction' => 'Transaction details',
6057 );
Index: trunk/extensions/DonationInterface/paypal_gateway/paypal_gateway.php
@@ -36,32 +36,32 @@
3737 */
3838 function paypalGatewayValue(&$values) {
3939
40 - $values['paypal'] = array(
41 - 'gateway' => "paypal",
42 - 'display_name' => "Paypal",
43 - 'form_value' => "paypal",
44 - 'currencies' => array(
45 - 'GBP' => "GBP: British Pound",
46 - 'EUR' => "EUR: Euro",
47 - 'USD' => "USD: U.S. Dollar",
48 - 'AUD' => "AUD: Australian Dollar",
49 - 'CAD' => "CAD: Canadian Dollar",
50 - 'CHF' => "CHF: Swiss Franc",
51 - 'CZK' => "CZK: Czech Koruna",
52 - 'DKK' => "DKK: Danish Krone",
53 - 'HKD' => "HKD: Hong Kong Dollar",
54 - 'HUF' => "HUF: Hungarian Forint",
55 - 'JPY' => "JPY: Japanese Yen",
56 - 'NZD' => "NZD: New Zealand Dollar",
57 - 'NOK' => "NOK: Norwegian Krone",
58 - 'PLN' => "PLN: Polish Zloty",
59 - 'SGD' => "SGD: Singapore Dollar",
60 - 'SEK' => "SEK: Swedish Krona",
61 - 'ILS' => "ILS: Israeli Shekel",
62 - ),
63 - );
64 -
65 - return true;
 40+ $values['paypal'] = array(
 41+ 'gateway' => "paypal",
 42+ 'display_name' => "Paypal",
 43+ 'form_value' => "paypal",
 44+ 'currencies' => array(
 45+ 'GBP' => "GBP: British Pound",
 46+ 'EUR' => "EUR: Euro",
 47+ 'USD' => "USD: U.S. Dollar",
 48+ 'AUD' => "AUD: Australian Dollar",
 49+ 'CAD' => "CAD: Canadian Dollar",
 50+ 'CHF' => "CHF: Swiss Franc",
 51+ 'CZK' => "CZK: Czech Koruna",
 52+ 'DKK' => "DKK: Danish Krone",
 53+ 'HKD' => "HKD: Hong Kong Dollar",
 54+ 'HUF' => "HUF: Hungarian Forint",
 55+ 'JPY' => "JPY: Japanese Yen",
 56+ 'NZD' => "NZD: New Zealand Dollar",
 57+ 'NOK' => "NOK: Norwegian Krone",
 58+ 'PLN' => "PLN: Polish Zloty",
 59+ 'SGD' => "SGD: Singapore Dollar",
 60+ 'SEK' => "SEK: Swedish Krona",
 61+ 'ILS' => "ILS: Israeli Shekel",
 62+ ),
 63+ );
 64+
 65+ return true;
6666 }
6767
6868 /*
@@ -72,10 +72,15 @@
7373 * It is set in the LocalSettings.php file
7474 */
7575 function paypalGatewayPage(&$url) {
76 - // Business email address set in LocalSettings.php
77 - global $wgPaypalEmail;
78 -
79 - $url['paypal'] = "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=". urlencode($wgPaypalEmail) ."&lc=US&no_note=1&no_shipping=1&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";
80 -
81 - return true;
 76+ // Business email address set in LocalSettings.php
 77+ global $wgPaypalEmail;
 78+
 79+ // to go directly to Paypal, will be used for this extension in general
 80+ //$url['paypal'] = "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=". urlencode($wgPaypalEmail) ."&lc=US&no_note=1&no_shipping=1&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";
 81+
 82+ //specifically for WikiMedia, goes to processor page
 83+ //TODO: Fix for language specific pages!!
 84+ $url['paypal'] = "http://wikimediafoundation.org/wiki/Special:ContributionTracking/";
 85+
 86+ return true;
8287 }
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php
@@ -14,7 +14,7 @@
1515 'name' => 'DonateInterface',
1616 //'author' => array( 'diana' ), // FIXME: Committer does not have details in http://svn.wikimedia.org/viewvc/mediawiki/USERINFO/
1717 'description' => 'Donate interface',
18 - //'descriptionmsg' => 'donor-desc', // FIXME: need description in donate_interface.i18n.php
 18+ 'descriptionmsg' => 'donor-desc',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:DonateInterface',
2020 );
2121
@@ -31,29 +31,53 @@
3232
3333 $wgParser->setHook( 'donate', 'efDonateRender' );
3434
 35+ // declare variables used to hold post data
 36+ $userInput = array (
 37+ 'currency' => 'USD',
 38+ 'amount' => '0.00',
 39+ 'payment_method' => '',
 40+ 'referrer' => '',
 41+ 'utm_source' => '',
 42+ 'utm_medium' => '',
 43+ 'utm_campaign' => '',
 44+ 'language' => '',
 45+ 'comment' => '',
 46+ 'comment-option' => '',
 47+ 'email' => '',
 48+ );
 49+
3550 // if form has been submitted, assign data and redirect user to chosen payment gateway
3651 if ($_POST['process'] == "_yes_") {
37 - //find out which amount option was chosen for amount, redefined buttons or text box
38 - if (isset($_POST['amount'])) {
39 - $amount = number_format($wgRequest->getText('amount'), 2);
40 - } else { $amount = number_format($wgRequest->getText('amount2'), 2, '.', ''); }
 52+ //find out which amount option was chosen for amount, redefined buttons or text box
 53+ if (isset($_POST['amount'])) {
 54+ $amount = number_format($wgRequest->getText('amount'), 2);
 55+ } else { $amount = number_format($wgRequest->getText('amount2'), 2, '.', ''); }
4156
42 - // create array of user input
 57+ // create array of user input from post data
4358 $userInput = array (
4459 'currency' => $wgRequest->getText('currency_code'),
4560 'amount' => $amount,
46 - 'payment_method' => $wgRequest->getText('payment_method')
 61+ 'payment_method' => $wgRequest->getText('payment_method'),
 62+ 'referrer' => $wgRequest->getText('referrer'),
 63+ 'utm_source' => $wgRequest->getText('utm_source'),
 64+ 'utm_medium' => $wgRequest->getText('utm_medium'),
 65+ 'utm_campaign' => $wgRequest->getText('utm_campaign'),
 66+ 'language' => $wgRequest->getText('language'),
 67+ 'comment' => $wgRequest->getText('comment'),
 68+ 'comment-option' => $wgRequest->getText('comment-option'),
 69+ 'email' => $wgRequest->getText('opt'),
4770 );
4871
49 - // ask payment processor extensions for their URL/page title
50 - wfRunHooks('gwPage', array(&$url));
 72+ // ask payment processor extensions for their URL/page title
 73+ wfRunHooks('gwPage', array(&$url));
5174
52 - // send user to correct page for payment
53 - redirectToProcessorPage($userInput, $url);
 75+ var_dump($userInput);
 76+ // send user to correct page for payment
 77+ redirectToProcessorPage($userInput, $url);
5478
55 - }// end if form has been submitted
 79+ }// end if form has been submitted
5680
57 - return true;
 81+ return true;
5882 }
5983
6084
@@ -76,9 +100,10 @@
77101 //add javascript validation to <head>
78102 $parser->mOutput->addHeadItem('<script type="text/javascript" language="javascript" src="/extensions/DonationInterface/donate_interface/validate_donation.js"></script>');
79103
 104+
80105 //display form to gather data from user
81106 $output = createOutput();
82 -
 107+
83108 return $output;
84109 }
85110
@@ -89,7 +114,33 @@
90115 * option supplies it's value and name for the form, as well as currencies it supports.
91116 */
92117 function createOutput() {
 118+ global $wgOut, $wgRequest;
 119+
 120+ // declare variable
 121+ $utm_source = '';
 122+ $utm_medium = '';
 123+ $utm_campaign = '';
 124+ $referrer = '';
93125
 126+ // set them equal to post data
 127+ $utm_source = $wgRequest->getText('utm_source');
 128+ $utm_medium = $wgRequest->getText('utm_medium');
 129+ $utm_campaign = $wgRequest->getText('utm_campaign');
 130+ $referrer = $_SERVER['HTTP_REFERER'];
 131+
 132+ //get language from URL
 133+ $url = $_SERVER['REQUEST_URI'];
 134+
 135+ if ($url) {
 136+ $getLang = explode('/', $url);
 137+ $language = substr($getLang[3], 0, 2);
 138+ }
 139+
 140+ // error check and set "en" as default
 141+ if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
 142+ $language = 'en';
 143+ }
 144+
94145 //get payment method gateway value and name from each gateway and create menu of options
95146 $values = '';
96147 wfRunHooks('gwValue', array(&$values));
@@ -118,6 +169,12 @@
119170 XML::openElement('div', array('id' => 'mw-donation-intro')) .
120171 XML::element('p', array('class' => 'mw-donation-intro-text'), wfMsg('donor-intro')) .
121172 XML::closeElement('div');
 173+
 174+ $output .= XML::hidden("utm_source", $utm_source) .
 175+ XML::hidden("utm_medium", $utm_medium) .
 176+ XML::hidden("utm_campaign", $utm_campaign) .
 177+ XML::hidden("language", $language) .
 178+ XML::hidden("referrer", $referrer);
122179
123180 $amount = array(
124181 XML::radioLabel('$100', 'amount', '100', 'input_amount_3', FALSE, array("")),
@@ -158,13 +215,25 @@
159216 $gatewayMenu .
160217 XML::closeElement('select');
161218
162 - $output .= XML::fieldset(wfMsg( 'donor-gateway' ), $gatewayFields, array('class' => "mw-donation-gateway")) .
163 - XML::hidden('process', '_yes_') .
 219+ $output .= XML::fieldset(wfMsg( 'donor-gateway' ), $gatewayFields, array('class' => "mw-donation-gateway"));
 220+
 221+ $publicComment = XML::element('div', array('class' => 'mw-donation-comment-message'), wfMsg( 'donor-comment-message' )) .
 222+ XML::inputLabel(wfMsg( 'donor-comment-label' ), "comment", "comment", "30", '', array('maxlength' => "200")) .
 223+ XML::openElement('div', array('id' => 'mw-donation-checkbox')) .
 224+ XML::checkLabel(wfMsg( 'donor-anon-message' ), 'comment-option', 'input_comment-option', TRUE) .
 225+ XML::closeElement('div') .
 226+ XML::openElement('div', array('id' => 'mw-donation-checkbox')) .
 227+ XML::check('opt', TRUE) .
 228+ XML::tags('span', array('class' => 'mw-email-agreement'), wfMsg( 'donor-email-agreement' )) .
 229+ XML::closeElement('div');
 230+
 231+ $output .= XML::fieldset(wfMsg( 'donor-comment-title' ), $publicComment, array('class' => 'mw-donation-public-comment'));
 232+
 233+ $output .= XML::hidden('process', '_yes_') .
164234 XML::submitButton(wfMsg( 'donor-submit-button' ));
165 -
166 -
 235+
167236 $output .= XML::closeElement('form');
168 -
 237+
169238 // NOTE: For testing: show country of origin
170239 //$country = fnDonateGetCountry();
171240 //$output .= XML::element('p', array('class' => 'mw-donation-test-message'), 'Country:' . $country);
@@ -175,8 +244,11 @@
176245
177246 // NOTE: for testing: show IP address
178247 //$referrer = $_SERVER['HTTP_REFERER'];
179 - //$output .= '<p>' . "Referrer:" . $referrer . '<p>';
180 -
 248+ //$output .= '<p>' . "Referrer:" . $referrer . '</p>';
 249+
 250+ //for testing to show language culled from URL
 251+ $output .= '<p>' . " Language: " . $language . '</p>';
 252+
181253 return $output;
182254 }
183255
@@ -189,12 +261,14 @@
190262 * matches the form value (also supplied by the gateway)
191263 */
192264 function redirectToProcessorPage($userInput, $url) {
193 - global $wgOut,$wgPaymentGatewayHost;
 265+ global $wgOut,$wgPaymentGatewayHost;
 266+
 267+ $chosenGateway = $userInput['payment_method'];
 268+
 269+
 270+ $wgOut->redirect($url[$chosenGateway].'&amount='.$userInput['amount'].'&currency_code='.$userInput['currency'].'&gateway='.$userInput['payment_method'].'&referrer='.$userInput['referrer'].'&utm_source='.$userInput['utm_source'].'&utm_medium='.$userInput['utm_medium'].'&utm_campaign='.$userInput['utm_campaign'].'&language='.$userInput['language'].'&comment='.$userInput['comment'].'&comment-option='.$userInput['comment-option'].'&email='.$userInput['email']);
 271+
194272
195 - $chosenGateway = $userInput['payment_method'];
196 -
197 - $wgOut->redirect( $wgPaymentGatewayHost . $url[$chosenGateway] . '&amount=' . $userInput['amount'] .
198 - '&currency_code=' . $userInput['currency'] );
199273 }
200274
201275 /**
@@ -258,7 +332,6 @@
259333 $country_code = fnDonateGetCountry();
260334 }
261335
262 -
263336 $chapter = fnDonateGetChapter($country_code);
264337
265338
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.i18n.php
@@ -8,12 +8,19 @@
99 $messages = array();
1010
1111 $messages['en'] = array(
12 - 'donate_interface' => 'Support Wikimedia',
13 - //'donate-desc' => 'Some description needed', // FIXME: needs description
14 - 'donor-intro' => 'Please choose a payment method, amount, and currency.',
15 - 'donor-amount' => 'Donation amount:',
16 - 'donor-other-amount' => 'Other amount',
17 - 'donor-currency' => 'Currency:',
18 - 'donor-gateway' => 'Payment method:',
19 - 'donor-submit-button' => 'Donate',
 12+ 'donate_interface' => 'Support Wikimedia',
 13+ 'donate-desc' => 'Donation landing page that integrates gateway extensions',
 14+ 'donor-intro' => 'Please choose a payment method, amount, and currency.',
 15+ 'donor-amount' => 'Donation amount:',
 16+ 'donor-other-amount' => 'Other amount',
 17+ 'donor-currency' => 'Currency:',
 18+ 'donor-gateway' => 'Payment method:',
 19+ 'donor-submit-button' => 'Donate',
 20+ 'donor-comment-message' => "Have a thought to share with the world? Put up to 200 characters here:",
 21+ 'donor-comment-label' => "Comment: ",
 22+ 'donor-anon-message' => "Please list my name (next to my comment) on the public donor list.",
 23+ 'donor-email-agreement' => "I agree to receive future Wikimedia Foundation newsletters or emails. We will never sell or trade your information. Our donor privacy policy can be found
 24+<a title='Donate/Donor Privacy' href='/wiki/Donate/Donor_Privacy'>here</a>",
 25+ 'donor-comment-title' => "Public Comment",
 26+
2027 );
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -9,12 +9,12 @@
1010 }
1111
1212 $wgExtensionCredits['other'][] = array(
13 - 'name' => 'ActiveMQ - PHP STOMP',
14 - 'author' => 'Four Kitchens',
15 - 'url' => '',
16 - 'description' => 'Interface to send donation data to ActiveMQ server',
17 - 'descriptionmsg' => 'activemq_stomp-desc',
18 - 'version' => '1.0.0',
 13+ 'name' => 'ActiveMQ - PHP STOMP',
 14+ 'author' => 'Four Kitchens',
 15+ 'url' => '',
 16+ 'description' => 'Interface to send donation data to ActiveMQ server',
 17+ 'descriptionmsg' => 'activemq_stomp-desc',
 18+ 'version' => '1.0.0',
1919 );
2020
2121
@@ -24,9 +24,9 @@
2525 #$wgExtensionMessagesFiles['ActiveMQSTOMP'] = $dir . 'activemq_stomp.il8n.php';
2626
2727 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
28 - $wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
 28+ $wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
2929 } else { // Otherwise do things the old fashioned way
30 - $wgExtensionFunctions[] = 'efStompSetup';
 30+ $wgExtensionFunctions[] = 'efStompSetup';
3131 }
3232
3333
@@ -34,24 +34,24 @@
3535 * Create <donate /> tag to include landing page donation form
3636 */
3737 function efStompSetup(&$parser) {
38 - global $wgParser, $wgOut;
39 -
40 - $parser->disableCache();
41 -
42 - $wgParser->setHook( 'stomp', 'efStompTest' );
43 -
44 - return true;
 38+ global $wgParser, $wgOut;
 39+
 40+ $parser->disableCache();
 41+
 42+ $wgParser->setHook( 'stomp', 'efStompTest' );
 43+
 44+ return true;
4545 }
4646
4747 function efStompTest($input, $args, &$parser) {
4848
49 - $parser->disableCache();
50 -
51 - $output = "STOMP Test page";
52 -
53 - wfRunHooks('gwStomp', array(&$transaction));
54 -
55 - return $output;
 49+ $parser->disableCache();
 50+
 51+ $output = "STOMP Test page";
 52+
 53+ wfRunHooks('gwStomp', array(&$transaction));
 54+
 55+ return $output;
5656 }
5757
5858 /**
@@ -65,52 +65,29 @@
6666 * Hook to send transaction information to ActiveMQ server
6767 */
6868 function sendSTOMP($transaction) {
69 - global $wgOut;
70 - global $wgStompServer;
71 - //var_dump($wgStompServer);
72 -
73 - // include a library
74 - require_once("Stomp.php");
75 -
76 - $message = json_encode(createQueueMessage($transaction));
77 -
78 - // make a connection
79 - $con = new Stomp($wgStompServer);
80 -
81 - // connect
82 - $con->connect();
83 -
84 - // send a message to the queue
85 - $result = $con->send("/queue/test", $message, array('persistent' => 'true'));
86 -
87 - // TODO: Add back up logging if no result!
88 -
89 - $con->disconnect();
90 -
91 - /* NOTE: For receiving messages - saved for later development
92 -
93 - // subscribe to the queue
94 -
95 - $con->subscribe("/queue/test");
96 -
97 - // receive a message from the queue
98 - $msg = $con->readFrame();
99 -
100 - // do what you want with the message
101 - if ( $msg->body === "string") {
102 - echo "Worked!!\n";
103 - $wgOut->addHTML("WORKED");
104 - // mark the message as received in the queue
105 - $con->ack($msg);
106 - } else {
107 - echo "Failed\n";
108 - $wgOut->addHTML("FAILED");
109 - }
110 -*/
111 - // disconnect
112 -
113 -
114 - return true;
 69+ global $wgOut;
 70+ global $wgStompServer;
 71+ //var_dump($wgStompServer);
 72+
 73+ // include a library
 74+ require_once("Stomp.php");
 75+
 76+ $message = json_encode(createQueueMessage($transaction));
 77+
 78+ // make a connection
 79+ $con = new Stomp($wgStompServer);
 80+
 81+ // connect
 82+ $con->connect();
 83+
 84+ // send a message to the queue
 85+ $result = $con->send("/queue/test", $message, array('persistent' => 'true'));
 86+
 87+ // TODO: Add back up logging if no result!
 88+
 89+ $con->disconnect();
 90+
 91+ return true;
11592 }
11693
11794 /**
@@ -135,9 +112,14 @@
136113 // edit this array to include/ignore transaction data sent to the server
137114 $message = array(
138115 'contribution_tracking_id' => $transaction['order_id'],
139 - 'optout' => 1, //TODO: include once created on donation page
140 - 'anonymous' => 0, //TODO: include once created on donation page
141 - 'comment' => '', //TODO: include once created on donation page
 116+ 'optout' => $transaction['optout'],
 117+ 'anonymous' => $transaction['anonymous'],
 118+ 'comment' => $transaction['comment'],
 119+ 'utm_source' => $transaction['utm_source'],
 120+ 'utm_medium' => $transaction['utm_medium'],
 121+ 'utm_campaign' => $transaction['utm_campaign'],
 122+ 'language' => $transaction['language'],
 123+ 'referrer' => $transaction['referrer'],
142124 'email' => $transaction['email'],
143125 'first_name' => $transaction['fname'],
144126 'middle_name' => $transaction['mname'],
@@ -164,4 +146,3 @@
165147
166148 return $message;
167149 }
168 -

Comments

#Comment by Tim Starling (talk | contribs)   03:16, 17 December 2009

Just some explanatory notes:

  • The var_dump() was removed in r58314.
  • The way $error[...] is substituted into HTML looks like XSS but isn't. Also, $language is validated so the apparent XSS there is also relatively safe.
  • The URL escaping issue in redirectToProcessorPage() was fixed at some point.

Status & tagging log