Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | { |
6 | 6 | 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' ]; |
7 | 7 | |
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"], |
9 | 9 | numFields = fields.length, |
10 | 10 | i, |
11 | 11 | output = ''; |
— | — | @@ -19,8 +19,8 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | // 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("."); |
25 | 25 | |
26 | 26 | if (apos<1||dotpos-apos<2) |
27 | 27 | { |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -39,6 +39,14 @@ |
40 | 40 | 'payment_method' => '', |
41 | 41 | 'order_id' => '', |
42 | 42 | 'numAttempt' => '', |
| 43 | + 'referrer' => '', |
| 44 | + 'utm_source' => '', |
| 45 | + 'utm_medium' => '', |
| 46 | + 'utm_campaign' => '', |
| 47 | + 'language' => '', |
| 48 | + 'comment' => '', |
| 49 | + 'anonymous' => '', |
| 50 | + 'optout' => '', |
43 | 51 | 'token' => $token, |
44 | 52 | ); |
45 | 53 | |
— | — | @@ -59,7 +67,7 @@ |
60 | 68 | // Populate from data |
61 | 69 | $data = array( |
62 | 70 | 'amount' => $amount, |
63 | | - 'email' => $wgRequest->getText('email'), |
| 71 | + 'email' => $wgRequest->getText('emailAdd'), |
64 | 72 | 'fname' => $wgRequest->getText('fname'), |
65 | 73 | 'mname' => $wgRequest->getText('mname'), |
66 | 74 | 'lname' => $wgRequest->getText('lname'), |
— | — | @@ -76,6 +84,14 @@ |
77 | 85 | 'payment_method' => $wgRequest->getText('payment_method'), |
78 | 86 | 'order-id' => NULL, //will be set with $payflow_data |
79 | 87 | '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'), |
80 | 96 | 'test_string' => $wgRequest->getText('process'), //for showing payflow string during testing |
81 | 97 | ); |
82 | 98 | |
— | — | @@ -131,19 +147,17 @@ |
132 | 148 | XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message' )) . |
133 | 149 | XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message-2' )) . |
134 | 150 | 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 | + |
148 | 162 | //create drop down of countries |
149 | 163 | $countries = countryCodes(); |
150 | 164 | |
— | — | @@ -158,21 +172,21 @@ |
159 | 173 | XML::hidden('amount', $data['amount']); |
160 | 174 | |
161 | 175 | $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>', |
164 | 178 | 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>', |
168 | 182 | XML::label(wfMsg( 'pfp-donor-state' ), "state") . |
169 | 183 | XML::openElement('select', array('name' => "state", 'id' => "state", 'value' => $data['state'])) . |
170 | 184 | 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>', |
173 | 187 | XML::label(wfMsg( 'pfp-donor-country' ), "country") . |
174 | 188 | XML::openElement('select', array('name' => "country", 'id' => "country", 'value' => $data['country'])) . |
175 | 189 | $countryMenu . |
176 | | - XML::closeElement('select') |
| 190 | + XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['country'].'</span>' |
177 | 191 | ); |
178 | 192 | |
179 | 193 | $donorField = ""; |
— | — | @@ -227,9 +241,9 @@ |
228 | 242 | XML::openElement('select', array('name' => "card", 'id' => "card")) . |
229 | 243 | $cardOptionsMenu . |
230 | 244 | 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>', |
232 | 246 | $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>', |
234 | 248 | ); |
235 | 249 | |
236 | 250 | foreach($cardInput as $value) { |
— | — | @@ -267,7 +281,7 @@ |
268 | 282 | //does not include fields that are not required |
269 | 283 | $msg = array( |
270 | 284 | 'amount' => "donation amount", |
271 | | - 'email' => "email address", |
| 285 | + 'emailAdd' => "email address", |
272 | 286 | 'fname' => "first name", |
273 | 287 | 'lname' => "last name", |
274 | 288 | 'street' => "street address", |
— | — | @@ -295,7 +309,7 @@ |
296 | 310 | |
297 | 311 | //create error message (supercedes empty field message) |
298 | 312 | if (!$isEmail) { |
299 | | - $error['email'] = wfMsg ( 'pfp-error-msg-email' ); |
| 313 | + $error['emailAdd'] = wfMsg ( 'pfp-error-msg-email' ); |
300 | 314 | $error_result = '1'; |
301 | 315 | } |
302 | 316 | |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php |
— | — | @@ -8,52 +8,49 @@ |
9 | 9 | $messages = array(); |
10 | 10 | |
11 | 11 | $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', |
60 | 57 | ); |
Index: trunk/extensions/DonationInterface/paypal_gateway/paypal_gateway.php |
— | — | @@ -36,32 +36,32 @@ |
37 | 37 | */ |
38 | 38 | function paypalGatewayValue(&$values) { |
39 | 39 | |
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; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /* |
— | — | @@ -72,10 +72,15 @@ |
73 | 73 | * It is set in the LocalSettings.php file |
74 | 74 | */ |
75 | 75 | 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; |
82 | 87 | } |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | 'name' => 'DonateInterface', |
16 | 16 | //'author' => array( 'diana' ), // FIXME: Committer does not have details in http://svn.wikimedia.org/viewvc/mediawiki/USERINFO/ |
17 | 17 | 'description' => 'Donate interface', |
18 | | - //'descriptionmsg' => 'donor-desc', // FIXME: need description in donate_interface.i18n.php |
| 18 | + 'descriptionmsg' => 'donor-desc', |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:DonateInterface', |
20 | 20 | ); |
21 | 21 | |
— | — | @@ -31,29 +31,53 @@ |
32 | 32 | |
33 | 33 | $wgParser->setHook( 'donate', 'efDonateRender' ); |
34 | 34 | |
| 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 | + |
35 | 50 | // if form has been submitted, assign data and redirect user to chosen payment gateway |
36 | 51 | 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, '.', ''); } |
41 | 56 | |
42 | | - // create array of user input |
| 57 | + // create array of user input from post data |
43 | 58 | $userInput = array ( |
44 | 59 | 'currency' => $wgRequest->getText('currency_code'), |
45 | 60 | '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'), |
47 | 70 | ); |
48 | 71 | |
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)); |
51 | 74 | |
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); |
54 | 78 | |
55 | | - }// end if form has been submitted |
| 79 | + }// end if form has been submitted |
56 | 80 | |
57 | | - return true; |
| 81 | + return true; |
58 | 82 | } |
59 | 83 | |
60 | 84 | |
— | — | @@ -76,9 +100,10 @@ |
77 | 101 | //add javascript validation to <head> |
78 | 102 | $parser->mOutput->addHeadItem('<script type="text/javascript" language="javascript" src="/extensions/DonationInterface/donate_interface/validate_donation.js"></script>'); |
79 | 103 | |
| 104 | + |
80 | 105 | //display form to gather data from user |
81 | 106 | $output = createOutput(); |
82 | | - |
| 107 | + |
83 | 108 | return $output; |
84 | 109 | } |
85 | 110 | |
— | — | @@ -89,7 +114,33 @@ |
90 | 115 | * option supplies it's value and name for the form, as well as currencies it supports. |
91 | 116 | */ |
92 | 117 | function createOutput() { |
| 118 | + global $wgOut, $wgRequest; |
| 119 | + |
| 120 | + // declare variable |
| 121 | + $utm_source = ''; |
| 122 | + $utm_medium = ''; |
| 123 | + $utm_campaign = ''; |
| 124 | + $referrer = ''; |
93 | 125 | |
| 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 | + |
94 | 145 | //get payment method gateway value and name from each gateway and create menu of options |
95 | 146 | $values = ''; |
96 | 147 | wfRunHooks('gwValue', array(&$values)); |
— | — | @@ -118,6 +169,12 @@ |
119 | 170 | XML::openElement('div', array('id' => 'mw-donation-intro')) . |
120 | 171 | XML::element('p', array('class' => 'mw-donation-intro-text'), wfMsg('donor-intro')) . |
121 | 172 | 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); |
122 | 179 | |
123 | 180 | $amount = array( |
124 | 181 | XML::radioLabel('$100', 'amount', '100', 'input_amount_3', FALSE, array("")), |
— | — | @@ -158,13 +215,25 @@ |
159 | 216 | $gatewayMenu . |
160 | 217 | XML::closeElement('select'); |
161 | 218 | |
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_') . |
164 | 234 | XML::submitButton(wfMsg( 'donor-submit-button' )); |
165 | | - |
166 | | - |
| 235 | + |
167 | 236 | $output .= XML::closeElement('form'); |
168 | | - |
| 237 | + |
169 | 238 | // NOTE: For testing: show country of origin |
170 | 239 | //$country = fnDonateGetCountry(); |
171 | 240 | //$output .= XML::element('p', array('class' => 'mw-donation-test-message'), 'Country:' . $country); |
— | — | @@ -175,8 +244,11 @@ |
176 | 245 | |
177 | 246 | // NOTE: for testing: show IP address |
178 | 247 | //$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 | + |
181 | 253 | return $output; |
182 | 254 | } |
183 | 255 | |
— | — | @@ -189,12 +261,14 @@ |
190 | 262 | * matches the form value (also supplied by the gateway) |
191 | 263 | */ |
192 | 264 | 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'].'¤cy_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 | + |
194 | 272 | |
195 | | - $chosenGateway = $userInput['payment_method']; |
196 | | - |
197 | | - $wgOut->redirect( $wgPaymentGatewayHost . $url[$chosenGateway] . '&amount=' . $userInput['amount'] . |
198 | | - '¤cy_code=' . $userInput['currency'] ); |
199 | 273 | } |
200 | 274 | |
201 | 275 | /** |
— | — | @@ -258,7 +332,6 @@ |
259 | 333 | $country_code = fnDonateGetCountry(); |
260 | 334 | } |
261 | 335 | |
262 | | - |
263 | 336 | $chapter = fnDonateGetChapter($country_code); |
264 | 337 | |
265 | 338 | |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.i18n.php |
— | — | @@ -8,12 +8,19 @@ |
9 | 9 | $messages = array(); |
10 | 10 | |
11 | 11 | $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 | + |
20 | 27 | ); |
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -9,12 +9,12 @@ |
10 | 10 | } |
11 | 11 | |
12 | 12 | $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', |
19 | 19 | ); |
20 | 20 | |
21 | 21 | |
— | — | @@ -24,9 +24,9 @@ |
25 | 25 | #$wgExtensionMessagesFiles['ActiveMQSTOMP'] = $dir . 'activemq_stomp.il8n.php'; |
26 | 26 | |
27 | 27 | if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
28 | | - $wgHooks['ParserFirstCallInit'][] = 'efStompSetup'; |
| 28 | + $wgHooks['ParserFirstCallInit'][] = 'efStompSetup'; |
29 | 29 | } else { // Otherwise do things the old fashioned way |
30 | | - $wgExtensionFunctions[] = 'efStompSetup'; |
| 30 | + $wgExtensionFunctions[] = 'efStompSetup'; |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
— | — | @@ -34,24 +34,24 @@ |
35 | 35 | * Create <donate /> tag to include landing page donation form |
36 | 36 | */ |
37 | 37 | 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; |
45 | 45 | } |
46 | 46 | |
47 | 47 | function efStompTest($input, $args, &$parser) { |
48 | 48 | |
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; |
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
— | — | @@ -65,52 +65,29 @@ |
66 | 66 | * Hook to send transaction information to ActiveMQ server |
67 | 67 | */ |
68 | 68 | 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; |
115 | 92 | } |
116 | 93 | |
117 | 94 | /** |
— | — | @@ -135,9 +112,14 @@ |
136 | 113 | // edit this array to include/ignore transaction data sent to the server |
137 | 114 | $message = array( |
138 | 115 | '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'], |
142 | 124 | 'email' => $transaction['email'], |
143 | 125 | 'first_name' => $transaction['fname'], |
144 | 126 | 'middle_name' => $transaction['mname'], |
— | — | @@ -164,4 +146,3 @@ |
165 | 147 | |
166 | 148 | return $message; |
167 | 149 | } |
168 | | - |