Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -9,9 +9,6 @@ |
10 | 10 | |
11 | 11 | function execute( $par ) { |
12 | 12 | global $wgRequest, $wgOut, $wgUser; |
13 | | - |
14 | | - global $wgParser; |
15 | | - $wgParser->disableCache(); |
16 | 13 | |
17 | 14 | $this->setHeaders(); |
18 | 15 | |
— | — | @@ -53,12 +50,12 @@ |
54 | 51 | $error[] = ''; |
55 | 52 | |
56 | 53 | //find out if amount was a radio button or textbox, set amount |
57 | | - if (isset($_REQUEST['amount'])) { |
| 54 | + if (isset($_REQUEST['amount'])&& preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount'))) { |
58 | 55 | $amount = $wgRequest->getText('amount'); |
59 | | - } else if (isset($_REQUEST['amount2'])) { |
| 56 | + } else if (isset($_REQUEST['amount2']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount2'))) { |
60 | 57 | $amount = number_format($wgRequest->getText('amount2'), 2, '.', ''); |
61 | 58 | } else { |
62 | | - $wgOut->addHTML(wfMsg( 'pfp-accessible' )); |
| 59 | + $wgOut->addHTML(wfMsg( 'payflowpro_gateway-accessible' )); |
63 | 60 | return; |
64 | 61 | } |
65 | 62 | |
— | — | @@ -111,17 +108,17 @@ |
112 | 109 | if ($success) { |
113 | 110 | if ($data['payment_method'] == "processed") { |
114 | 111 | // Check form for errors and redisplay with messages |
115 | | - if ($form_errors = $this->validateForm($data, $error)) { |
116 | | - $this->displayForm($data, $error); |
| 112 | + if ($form_errors = $this->fnPayflowValidateForm($data, $error)) { |
| 113 | + $this->fnPayflowDisplayForm($data, $error); |
117 | 114 | } else { |
118 | 115 | // The submitted data is valid, so process it |
119 | 116 | //increase the count of attempts |
120 | 117 | ++$data['numAttempt']; |
121 | | - $this->processTransaction($data, $payflow_data); |
| 118 | + $this->fnPayflowProcessTransaction($data, $payflow_data); |
122 | 119 | } |
123 | 120 | } else { |
124 | 121 | //Display form for the first time |
125 | | - $this->displayForm($data, $error); |
| 122 | + $this->fnPayflowDisplayForm($data, $error); |
126 | 123 | } |
127 | 124 | } // end $success |
128 | 125 | |
— | — | @@ -136,16 +133,16 @@ |
137 | 134 | * |
138 | 135 | * The message at the top of the form can be edited in the payflow_gateway.i18.php file |
139 | 136 | */ |
140 | | - private function displayForm($data, &$error) { |
| 137 | + private function fnPayflowDisplayForm($data, &$error) { |
141 | 138 | require_once('includes/stateAbbreviations.inc'); |
142 | 139 | require_once('includes/countryCodes.inc'); |
143 | 140 | |
144 | | - global $wgOut; |
| 141 | + global $wgOut, $wgLang; |
145 | 142 | |
146 | 143 | $form = XML::openElement('div', array('id' => 'mw-creditcard')) . |
147 | 144 | XML::openElement('div', array('id' => 'mw-creditcard-intro')) . |
148 | | - XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message' )) . |
149 | | - XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'pfp-form-message-2' )) . |
| 145 | + XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'payflowpro_gateway-form-message' )) . |
| 146 | + XML::tags('p', array('class' => 'mw-creditcard-intro-msg'), wfMsg( 'payflowpro_gateway-form-message-2' )) . |
150 | 147 | XML::closeElement('div'); |
151 | 148 | |
152 | 149 | //add hidden fields |
— | — | @@ -168,22 +165,22 @@ |
169 | 166 | //Form |
170 | 167 | $form .= XML::openElement('div', array('id' => 'mw-creditcard-form')) . |
171 | 168 | XML::openElement('form', array('name' => "payment", 'method' => "post", 'action' => "", 'onsubmit' => 'return validate_form(this)')) . |
172 | | - XML::element('legend', array('class' => 'mw-creditcard-amount'), wfMsg( 'pfp-amount-legend' ) .$data['amount']) . |
| 169 | + XML::element('legend', array('class' => 'mw-creditcard-amount'), wfMsg( 'payflowpro_gateway-amount-legend' ) .$data['amount']) . |
173 | 170 | XML::hidden('amount', $data['amount']); |
174 | 171 | |
175 | 172 | $donorInput = array( |
176 | | - XML::inputLabel(wfMsg( 'pfp-donor-email' ), "emailAdd", "emailAdd", "30", $data['email'], array('maxlength' => "150")) . '<span class="creditcard_error_msg">'. " " . $error['emailAdd'].'</span>', |
177 | | - XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')) . '<span class="creditcard_error_msg">'. " " . $error['fname'].'</span>', |
178 | | - XML::inputLabel(wfMsg( 'pfp-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")), |
179 | | - XML::inputLabel(wfMsg( 'pfp-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['lname'].'</span>', |
180 | | - XML::inputLabel(wfMsg( 'pfp-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['street'].'</span>', |
181 | | - XML::inputLabel(wfMsg( 'pfp-donor-city' ), "city", "city", "20", $data['city'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['city'].'</span>', |
182 | | - XML::label(wfMsg( 'pfp-donor-state' ), "state") . |
| 173 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-email' ), "emailAdd", "emailAdd", "30", $data['email'], array('maxlength' => "150")) . '<span class="creditcard_error_msg">'. " " . $error['emailAdd'].'</span>', |
| 174 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')) . '<span class="creditcard_error_msg">'. " " . $error['fname'].'</span>', |
| 175 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")), |
| 176 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['lname'].'</span>', |
| 177 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['street'].'</span>', |
| 178 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-city' ), "city", "city", "20", $data['city'], array('maxlength' => "35")) . '<span class="creditcard_error_msg">'. " " . $error['city'].'</span>', |
| 179 | + XML::label(wfMsg( 'payflowpro_gateway-donor-state' ), "state") . |
183 | 180 | XML::openElement('select', array('name' => "state", 'id' => "state", 'value' => $data['state'])) . |
184 | 181 | statesMenuXML() . |
185 | 182 | XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['state'].'</span>', |
186 | | - XML::inputLabel(wfMsg( 'pfp-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "18")) . '<span class="creditcard_error_msg">'. " " . $error['zip'].'</span>', |
187 | | - XML::label(wfMsg( 'pfp-donor-country' ), "country") . |
| 183 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "18")) . '<span class="creditcard_error_msg">'. " " . $error['zip'].'</span>', |
| 184 | + XML::label(wfMsg( 'payflowpro_gateway-donor-country' ), "country") . |
188 | 185 | XML::openElement('select', array('name' => "country", 'id' => "country", 'value' => $data['country'])) . |
189 | 186 | $countryMenu . |
190 | 187 | XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['country'].'</span>' |
— | — | @@ -195,7 +192,7 @@ |
196 | 193 | $donorField .= '<p>' . $value . '</p>'; |
197 | 194 | } |
198 | 195 | |
199 | | - $form .= XML::fieldset(wfMsg( 'pfp-donor-legend' ), $donorField, array('class' => "mw-creditcard-donor")); |
| 196 | + $form .= XML::fieldset(wfMsg( 'payflowpro_gateway-donor-legend' ), $donorField, array('class' => "mw-creditcard-donor")); |
200 | 197 | |
201 | 198 | $cardOptions = array( |
202 | 199 | 'visa' => "Visa", |
— | — | @@ -208,7 +205,7 @@ |
209 | 206 | } |
210 | 207 | |
211 | 208 | $cardInput = |
212 | | - XML::label(wfMsg( 'pfp-donor-card' ), "card") . |
| 209 | + XML::label(wfMsg( 'payflowpro_gateway-donor-card' ), "card") . |
213 | 210 | XML::openElement('select', array('name' => "card", 'id' => "card")) . |
214 | 211 | $cardOptionsMenu . |
215 | 212 | XML::closeElement('select'); |
— | — | @@ -216,11 +213,13 @@ |
217 | 214 | $expMos = ''; |
218 | 215 | |
219 | 216 | for($i=1; $i<13; $i++) { |
220 | | - $expMos .= XML::option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); |
| 217 | + //$expMos .= XML::option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); |
| 218 | + $expMos .= XML::option($wgLang->getMonthName( $i ), str_pad($i, 2, '0', STR_PAD_LEFT)); |
| 219 | + |
221 | 220 | } |
222 | 221 | |
223 | 222 | $expMosMenu = |
224 | | - XML::label(wfMsg( 'pfp-donor-expiration' ), "expiration") . |
| 223 | + XML::label(wfMsg( 'payflowpro_gateway-donor-expiration' ), "expiration") . |
225 | 224 | XML::openElement('select', array('name' => "mos", 'id' => "mos")) . |
226 | 225 | $expMos . |
227 | 226 | XML::closeElement('select'); |
— | — | @@ -237,33 +236,33 @@ |
238 | 237 | XML::closeElement('select'); |
239 | 238 | |
240 | 239 | $cardInput = array( |
241 | | - XML::label(wfMsg( 'pfp-donor-card' ), "card") . |
| 240 | + XML::label(wfMsg( 'payflowpro_gateway-donor-card' ), "card") . |
242 | 241 | XML::openElement('select', array('name' => "card", 'id' => "card")) . |
243 | 242 | $cardOptionsMenu . |
244 | 243 | XML::closeElement('select'), |
245 | | - XML::inputLabel(wfMsg( 'pfp-donor-card-num' ), "card_num", "card_num", "30", '', array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['card_num'].'</span>' . '<span class="creditcard_error_msg">'. " " . $error['card'].'</span>', |
| 244 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-card-num' ), "card_num", "card_num", "30", '', array('maxlength' => "100")) . '<span class="creditcard_error_msg">'. " " . $error['card_num'].'</span>' . '<span class="creditcard_error_msg">'. " " . $error['card'].'</span>', |
246 | 245 | $expMosMenu . $expYrMenu, |
247 | | - XML::inputLabel(wfMsg( 'pfp-donor-security' ), "cvv", "cvv", "5", '', array('maxlength' => "10")) . '<span class="creditcard_error_msg">'. " " . $error['cvv'].'</span>', |
| 246 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-security' ), "cvv", "cvv", "5", '', array('maxlength' => "10")) . '<span class="creditcard_error_msg">'. " " . $error['cvv'].'</span>', |
248 | 247 | ); |
249 | 248 | |
250 | 249 | foreach($cardInput as $value) { |
251 | 250 | $cardField .= '<p>' . $value . '</p>'; |
252 | 251 | } |
253 | 252 | |
254 | | - $form .= XML::fieldset(wfMsg( 'pfp-card-legend' ), $cardField, array('class' => "mw-creditcard-card")) . |
| 253 | + $form .= XML::fieldset(wfMsg( 'payflowpro_gateway-card-legend' ), $cardField, array('class' => "mw-creditcard-card")) . |
255 | 254 | XML::hidden('process', 'CreditCard') . |
256 | 255 | XML::hidden('payment_method', 'processed') . |
257 | 256 | XML::hidden('token', $data['token']) . |
258 | 257 | XML::hidden('currency_code', $data['currency']) . |
259 | 258 | XML::hidden('orderid', $data['order_id']) . |
260 | 259 | XML::hidden('numAttempt', $data['numAttempt']) . |
261 | | - XML::submitButton("Donate") . |
| 260 | + XML::submitButton(wfMsg( 'payflowpro_gateway-submit-button' )) . |
262 | 261 | XML::closeElement('form') . |
263 | 262 | XML::closeElement('div'); |
264 | 263 | |
265 | 264 | |
266 | 265 | $form .= XML::closeElement('div') . |
267 | | - XML::Element('p', array('class' => "mw-creditcard-submessage"), wfMsg( 'pfp-donor-currency-msg', $data['currency'] ) ); |
| 266 | + XML::Element('p', array('class' => "mw-creditcard-submessage"), wfMsg( 'payflowpro_gateway-donor-currency-msg', $data['currency'] ) ); |
268 | 267 | $wgOut->addHTML( $form ); |
269 | 268 | } |
270 | 269 | |
— | — | @@ -271,7 +270,7 @@ |
272 | 271 | /* |
273 | 272 | * Checks posted form data for errors and returns array of messages |
274 | 273 | */ |
275 | | - private function validateForm($data, &$error) { |
| 274 | + private function fnPayflowValidateForm($data, &$error) { |
276 | 275 | global $wgOut; |
277 | 276 | |
278 | 277 | //begin with no errors |
— | — | @@ -298,18 +297,19 @@ |
299 | 298 | if ($value == '') { |
300 | 299 | //ignore fields that are not required |
301 | 300 | if ($msg[$key]) { |
302 | | - $error[$key] = "**" . wfMsg( 'pfp-error-msg', $msg[$key] ) . "**<br />"; |
| 301 | + $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />"; |
303 | 302 | $error_result = '1'; |
304 | 303 | } |
305 | 304 | } |
306 | 305 | } |
307 | 306 | |
308 | 307 | //is email address valid? |
309 | | - $isEmail = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email']); |
| 308 | + //$isEmail = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email']); |
| 309 | + $isEmail = User::isValidEmailAddr($data['email']); |
310 | 310 | |
311 | 311 | //create error message (supercedes empty field message) |
312 | 312 | if (!$isEmail) { |
313 | | - $error['emailAdd'] = wfMsg ( 'pfp-error-msg-email' ); |
| 313 | + $error['emailAdd'] = wfMsg ( 'payflowpro_gateway-error-msg-email' ); |
314 | 314 | $error_result = '1'; |
315 | 315 | } |
316 | 316 | |
— | — | @@ -323,7 +323,7 @@ |
324 | 324 | //if the pattern doesn't match |
325 | 325 | if (!preg_match($pattern,$data['card_num'])) { |
326 | 326 | $error_result = '1'; |
327 | | - $error['card'] = wfMsg( 'pfp-error-msg-amex' ); |
| 327 | + $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-amex' ); |
328 | 328 | } |
329 | 329 | |
330 | 330 | break; |
— | — | @@ -335,7 +335,7 @@ |
336 | 336 | //if pattern doesn't match |
337 | 337 | if (!preg_match($pattern,$data['card_num'])) { |
338 | 338 | $error_result = '1'; |
339 | | - $error['card'] = wfMsg( 'pfp-error-msg-mc' ); |
| 339 | + $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-mc' ); |
340 | 340 | } |
341 | 341 | |
342 | 342 | break; |
— | — | @@ -347,7 +347,7 @@ |
348 | 348 | //if pattern doesn't match |
349 | 349 | if (!preg_match($pattern,$data['card_num'])) { |
350 | 350 | $error_result = '1'; |
351 | | - $error['card'] = wfMsg( 'pfp-error-msg-visa' ); |
| 351 | + $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-visa' ); |
352 | 352 | } |
353 | 353 | |
354 | 354 | break; |
— | — | @@ -365,14 +365,12 @@ |
366 | 366 | * $payflow_data array of necessary Payflow variables to include in string (ie Vendor, password) |
367 | 367 | * |
368 | 368 | */ |
369 | | - private function processTransaction($data, $payflow_data) { |
| 369 | + private function fnPayflowProcessTransaction($data, $payflow_data) { |
370 | 370 | global $wgOut; |
371 | 371 | |
372 | 372 | /* Create name-value pair query string */ |
373 | 373 | $payflow_query = "TRXTYPE=$payflow_data[trxtype]&TENDER=$payflow_data[tender]&USER=$payflow_data[user]&VENDOR=$payflow_data[vendor]&PARTNER=$payflow_data[partner]&PWD=$payflow_data[password]&ACCT=$data[card_num]&EXPDATE=$data[expiration]&AMT=$data[amount]&FIRSTNAME=$data[fname]&LASTNAME=$data[lname]&STREET=$data[street]&ZIP=$data[zip]&INVNUM=$payflow_data[order_id]&CVV2=$data[cvv]&CURRENCY=$data[currency]&VERBOSITY=$payflow_data[verbosity]&CUSTIP=$payflow_data[user_ip]"; |
374 | 374 | |
375 | | - //NOTE: for testing |
376 | | - //var_dump($payflow_query); |
377 | 375 | |
378 | 376 | // assign header data necessary for the curl_setopt() function |
379 | 377 | $user_agent = $_SERVER['HTTP_USER_AGENT']; |
— | — | @@ -422,7 +420,7 @@ |
423 | 421 | $result = strstr($result, "RESULT"); |
424 | 422 | |
425 | 423 | // parse string and display results to the user |
426 | | - $this->getResults($data, $result); |
| 424 | + $this->fnPayflowGetResults($data, $result); |
427 | 425 | |
428 | 426 | } |
429 | 427 | |
— | — | @@ -436,12 +434,9 @@ |
437 | 435 | * |
438 | 436 | * Credit:code modified from payflowpro_example_EC.php posted (and supervised) on the PayPal developers message board |
439 | 437 | */ |
440 | | - private function getResults($data, $result) { |
| 438 | + private function fnPayflowGetResults($data, $result) { |
441 | 439 | global $wgOut; |
442 | 440 | |
443 | | - //NOTE for testing |
444 | | - //var_dump($result); |
445 | | - |
446 | 441 | //prepare NVP response for sorting and outputting |
447 | 442 | $responseArray = array(); |
448 | 443 | |
— | — | @@ -467,19 +462,19 @@ |
468 | 463 | |
469 | 464 | //interpret result code, return |
470 | 465 | //approved (1), denied (2), try again (3), general error (4) |
471 | | - $errorCode = $this->getResponseMsg($resultCode, $responseMsg); |
| 466 | + $errorCode = $this->fnPayflowGetResponseMsg($resultCode, $responseMsg); |
472 | 467 | |
473 | 468 | //if approved, display results and send transaction to the queue |
474 | 469 | if ($errorCode == '1') { |
475 | | - $this->displayApprovedResults($data, $responseArray, $responseMsg); |
| 470 | + $this->fnPayflowDisplayApprovedResults($data, $responseArray, $responseMsg); |
476 | 471 | //give user a second chance to enter incorrect data |
477 | 472 | } else if (($errorCode == '3') && ($data['numAttempt'] < '2')) { |
478 | 473 | //pass responseMsg as an array key as required by displayForm |
479 | 474 | $tryAgainResponse[$responseMsg] = $responseMsg; |
480 | | - $this->displayForm($data, $tryAgainResponse); |
| 475 | + $this->fnPayflowDisplayForm($data, $tryAgainResponse); |
481 | 476 | // if declined or if user has already made two attempts, decline |
482 | 477 | } else if (($errorCode == '2') || ($data['numAttempt'] >= '2')) { |
483 | | - $this->displayDeclinedResults($responseMsg); |
| 478 | + $this->fnPayflowDisplayDeclinedResults($responseMsg); |
484 | 479 | } |
485 | 480 | |
486 | 481 | }// end display results |
— | — | @@ -491,53 +486,53 @@ |
492 | 487 | * 3 if invalid data was submitted by user |
493 | 488 | * 4 all other errors |
494 | 489 | */ |
495 | | - function getResponseMsg($resultCode, &$responseMsg) { |
496 | | - $responseMsg = wfMsg( 'pfp-response-default' ); |
| 490 | + function fnPayflowGetResponseMsg($resultCode, &$responseMsg) { |
| 491 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-default' ); |
497 | 492 | $errorCode = "0"; |
498 | 493 | |
499 | 494 | switch ($resultCode) { |
500 | 495 | case '0': |
501 | | - $responseMsg = wfMsg( 'pfp-response-0' ); |
| 496 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-0' ); |
502 | 497 | $errorCode = "1"; |
503 | 498 | break; |
504 | 499 | case '126': |
505 | | - $responseMsg = wfMsg( 'pfp-response-126' ); |
| 500 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-126' ); |
506 | 501 | $errorCode = "1"; |
507 | 502 | break; |
508 | 503 | case '12': |
509 | | - $responseMsg = wfMsg( 'pfp-response-12' ); |
| 504 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-12' ); |
510 | 505 | $errorCode = "2"; |
511 | 506 | break; |
512 | 507 | case '13': |
513 | | - $responseMsg = wfMsg( 'pfp-response-13' ); |
| 508 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-13' ); |
514 | 509 | $errorCode = "2"; |
515 | 510 | break; |
516 | 511 | case '114': |
517 | | - $responseMsg = wfMsg( 'pfp-response-114' ); |
| 512 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-114' ); |
518 | 513 | $errorCode = "2"; |
519 | 514 | break; |
520 | 515 | case '4': |
521 | | - $responseMsg = wfMsg( 'pfp-response-4' ); |
| 516 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-4' ); |
522 | 517 | $errorCode = "3"; |
523 | 518 | break; |
524 | 519 | case '23': |
525 | | - $responseMsg = wfMsg( 'pfp-response-23' ); |
| 520 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-23' ); |
526 | 521 | $errorCode = "3"; |
527 | 522 | break; |
528 | 523 | case '24': |
529 | | - $responseMsg = wfMsg( 'pfp-response-24' ); |
| 524 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-24' ); |
530 | 525 | $errorCode = "3"; |
531 | 526 | break; |
532 | 527 | case '112': |
533 | | - $responseMsg = wfMsg( 'pfp-response-112' ); |
| 528 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-112' ); |
534 | 529 | $errorCode = "3"; |
535 | 530 | break; |
536 | 531 | case '125': |
537 | | - $responseMsg = wfMsg( 'pfp-response-125' ); |
| 532 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-125' ); |
538 | 533 | $errorCode = "3"; |
539 | 534 | break; |
540 | 535 | default: |
541 | | - $responseMsg = wfMsg( 'pfp-response-default' ); |
| 536 | + $responseMsg = wfMsg( 'payflowpro_gateway-response-default' ); |
542 | 537 | $errorCode = "4"; |
543 | 538 | |
544 | 539 | } |
— | — | @@ -553,7 +548,7 @@ |
554 | 549 | * $responseMsg message supplied by getResults function |
555 | 550 | * |
556 | 551 | */ |
557 | | - function displayApprovedResults($data, $responseArray, $responseMsg) { |
| 552 | + function fnPayflowDisplayApprovedResults($data, $responseArray, $responseMsg) { |
558 | 553 | global $wgOut; |
559 | 554 | $transaction = ''; |
560 | 555 | |
— | — | @@ -567,11 +562,11 @@ |
568 | 563 | $countries = countryCodes(); |
569 | 564 | |
570 | 565 | $rows = array( |
571 | | - 'title' => array(wfMsg( 'pfp-post-transaction' )), |
572 | | - 'amount' => array(wfMsg( 'pfp-donor-amount' ), $data['amount']), |
573 | | - 'email' => array(wfMsg( 'pfp-donor-email' ), $data['email']), |
574 | | - 'name' => array(wfMsg( 'pfp-donor-name' ), $data['fname'], $data['mname'], $data['lname']), |
575 | | - 'address' => array(wfMsg( 'pfp-donor-address' ), $data['street'], $data['city'], $data['state'], $data['zip'],$countries[$data['country']]), |
| 566 | + 'title' => array(wfMsg( 'payflowpro_gateway-post-transaction' )), |
| 567 | + 'amount' => array(wfMsg( 'payflowpro_gateway-donor-amount' ), $data['amount']), |
| 568 | + 'email' => array(wfMsg( 'payflowpro_gateway-donor-email' ), $data['email']), |
| 569 | + 'name' => array(wfMsg( 'payflowpro_gateway-donor-name' ), $data['fname'], $data['mname'], $data['lname']), |
| 570 | + 'address' => array(wfMsg( 'payflowpro_gateway-donor-address' ), $data['street'], $data['city'], $data['state'], $data['zip'],$countries[$data['country']]), |
576 | 571 | ); |
577 | 572 | |
578 | 573 | //if we want to show the response |
— | — | @@ -602,7 +597,7 @@ |
603 | 598 | * $responseMsg message supplied by getResults function |
604 | 599 | * |
605 | 600 | */ |
606 | | - function displayDeclinedResults($responseMsg) { |
| 601 | + function fnPayflowDisplayDeclinedResults($responseMsg) { |
607 | 602 | global $wgOut; |
608 | 603 | |
609 | 604 | //general decline message |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php |
— | — | @@ -10,50 +10,51 @@ |
11 | 11 | $messages['en'] = array( |
12 | 12 | 'payflowprogateway' => 'Support Wikimedia', |
13 | 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. |
| 14 | + 'payflowpro_gateway-accessible' => 'This page is only accessible from the donation page.', |
| 15 | + 'payflowpro_gateway-form-message' => 'Contribute with your credit card. |
16 | 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. |
| 17 | + 'payflowpro_gateway-form-message-2' => 'To change amount or currency, return to <a href="https://www.mediawiki.org/index.php?title=Donate">the donation page</a>', |
| 18 | + 'payflowpro_gateway-donor-legend' => 'Donor information', |
| 19 | + 'payflowpro_gateway-card-legend' => 'Credit card information', |
| 20 | + 'payflowpro_gateway-amount-legend' => 'Donation amount:', |
| 21 | + 'payflowpro_gateway-donor-amount' => 'Amount:', |
| 22 | + 'payflowpro_gateway-donor-email' => 'E-mail address:', |
| 23 | + 'payflowpro_gateway-donor-fname' => 'First name:', |
| 24 | + 'payflowpro_gateway-donor-mname' => 'Middle name:', |
| 25 | + 'payflowpro_gateway-donor-lname' => 'Last name:', |
| 26 | + 'payflowpro_gateway-donor-name' => 'Name:', |
| 27 | + 'payflowpro_gateway-donor-street' => 'Street:', |
| 28 | + 'payflowpro_gateway-donor-city' => 'City:', |
| 29 | + 'payflowpro_gateway-donor-state' => 'State:', |
| 30 | + 'payflowpro_gateway-donor-postal' => 'Postal code:', |
| 31 | + 'payflowpro_gateway-donor-country' => 'Country/Region:', |
| 32 | + 'payflowpro_gateway-donor-address'=> 'Address:', |
| 33 | + 'payflowpro_gateway-donor-card' => 'Credit card:', |
| 34 | + 'payflowpro_gateway-donor-card-num' => 'Card number:', |
| 35 | + 'payflowpro_gateway-donor-expiration' => 'Expiration date:', |
| 36 | + 'payflowpro_gateway-donor-security' => 'Security code:', |
| 37 | + 'payflowpro_gateway-donor-submit' => 'Donate', |
| 38 | + 'payflowpro_gateway-donor-currency-msg' => 'This donation is being made in $1', |
| 39 | + 'payflowpro_gateway-error-msg' => 'Please enter your $1', |
| 40 | + 'payflowpro_gateway-error-msg-email' => '**Please enter a valid e-mail address**', |
| 41 | + 'payflowpro_gateway-error-msg-amex' => '**Please enter a correct card number for American Express.**', |
| 42 | + 'payflowpro_gateway-error-msg-mc' => '**Please enter a correct card number for Mastercard.**', |
| 43 | + 'payflowpro_gateway-error-msg-visa' => '**Please enter a correct card number for Visa.**', |
| 44 | + 'payflowpro_gateway-response-0' => 'Your transaction has been approved. |
45 | 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. |
| 46 | + 'payflowpro_gateway-response-126' => 'Your transaction is pending approval.', |
| 47 | + 'payflowpro_gateway-response-12' => 'Please contact your credit card company for further information.', |
| 48 | + 'payflowpro_gateway-response-13' => 'Your transaction requires voice authorization. |
49 | 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. |
| 50 | + 'payflowpro_gateway-response-114' => 'Please contact your credit card company for further information.', |
| 51 | + 'payflowpro_gateway-response-23' => 'Your credit card number or expiration date is incorrect.', |
| 52 | + 'payflowpro_gateway-response-4' => 'Invalid amount.', |
| 53 | + 'payflowpro_gateway-response-24' => 'Your credit card number or expiration date is incorrect.', |
| 54 | + 'payflowpro_gateway-response-112' => 'Your address or CVV number (security code) is incorrect.', |
| 55 | + 'payflowpro_gateway-response-125' => 'Your transaction has been declined by Fraud Prevention Services.', |
| 56 | + 'payflowpro_gateway-response-default' => 'There was an error processing your transaction. |
57 | 57 | Please try again later.', |
58 | 58 | 'php-response-declined' => 'Your transaction has been declined.', |
59 | | - 'pfp-post-transaction' => 'Transaction details', |
| 59 | + 'payflowpro_gateway-post-transaction' => 'Transaction details', |
| 60 | + 'payflowpro_gateway-submit-button' => "Donate", |
60 | 61 | ); |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -26,15 +26,25 @@ |
27 | 27 | $wgExtensionAliasesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.alias.php'; |
28 | 28 | $wgSpecialPages['PayflowProGateway'] = 'PayflowProGateway'; # Let MediaWiki know about your new special page. |
29 | 29 | |
| 30 | +// set defaults, these should be assigned in LocalSettings.php |
| 31 | +$wgPayflowProURL = 'https://payflowpro.paypal.com'; |
| 32 | +$wgPayflowProTestingURL = 'https://pilot-payflowpro.paypal.com'; // Payflow testing URL |
30 | 33 | |
| 34 | +$wgPayflowProPartnerID = ''; //PayPal or original authorized reseller |
| 35 | +$wgPayflowProVendorID = ''; // paypal merchant login ID |
| 36 | +$wgPayflowProUserID = ''; //if one or more users are set up, authorized user ID, else same as VENDOR |
| 37 | +$wgPayflowProPassword = ''; //merchant login password |
| 38 | + |
| 39 | + |
| 40 | + |
31 | 41 | /** |
32 | 42 | * Hooks required to interface with the donation extension (include <donate> on page) |
33 | 43 | * |
34 | 44 | * gwValue supplies the value of the form option, the name that appears on the form |
35 | 45 | * and the currencies supported by the gateway in the $values array |
36 | 46 | */ |
37 | | -$wgHooks['gwValue'][] = 'pfpGatewayValue'; |
38 | | -$wgHooks['gwPage'][] = 'pfpGatewayPage'; |
| 47 | +$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue'; |
| 48 | +$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage'; |
39 | 49 | |
40 | 50 | /* |
41 | 51 | * Hook to register form value and display name of this gateway |
Index: trunk/extensions/DonationInterface/paypal_gateway/paypal_gateway.php |
— | — | @@ -21,14 +21,17 @@ |
22 | 22 | |
23 | 23 | $wgExtensionMessagesFiles['PaypalGateway'] = $dir . 'paypal_gateway.i18n.php'; |
24 | 24 | |
| 25 | +//default variables that should be set in LocalSettings |
| 26 | +$wgPaypalEmail = ""; |
| 27 | + |
25 | 28 | /** |
26 | 29 | * Hooks required to interface with the donation extension (include <donate> on page) |
27 | 30 | * |
28 | 31 | * gwValue supplies the value of the form option, the name that appears on the form |
29 | 32 | * and the currencies supported by the gateway in the $values array |
30 | 33 | */ |
31 | | -$wgHooks['gwValue'][] = 'paypalGatewayValue'; |
32 | | -$wgHooks['gwPage'][] = 'paypalGatewayPage'; |
| 34 | +$wgHooks['DonationInterface_Value'][] = 'paypalGatewayValue'; |
| 35 | +$wgHooks['DonationInterface_Page'][] = 'paypalGatewayPage'; |
33 | 36 | |
34 | 37 | /* |
35 | 38 | * Hook to register form value and display name of this gateway |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php |
— | — | @@ -12,12 +12,13 @@ |
13 | 13 | } |
14 | 14 | |
15 | 15 | // Extension credits that will show up on Special:Version |
| 16 | + |
16 | 17 | $wgExtensionCredits['specialpage'][] = array( |
17 | 18 | 'path' => __FILE__, |
18 | 19 | 'name' => 'DonateInterface', |
19 | 20 | //'author' => array( 'diana' ), // FIXME: Committer does not have details in http://svn.wikimedia.org/viewvc/mediawiki/USERINFO/ |
20 | 21 | 'description' => 'Donate interface', |
21 | | - 'descriptionmsg' => 'donor-desc', |
| 22 | + 'descriptionmsg' => 'donate_interface-desc', |
22 | 23 | 'url' => 'http://www.mediawiki.org/wiki/Extension:DonateInterface', |
23 | 24 | ); |
24 | 25 | |
— | — | @@ -26,68 +27,26 @@ |
27 | 28 | $wgExtensionMessagesFiles['DonateInterface'] = $dir . 'donate_interface.i18n.php'; |
28 | 29 | |
29 | 30 | $wgHooks['ParserFirstCallInit'][] = 'efDonateSetup'; |
| 31 | +$wgHooks['MediaWikiPerformAction'][] = 'fnProcessDonateForm'; |
| 32 | + |
30 | 33 | /** |
31 | 34 | * Create <donate /> tag to include landing page donation form |
32 | 35 | */ |
33 | 36 | function efDonateSetup( &$parser ) { |
34 | | - global $wgParser, $wgOut, $wgRequest; |
| 37 | + global $wgHooks; |
| 38 | + |
| 39 | + //load extension messages |
| 40 | + wfLoadExtensionMessages( 'donate_interface' ); |
35 | 41 | |
36 | | - // Load extension messages |
37 | | - wfLoadExtensionMessages( 'DonateInterface' ); |
| 42 | + $parser->disableCache(); |
38 | 43 | |
39 | | - $parser->disableCache(); |
| 44 | + $parser->setHook( 'donate', 'efDonateRender' ); |
| 45 | + |
| 46 | + //process form |
| 47 | + wfRunHooks( 'MediaWikiPerformAction', array( $output, |
| 48 | +$article, $title, $user, $request, $this)); |
40 | 49 | |
41 | | - $wgParser->setHook( 'donate', 'efDonateRender' ); |
42 | | - |
43 | | - // declare variables used to hold post data |
44 | | - $userInput = array ( |
45 | | - 'currency' => 'USD', |
46 | | - 'amount' => '0.00', |
47 | | - 'payment_method' => '', |
48 | | - 'referrer' => '', |
49 | | - 'utm_source' => '', |
50 | | - 'utm_medium' => '', |
51 | | - 'utm_campaign' => '', |
52 | | - 'language' => '', |
53 | | - 'comment' => '', |
54 | | - 'comment-option' => '', |
55 | | - 'email' => '', |
56 | | - ); |
57 | | - |
58 | | - // if form has been submitted, assign data and redirect user to chosen payment gateway |
59 | | - if ( isset( $_POST['process'] ) ) { |
60 | | - if ( $_POST['process'] == '_yes_' ) { |
61 | | - // find out which amount option was chosen for amount, redefined buttons or text box |
62 | | - if( isset( $_POST['amount'] ) ) { |
63 | | - $amount = number_format( $wgRequest->getText( 'amount' ), 2 ); |
64 | | - } else { |
65 | | - $amount = number_format( $wgRequest->getText( 'amount2' ), 2, '.', '' ); |
66 | | - } |
67 | | - |
68 | | - // create array of user input from post data |
69 | | - $userInput = array( |
70 | | - 'currency' => $wgRequest->getText( 'currency_code' ), |
71 | | - 'amount' => $amount, |
72 | | - 'payment_method' => $wgRequest->getText( 'payment_method' ), |
73 | | - 'referrer' => $wgRequest->getText( 'referrer' ), |
74 | | - 'utm_source' => $wgRequest->getText( 'utm_source' ), |
75 | | - 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
76 | | - 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
77 | | - 'language' => $wgRequest->getText( 'language' ), |
78 | | - 'comment' => $wgRequest->getText( 'comment' ), |
79 | | - 'comment-option' => $wgRequest->getText( 'comment-option' ), |
80 | | - 'email' => $wgRequest->getText( 'opt' ), |
81 | | - ); |
82 | | - |
83 | | - // ask payment processor extensions for their URL/page title |
84 | | - wfRunHooks( 'gwPage', array( &$url ) ); |
85 | | - |
86 | | - // send user to correct page for payment |
87 | | - redirectToProcessorPage( $userInput, $url ); |
88 | | - } // end if form has been submitted |
89 | | - } |
90 | | - |
91 | | - return true; |
| 50 | + return true; |
92 | 51 | } |
93 | 52 | |
94 | 53 | /** |
— | — | @@ -98,19 +57,20 @@ |
99 | 58 | */ |
100 | 59 | function efDonateRender( $input, $args, &$parser ) { |
101 | 60 | global $wgOut, $wgScriptPath; |
102 | | - |
103 | | - $parser->disableCache(); |
104 | | - |
105 | | - // if chapter exists for user's country, redirect |
106 | | - $chapter = fnDonateChapterRedirect(); |
107 | | - |
108 | | - // add JavaScript validation to <head> |
109 | | - $wgOut->addScriptFile( $wgScriptPath . '/extensions/DonationInterface/donate_interface/validate_donation.js' ); |
110 | | - |
111 | | - // display form to gather data from user |
112 | | - $output = createOutput(); |
113 | | - |
114 | | - return $output; |
| 61 | + |
| 62 | + $parser->disableCache(); |
| 63 | + |
| 64 | + // if chapter exists for user's country, redirect |
| 65 | + $chapter = fnDonateChapterRedirect(); |
| 66 | + |
| 67 | + // add JavaScript validation to <head> |
| 68 | + $wgOut->addScriptFile( $wgScriptPath . '/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js' ); |
| 69 | + |
| 70 | + |
| 71 | + //display form to gather data from user |
| 72 | + $output = fnDonateCreateOutput(); |
| 73 | + |
| 74 | + return $output; |
115 | 75 | } |
116 | 76 | |
117 | 77 | /** |
— | — | @@ -119,158 +79,152 @@ |
120 | 80 | * Payment gateway options are created with the hook "gwValue". Each potential payment |
121 | 81 | * option supplies it's value and name for the form, as well as currencies it supports. |
122 | 82 | */ |
123 | | -function createOutput() { |
124 | | - global $wgOut, $wgRequest; |
| 83 | +function fnDonateCreateOutput() { |
| 84 | + global $wgOut, $wgRequest; |
125 | 85 | |
126 | | - // declare variable |
| 86 | + // declare variable |
127 | 87 | $utm_source = ''; |
128 | 88 | $utm_medium = ''; |
129 | 89 | $utm_campaign = ''; |
130 | 90 | $referrer = ''; |
| 91 | + |
| 92 | + // set them equal to post data |
| 93 | + $utm_source = $wgRequest->getText( 'utm_source' ); |
| 94 | + $utm_medium = $wgRequest->getText( 'utm_medium' ); |
| 95 | + $utm_campaign = $wgRequest->getText( 'utm_campaign' ); |
| 96 | + $referrer = $_SERVER['HTTP_REFERER']; |
| 97 | + |
| 98 | + //get language from URL |
| 99 | + $url = $_SERVER['REQUEST_URI']; |
| 100 | + |
| 101 | + if ($url) { |
| 102 | + $getLang = explode('/', $url); |
| 103 | + $language = substr($getLang[3], 0, 2); |
| 104 | + } |
| 105 | + |
| 106 | + // error check and set "en" as default |
| 107 | + if ( !preg_match( '/^[a-z-]+$/', $language ) ) { |
| 108 | + $language = 'en'; |
| 109 | + } |
131 | 110 | |
132 | | - // set them equal to post data |
133 | | - $utm_source = $wgRequest->getText( 'utm_source' ); |
134 | | - $utm_medium = $wgRequest->getText( 'utm_medium' ); |
135 | | - $utm_campaign = $wgRequest->getText( 'utm_campaign' ); |
136 | | - $referrer = $_SERVER['HTTP_REFERER']; |
| 111 | + //get payment method gateway value and name from each gateway and create menu of options |
| 112 | + $values = ''; |
| 113 | + wfRunHooks('DonationInterface_Value', array(&$values)); |
| 114 | + |
| 115 | + $gatewayMenu = ''; |
| 116 | + |
| 117 | + foreach($values as $current) { |
| 118 | + $gatewayMenu .= Xml::option($current['display_name'], $current['form_value']); |
| 119 | + } |
| 120 | + |
| 121 | + //get available currencies |
| 122 | + foreach($values as $key) { |
| 123 | + $currencies = $key['currencies']; |
| 124 | + } |
137 | 125 | |
138 | | - // Get language from URL |
139 | | - $url = $_SERVER['REQUEST_URI']; |
140 | | - |
141 | | - if( $url ) { |
142 | | - $getLang = explode( '/', $url ); |
143 | | - $language = substr( $getLang[3], 0, 2 ); |
144 | | - } |
145 | | - |
146 | | - // error check and set "en" as default |
147 | | - if ( !preg_match( '/^[a-z-]+$/', $language ) ) { |
148 | | - $language = 'en'; |
149 | | - } |
150 | | - |
151 | | - // Get payment method gateway value and name from each gateway and create menu of options |
152 | | - $values = ''; |
153 | | - wfRunHooks( 'gwValue', array( &$values ) ); |
154 | | - |
155 | | - $gatewayMenu = ''; |
156 | | - |
157 | | - foreach( $values as $current ) { |
158 | | - $gatewayMenu .= Xml::option( $current['display_name'], $current['form_value'] ); |
159 | | - } |
160 | | - |
161 | | - // Get available currencies |
162 | | - // NOTE: currently all available currencies are accepted by all developed gateways |
163 | | - // the next version will include gateway/currency checking |
164 | | - // and inform user of gateways that aren't an option for that currency |
165 | | - foreach( $values as $key ) { |
166 | | - $currencies = $key['currencies']; |
167 | | - } |
168 | | - |
169 | 126 | $currencyMenu = ''; |
170 | 127 | |
171 | | - foreach( $currencies as $value => $fullName ) { |
172 | | - $currencyMenu .= Xml::option( $fullName, $value ); |
173 | | - } |
174 | | - |
175 | | - $output = Xml::openElement( 'form', array( 'name' => 'donate', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validateForm(this)' ) ) . |
176 | | - Xml::openElement( 'div', array( 'id' => 'mw-donation-intro' ) ) . |
177 | | - Xml::element( 'p', array( 'class' => 'mw-donation-intro-text' ), wfMsg( 'donor-intro' ) ) . |
178 | | - Xml::closeElement( 'div' ); |
179 | | - |
180 | | - $output .= Xml::hidden( 'utm_source', $utm_source ) . |
181 | | - Xml::hidden( 'utm_medium', $utm_medium ) . |
182 | | - Xml::hidden( 'utm_campaign', $utm_campaign ) . |
183 | | - Xml::hidden( 'language', $language ) . |
184 | | - Xml::hidden( 'referrer', $referrer ); |
185 | | - |
186 | | - $amount = array( |
187 | | - Xml::radioLabel( '$100', 'amount', '100', 'input_amount_3', false, array( '' ) ), |
188 | | - Xml::radioLabel( '$75', 'amount', '75', 'input_amount_2', false, array( '' ) ), |
189 | | - Xml::radioLabel( '$30', 'amount', '30', 'input_amount_1', false, array( '' ) ), |
190 | | - Xml::inputLabel( wfMsg( 'donor-other-amount' ), 'amount2', 'input_amount_other', '5' ), |
191 | | - ); |
192 | | - |
193 | | - $amountFields = '<table><tr>'; |
194 | | - foreach( $amount as $value ) { |
195 | | - $amountFields .= '<td>' . $value . '</td>'; |
196 | | - } |
197 | | - $amountFields .= '</tr></table>'; |
198 | | - |
199 | | - $output .= Xml::fieldset( wfMsg( 'donor-amount' ), $amountFields, array( 'class' => 'mw-donation-amount' ) ); |
200 | | - |
201 | | - //$output .= '<p>Some test IPs: 91.189.90.211 (uk), 217.70.184.38 (fr)</p>'; |
202 | | - |
203 | | - // Build currency options |
204 | | - $default_currency = fnDonateDefaultCurrency(); |
205 | | - |
206 | | - $currency_options = ''; |
207 | | - foreach( $currencies as $code => $name ) { |
208 | | - $selected = ''; |
209 | | - if( $code == $default_currency ) { |
210 | | - $selected = ' selected="selected"'; |
211 | | - } |
212 | | - $currency_options .= '<option value="' . $code . '"' . $selected . '>' . $name . '</option>'; |
213 | | - } |
214 | | - |
215 | | - $currencyFields = Xml::openElement( 'select', array( 'name' => 'currency_code', 'id' => 'input_currency_code' ) ) . |
216 | | - $currency_options . |
217 | | - Xml::closeElement( 'select' ); |
218 | | - |
219 | | - $output .= Xml::fieldset( wfMsg( 'donor-currency' ), $currencyFields, array( 'class' => 'mw-donation-currency' ) ); |
220 | | - |
221 | | - $gatewayFields = Xml::openElement( 'select', array( 'name' => 'payment_method', 'id' => 'select_payment_method' ) ) . |
222 | | - $gatewayMenu . |
223 | | - Xml::closeElement( 'select' ); |
224 | | - |
225 | | - $output .= Xml::fieldset( wfMsg( 'donor-gateway' ), $gatewayFields, array( 'class' => 'mw-donation-gateway' ) ); |
226 | | - |
227 | | - $publicComment = Xml::element( 'div', array( 'class' => 'mw-donation-comment-message' ), wfMsg( 'donor-comment-message' ) ) . |
228 | | - Xml::inputLabel(wfMsg( 'donor-comment-label' ), 'comment', 'comment', '30', '', array( 'maxlength' => '200' ) ) . |
229 | | - Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' ) ) . |
230 | | - Xml::checkLabel( wfMsg( 'donor-anon-message' ), 'comment-option', 'input_comment-option', true ) . |
231 | | - Xml::closeElement( 'div' ) . |
232 | | - Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' ) ) . |
233 | | - Xml::check( 'opt', true ) . |
234 | | - Xml::tags( 'span', array( 'class' => 'mw-email-agreement' ), wfMsg( 'donor-email-agreement' ) ) . |
235 | | - Xml::closeElement( 'div' ); |
236 | | - |
237 | | - $output .= Xml::fieldset( wfMsg( 'donor-comment-title' ), $publicComment, array( 'class' => 'mw-donation-public-comment' ) ); |
238 | | - |
239 | | - $output .= Xml::hidden( 'process', '_yes_' ) . |
240 | | - Xml::submitButton( wfMsg( 'donor-submit-button' ) ); |
241 | | - |
242 | | - $output .= Xml::closeElement( 'form' ); |
243 | | - |
244 | | - |
245 | | - // NOTE: For testing: show country of origin |
246 | | - //$country = fnDonateGetCountry(); |
247 | | - //$output .= Xml::element( 'p', array( 'class' => 'mw-donation-test-message' ), 'Country:' . $country ); |
248 | | - |
249 | | - // NOTE: for testing: show default currency |
250 | | - //$currencyTest = fnDonateDefaultCurrency(); |
251 | | - //$output .= Xml::element( 'p', array( 'class' => 'mw-donation-test-message' ), wfMsg( 'donor-currency' ) . $currencyTest ); |
252 | | - |
253 | | - // NOTE: for testing: show IP address |
254 | | - //$referrer = $_SERVER['HTTP_REFERER']; |
255 | | - //$output .= '<p>' . 'Referrer:' . $referrer . '</p>'; |
256 | | - |
257 | | - // for testing to show language culled from URL |
258 | | - //$output .= '<p>' . ' Language: ' . $language . '</p>'; |
259 | | - |
260 | | - return $output; |
| 128 | + foreach( $currencies as $value => $fullName ) { |
| 129 | + $currencyMenu .= Xml::option( $fullName, $value ); |
| 130 | + } |
| 131 | + |
| 132 | + $output = Xml::openElement( 'form', array( 'name' => "donate", 'method' => "post", 'action' => "", 'onsubmit' => 'return DonateValidateForm(this)' )) . |
| 133 | + Xml::openElement( 'div', array('id' => 'mw-donation-intro' )) . |
| 134 | + Xml::element( 'p', array( 'class' => 'mw-donation-intro-text' ), wfMsg( 'donate_interface-intro' )) . |
| 135 | + Xml::closeElement( 'div' ); |
| 136 | + |
| 137 | + $output .= Xml::hidden( 'utm_source', $utm_source ) . |
| 138 | + Xml::hidden( 'utm_medium', $utm_medium ) . |
| 139 | + Xml::hidden( 'utm_campaign', $utm_campaign ) . |
| 140 | + Xml::hidden( 'language', $language ) . |
| 141 | + Xml::hidden( 'referrer', $referrer ); |
| 142 | + |
| 143 | + $amount = array( |
| 144 | + Xml::radioLabel(wfMsg( 'donate_interface-big-amount-display' ), 'amount', wfMsg( 'donate_interface-big-amount-value' ), 'input_amount_3', false ), |
| 145 | + Xml::radioLabel(wfMsg( 'donate_interface-medium-amount-display' ), 'amount', wfMsg( 'donate_interface-medium-amount-value' ), 'input_amount_2', false ), |
| 146 | + Xml::radioLabel(wfMsg( 'donate_interface-small-amount-display' ), 'amount', wfMsg( 'donate_interface-small-amount-value' ), 'input_amount_1', false ), |
| 147 | + Xml::inputLabel(wfMsg( 'donate_interface-other-amount' ), 'amount2', 'input_amount_other', '5'), |
| 148 | + ); |
| 149 | + |
| 150 | + $amountFields = '<table><tr>'; |
| 151 | + foreach( $amount as $value ) { |
| 152 | + $amountFields .= '<td>' . $value . '</td>'; |
| 153 | + } |
| 154 | + $amountFields .= '</tr></table>'; |
| 155 | + |
| 156 | + $output .= Xml::fieldset(wfMsg( 'donate_interface-amount' ), $amountFields, array('class' => "mw-donation-amount")); |
| 157 | + |
| 158 | + // Build currency options |
| 159 | + $default_currency = fnDonateDefaultCurrency(); |
| 160 | + |
| 161 | + $currency_options = ''; |
| 162 | + foreach ( $currencies as $code => $name ) { |
| 163 | + $selected = ''; |
| 164 | + if ( $code == $default_currency ) { |
| 165 | + $selected = ' selected="selected"'; |
| 166 | + } |
| 167 | + $currency_options .= '<option value="' . $code . '"' . $selected . '>' . $name . '</option>'; |
| 168 | + } |
| 169 | + |
| 170 | + $currencyFields = Xml::openElement( 'select', array( 'name' => 'currency_code', 'id' => "input_currency_code" )) . |
| 171 | + $currency_options . |
| 172 | + Xml::closeElement( 'select' ); |
| 173 | + |
| 174 | + $output .= Xml::fieldset(wfMsg( 'donate_interface-currency' ), $currencyFields, array('class' => "mw-donation-currency" )); |
| 175 | + |
| 176 | + $gatewayFields = Xml::openElement( 'select', array('name' => 'payment_method', 'id' => 'select_payment_method')) . |
| 177 | + $gatewayMenu . |
| 178 | + Xml::closeElement('select'); |
| 179 | + |
| 180 | + $output .= Xml::fieldset(wfMsg( 'donate_interface-gateway' ), $gatewayFields, array( 'class' => 'mw-donation-gateway' )); |
| 181 | + |
| 182 | + $publicComment = Xml::element( 'div', array( 'class' => 'mw-donation-comment-message'), wfMsg( 'donate_interface-comment-message' )) . |
| 183 | + Xml::inputLabel(wfMsg( 'donate_interface-comment-label' ), 'comment', 'comment', '30', '', array( 'maxlength' => '200' )) . |
| 184 | + Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' )) . |
| 185 | + Xml::checkLabel( wfMsg( 'donate_interface-anon-message' ), 'comment-option', 'input_comment-option', TRUE ) . |
| 186 | + Xml::closeElement( 'div' ) . |
| 187 | + Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' )) . |
| 188 | + Xml::check( 'opt', TRUE ) . |
| 189 | + Xml::tags( 'span', array( 'class' => 'mw-email-agreement' ), wfMsg( 'donate_interface-email-agreement' )) . |
| 190 | + Xml::closeElement( 'div' ); |
| 191 | + |
| 192 | + $output .= Xml::fieldset(wfMsg( 'donate_interface-comment-title' ), $publicComment, array( 'class' => 'mw-donation-public-comment')); |
| 193 | + |
| 194 | + $output .= Xml::hidden( 'process', '_yes_' ) . |
| 195 | + Xml::submitButton(wfMsg( 'donate_interface-submit-button' )); |
| 196 | + |
| 197 | + $output .= Xml::closeElement( 'form' ); |
| 198 | + |
| 199 | + // NOTE: For testing: show country of origin |
| 200 | + //$country = fnDonateGetCountry(); |
| 201 | + //$output .= Xml::element('p', array('class' => 'mw-donation-test-message'), 'Country:' . $country); |
| 202 | + |
| 203 | + // NOTE: for testing: show default currency |
| 204 | + //$currencyTest = fnDonateDefaultCurrency(); |
| 205 | + //$output .= Xml::element('p', array('class' => 'mw-donation-test-message'), wfMsg( 'donate_interface-currency' ) . $currencyTest); |
| 206 | + |
| 207 | + // NOTE: for testing: show IP address |
| 208 | + //$referrer = $_SERVER['HTTP_REFERER']; |
| 209 | + //$output .= '<p>' . 'Referrer:' . $referrer . '</p>'; |
| 210 | + |
| 211 | + //for testing to show language culled from URL |
| 212 | + $output .= '<p>' . ' Language: ' . $language . '</p>'; |
| 213 | + |
| 214 | + return $output; |
261 | 215 | } |
262 | 216 | |
263 | | -/** |
264 | | - * Redirects user to their chosen payment processor |
265 | | - * |
266 | | - * Includes the user's input passed as GET |
267 | | - * $url for the gateway was supplied with the gwPage hook and the key |
268 | | - * matches the form value (also supplied by the gateway) |
269 | | - */ |
270 | | -function redirectToProcessorPage( $userInput, $url ) { |
271 | | - global $wgOut, $wgPaymentGatewayHost; |
| 217 | +/* |
| 218 | +* Redirects user to their chosen payment processor |
| 219 | +* |
| 220 | +* Includes the user's input passed as GET |
| 221 | +* $url for the gateway was supplied with the gwPage hook and the key |
| 222 | +* matches the form value (also supplied by the gateway) |
| 223 | +*/ |
| 224 | +function fnDonateRedirectToProcessorPage($userInput, $url) { |
| 225 | + global $wgOut,$wgPaymentGatewayHost; |
| 226 | + |
| 227 | + $chosenGateway = $userInput['payment_method']; |
272 | 228 | |
273 | | - $chosenGateway = $userInput['payment_method']; |
274 | | - |
275 | 229 | $wgOut->redirect( |
276 | 230 | $wgPaymentGatewayHost . $url[$chosenGateway] . '&amount=' . |
277 | 231 | $userInput['amount'] . '¤cy_code=' . $userInput['currency'] . |
— | — | @@ -329,9 +283,9 @@ |
330 | 284 | */ |
331 | 285 | function fnDonateChapterRedirect() { |
332 | 286 | require_once( 'chapters.inc' ); |
| 287 | + |
| 288 | + $country_code = null; |
333 | 289 | |
334 | | - $country_code = null; |
335 | | - |
336 | 290 | if( function_exists( 'fnGetCountry' ) ) { |
337 | 291 | $country_code = fnDonateGetCountry(); |
338 | 292 | } |
— | — | @@ -346,3 +300,66 @@ |
347 | 301 | } |
348 | 302 | |
349 | 303 | } |
| 304 | + |
| 305 | +function fnProcessDonateForm( $output, $article, $title, $user, $request, $wiki ) { |
| 306 | + global $wgRequest, $wgOut; |
| 307 | + |
| 308 | + // declare variables used to hold post data |
| 309 | + $userInput = array ( |
| 310 | + 'currency' => 'USD', |
| 311 | + 'amount' => '0.00', |
| 312 | + 'payment_method' => '', |
| 313 | + 'referrer' => '', |
| 314 | + 'utm_source' => '', |
| 315 | + 'utm_medium' => '', |
| 316 | + 'utm_campaign' => '', |
| 317 | + 'language' => '', |
| 318 | + 'comment' => '', |
| 319 | + 'comment-option' => '', |
| 320 | + 'email' => '', |
| 321 | + ); |
| 322 | + |
| 323 | + // if form has been submitted, assign data and redirect user to chosen payment gateway |
| 324 | + if ( isset($_POST['process']) && $_POST['process'] == "_yes_" ) { |
| 325 | + //find out which amount option was chosen for amount, redefined buttons or text box |
| 326 | + if ( isset($_POST['amount']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount')) ) { |
| 327 | + $amount = number_format( $wgRequest->getText('amount'), 2 ); |
| 328 | + } elseif ( preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount2') )) { |
| 329 | + $amount = number_format( $wgRequest->getText('amount2'), 2, '.', '' ); |
| 330 | + } else { |
| 331 | + $wgOut->addHTML( wfMsg( 'donate_interface-amount-error' ) ); |
| 332 | + return true; |
| 333 | + } |
| 334 | + |
| 335 | + // create array of user input from post data |
| 336 | + $userInput = array ( |
| 337 | + 'currency' => $wgRequest->getText( 'currency_code', 'USD' ), |
| 338 | + 'amount' => $amount, |
| 339 | + 'payment_method' => $wgRequest->getText( 'payment_method', 'payflow' ), |
| 340 | + 'referrer' => $wgRequest->getText( 'referrer', '' ), |
| 341 | + 'utm_source' => $wgRequest->getText( 'utm_source', '' ), |
| 342 | + 'utm_medium' => $wgRequest->getText( 'utm_medium', '' ), |
| 343 | + 'utm_campaign' => $wgRequest->getText( 'utm_campaign', '' ), |
| 344 | + 'language' => $wgRequest->getText( 'language', 'en' ), |
| 345 | + 'comment' => $wgRequest->getText( 'comment', '' ), |
| 346 | + 'comment-option' => $wgRequest->getText( 'comment-option', '1' ), |
| 347 | + 'email' => $wgRequest->getText( 'opt', '1' ), |
| 348 | + ); |
| 349 | + |
| 350 | + // ask payment processor extensions for their URL/page title |
| 351 | + $url = ''; |
| 352 | + |
| 353 | + if ( wfRunHooks('DonationInterface_Page', array(&$url)) ) { |
| 354 | + |
| 355 | + // send user to correct page for payment |
| 356 | + fnDonateRedirectToProcessorPage( $userInput, $url ); |
| 357 | + |
| 358 | + } else { |
| 359 | + $wgOut->addHTML( wfMsg( 'donate_interface-processing-error' ) ); |
| 360 | + } |
| 361 | + |
| 362 | + }// end if form has been submitted |
| 363 | + |
| 364 | + return true; |
| 365 | +} |
| 366 | + |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js |
— | — | @@ -0,0 +1,53 @@ |
| 2 | +//<![CDATA[ |
| 3 | +function DonateValidateForm( form ) { |
| 4 | + |
| 5 | + var minimums = { |
| 6 | + 'USD' : 1, |
| 7 | + 'GBP' : 1, // $1.26 |
| 8 | + 'EUR' : 1, // $1.26 |
| 9 | + 'AUD' : 2, // $1.35 |
| 10 | + 'CAD' : 1, // $0.84 |
| 11 | + 'CHF' : 1, // $0.85 |
| 12 | + 'CZK' : 20, // $1.03 |
| 13 | + 'DKK' : 5, // $0.85 |
| 14 | + 'HKD' : 10, // $1.29 |
| 15 | + 'HUF' : 200, // $0.97 |
| 16 | + 'JPY' : 100, // $1 |
| 17 | + 'NZD' : 2, // $1.18 |
| 18 | + 'NOK' : 10, // $1.44 |
| 19 | + 'PLN' : 5, // $1.78 |
| 20 | + 'SGD' : 2, // $1.35 |
| 21 | + 'SEK' : 10, // $1.28 |
| 22 | + }; |
| 23 | + |
| 24 | + var error = true; |
| 25 | + |
| 26 | + // Get amount selection |
| 27 | + var amount = null; |
| 28 | + for ( var i = 0; i < form.amount.length; i++ ) { |
| 29 | + if ( form.amount[i].checked ) { |
| 30 | + amount = form.amount[i].value; |
| 31 | + } |
| 32 | + } |
| 33 | + if ( form.amount2.value != "" ) { |
| 34 | + amount = form.amount2.value; |
| 35 | + } |
| 36 | + // Check amount is a real number |
| 37 | + error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
| 38 | + if ( error ) { |
| 39 | + alert( 'You must enter a valid amount.' ); |
| 40 | + } |
| 41 | + |
| 42 | + // Check amount is at least the minimum |
| 43 | + var currency = form.currency_code[form.currency_code.selectedIndex].value; |
| 44 | + if ( typeof( minimums[currency] ) == 'undefined' ) { |
| 45 | + minimums[currency] = 1; |
| 46 | + } |
| 47 | + if ( amount < minimums[currency] ) { |
| 48 | + alert( 'You must contribute at least $1'.replace('$1', minimums[currency] + ' ' + currency ) ); |
| 49 | + error = true; |
| 50 | + } |
| 51 | + |
| 52 | + return !error; |
| 53 | +} |
| 54 | +//]]> |
Property changes on: trunk/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 55 | + native |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.i18n.php |
— | — | @@ -11,18 +11,26 @@ |
12 | 12 | /** English */ |
13 | 13 | $messages['en'] = array( |
14 | 14 | 'donate_interface' => 'Support Wikimedia', |
15 | | - 'donate-desc' => 'Donation landing page that integrates gateway extensions', |
16 | | - 'donor-intro' => 'Please choose a payment method, amount, and currency.', |
17 | | - 'donor-amount' => 'Donation amount:', |
18 | | - 'donor-other-amount' => 'Other amount', |
19 | | - 'donor-currency' => 'Currency:', |
20 | | - 'donor-gateway' => 'Payment method:', |
21 | | - 'donor-submit-button' => 'Donate', |
22 | | - 'donor-comment-message' => 'Have a thought to share with the world? Put up to 200 characters here:', |
23 | | - 'donor-comment-label' => 'Comment:', |
24 | | - 'donor-anon-message' => 'Please list my name (next to my comment) on the public donor list.', |
25 | | - 'donor-email-agreement' => "I agree to receive future Wikimedia Foundation newsletters or e-mails. |
| 15 | + 'donate_interface-desc' => 'Donation landing page that integrates gateway extensions', |
| 16 | + 'donate_interface-intro' => 'Please choose a payment method, amount, and currency.', |
| 17 | + 'donate_interface-amount' => 'Donation amount:', |
| 18 | + 'donate_interface-other-amount' => 'Other amount', |
| 19 | + 'donate_interface-currency' => 'Currency:', |
| 20 | + 'donate_interface-gateway' => 'Payment method:', |
| 21 | + 'donate_interface-submit-button' => 'Donate', |
| 22 | + 'donate_interface-comment-message' => 'Have a thought to share with the world? Put up to 200 characters here:', |
| 23 | + 'donate_interface-comment-label' => 'Comment:', |
| 24 | + 'donate_interface-anon-message' => 'Please list my name (next to my comment) on the public donor list.', |
| 25 | + 'donate_interface-email-agreement' => "I agree to receive future Wikimedia Foundation newsletters or e-mails. |
26 | 26 | We will never sell or trade your information. |
27 | 27 | Our donor privacy policy can be found <a title='Donate/Donor Privacy' href='/wiki/Donate/Donor_Privacy'>here</a>", |
28 | | - 'donor-comment-title' => 'Public comment', |
| 28 | + 'donate_interface-comment-title' => 'Public comment', |
| 29 | + 'donate_interface-big-amount-display' => '$100', |
| 30 | + 'donate_interface-medium-amount-display' => '$75', |
| 31 | + 'donate_interface-small-amount-display' => '$30', |
| 32 | + 'donate_interface-big-amount-value' => '100', |
| 33 | + 'donate_interface-medium-amount-value' => '75', |
| 34 | + 'donate_interface-small-amount-value' => '30', |
| 35 | + 'donate_interface-amount-error' => '**Please enter a correct amount**', |
| 36 | + 'donate_interface-processing-error' => 'There has been an error processing your request. No processor are available.', |
29 | 37 | ); |
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -21,8 +21,10 @@ |
22 | 22 | $dir = dirname(__FILE__) . '/'; |
23 | 23 | |
24 | 24 | $wgAutoloadClasses['activemq_stomp'] = $dir . 'activemq_stomp.php'; # Tell MediaWiki to load the extension body. |
25 | | -#$wgExtensionMessagesFiles['ActiveMQSTOMP'] = $dir . 'activemq_stomp.il8n.php'; |
26 | 25 | |
| 26 | +//default variables that should be set in LocalSettings |
| 27 | +$wgStompServer = ""; |
| 28 | + |
27 | 29 | if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
28 | 30 | $wgHooks['ParserFirstCallInit'][] = 'efStompSetup'; |
29 | 31 | } else { // Otherwise do things the old fashioned way |