Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -1,16 +1,18 @@ |
2 | 2 | //<![CDATA[ |
3 | 3 | |
4 | 4 | function validate_form( form ) { |
5 | | - var msg = [ 'email address', 'first name', 'last name', 'street address', 'city', 'state', 'zip code', 'credit card number', 'the CVV from the back of your card' ]; |
| 5 | + var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ]; |
6 | 6 | |
7 | 7 | var fields = ["emailAdd","fname","lname","street","city","state","zip","card_num","cvv"], |
8 | 8 | numFields = fields.length, |
9 | 9 | i, |
10 | | - output = ''; |
| 10 | + output = '', |
| 11 | + currField = ''; |
11 | 12 | |
12 | 13 | for( i = 0; i < numFields; i++ ) { |
13 | 14 | if( document.getElementById( fields[i] ).value == '' ) { |
14 | | - output += 'Please include a value for ' + msg[i] + '.\r\n'; |
| 15 | + currField = window['payflowproGatewayErrorMsg'+ msg[i]]; |
| 16 | + output += payflowproGatewayErrorMsgJs + currField + '.\r\n'; |
15 | 17 | } |
16 | 18 | } |
17 | 19 | |
— | — | @@ -19,7 +21,7 @@ |
20 | 22 | var dotpos = form.emailAdd.value.lastIndexOf("."); |
21 | 23 | |
22 | 24 | if( apos < 1 || dotpos-apos < 2 ) { |
23 | | - output += 'Please include a valid email address'; |
| 25 | + output += payflowproGatewayErrorMsgEmail; |
24 | 26 | } |
25 | 27 | |
26 | 28 | if( output ) { |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -19,8 +19,27 @@ |
20 | 20 | global $wgRequest, $wgOut, $wgUser, $wgScriptPath; |
21 | 21 | |
22 | 22 | $this->setHeaders(); |
| 23 | + |
| 24 | + //$wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" language="javascript" src="' . $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>' ); |
| 25 | + |
| 26 | + $scriptVars = array( |
| 27 | + 'payflowproGatewayErrorMsgJs' => wfMsg( 'payflowpro_gateway-error-msg-js' ), |
| 28 | + 'payflowproGatewayErrorMsgEmail' => wfMsg( 'payflowpro_gateway-error-msg-email' ), |
| 29 | + 'payflowproGatewayErrorMsgAmount' => wfMsg( 'payflowpro_gateway-error-msg-amount' ), |
| 30 | + 'payflowproGatewayErrorMsgEmailAdd' => wfMsg( 'payflowpro_gateway-error-msg-emailAdd' ), |
| 31 | + 'payflowproGatewayErrorMsgFname' => wfMsg( 'payflowpro_gateway-error-msg-fname' ), |
| 32 | + 'payflowproGatewayErrorMsgLname' => wfMsg( 'payflowpro_gateway-error-msg-lname' ), |
| 33 | + 'payflowproGatewayErrorMsgStreet' => wfMsg( 'payflowpro_gateway-error-msg-street' ), |
| 34 | + 'payflowproGatewayErrorMsgCity' => wfMsg( 'payflowpro_gateway-error-msg-city' ), |
| 35 | + 'payflowproGatewayErrorMsgState' => wfMsg( 'payflowpro_gateway-error-msg-state' ), |
| 36 | + 'payflowproGatewayErrorMsgZip' => wfMsg( 'payflowpro_gateway-error-msg-zip' ), |
| 37 | + 'payflowproGatewayErrorMsgCardNum' => wfMsg( 'payflowpro_gateway-error-msg-card_num' ), |
| 38 | + 'payflowproGatewayErrorMsgExpiration' => wfMsg( 'payflowpro_gateway-error-msg-expiration' ), |
| 39 | + 'payflowproGatewayErrorMsgCvv' => wfMsg( 'payflowpro_gateway-error-msg-cvv' ), |
| 40 | + ); |
| 41 | + |
23 | 42 | |
24 | | - $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" language="javascript" src="' . $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>' ); |
| 43 | + //$wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
25 | 44 | |
26 | 45 | // create token if one doesn't already exist |
27 | 46 | $token = $wgUser->editToken( 'mrxc877668DwQQ' ); |
— | — | @@ -61,14 +80,17 @@ |
62 | 81 | if( isset( $_REQUEST['amount'] ) && preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount' ) ) ) { |
63 | 82 | $amount = $wgRequest->getText( 'amount' ); |
64 | 83 | } elseif( isset( $_REQUEST['amount2'] ) && preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount2' ) ) ) { |
65 | | - $amount = number_format( $wgRequest->getText( 'amount2' ), 2, '.', '' ); |
| 84 | + $amount = number_format( $wgRequest->getText( 'amount2' ), 2, '.', '' ); |
| 85 | + } elseif( isset( $_REQUEST['amount'] ) ) { |
| 86 | + $amount = '0.00'; |
66 | 87 | } else { |
67 | | - $wgOut->addHTML( wfMsg( 'payflowpro_gateway-accessible' ) ); |
68 | | - return; |
| 88 | + $wgOut->addHTML( wfMsg( 'payflowpro_gateway-accessible' ) ); |
| 89 | + return; |
69 | 90 | } |
70 | | - |
| 91 | + |
71 | 92 | // track the number of attempts the user has made |
72 | 93 | $numAttempt = ( $wgRequest->getText( 'numAttempt' ) == '' ) ? '0' : $wgRequest->getText( 'numAttempt' ); |
| 94 | + |
73 | 95 | // Populate from data |
74 | 96 | $data = array( |
75 | 97 | 'amount' => $amount, |
— | — | @@ -87,7 +109,7 @@ |
88 | 110 | 'cvv' => $wgRequest->getText( 'cvv' ), |
89 | 111 | 'currency' => $wgRequest->getText( 'currency_code' ), |
90 | 112 | 'payment_method' => $wgRequest->getText( 'payment_method' ), |
91 | | - 'order-id' => null, //will be set with $payflow_data |
| 113 | + 'order_id' => null, //will be set with $payflow_data |
92 | 114 | 'numAttempt' => $numAttempt, |
93 | 115 | 'referrer' => $wgRequest->getText( 'referrer' ), |
94 | 116 | 'utm_source' => $wgRequest->getText( 'utm_source' ), |
— | — | @@ -99,6 +121,7 @@ |
100 | 122 | 'optout' => $wgRequest->getText( 'email' ), |
101 | 123 | 'test_string' => $wgRequest->getText( 'process' ), //for showing payflow string during testing |
102 | 124 | ); |
| 125 | + |
103 | 126 | |
104 | 127 | // Get array of default account values necessary for Payflow |
105 | 128 | require_once( 'includes/payflowUser.inc' ); |
— | — | @@ -128,7 +151,8 @@ |
129 | 152 | //Display form for the first time |
130 | 153 | $this->fnPayflowDisplayForm($data, $error); |
131 | 154 | } |
132 | | - } |
| 155 | + } |
| 156 | + |
133 | 157 | } |
134 | 158 | |
135 | 159 | /** |
— | — | @@ -144,24 +168,14 @@ |
145 | 169 | require_once( 'includes/countryCodes.inc' ); |
146 | 170 | |
147 | 171 | global $wgOut, $wgLang; |
148 | | - |
| 172 | + |
149 | 173 | $form = Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ) . |
150 | 174 | Xml::openElement( 'div', array( 'id' => 'mw-creditcard-intro' ) ) . |
151 | 175 | Xml::tags( 'p', array( 'class' => 'mw-creditcard-intro-msg' ), wfMsg( 'payflowpro_gateway-form-message' ) ) . |
152 | 176 | Xml::tags( 'p', array( 'class' => 'mw-creditcard-intro-msg' ), wfMsg( 'payflowpro_gateway-form-message-2' ) ) . |
153 | 177 | Xml::closeElement( 'div' ); |
154 | 178 | |
155 | | - // add hidden fields |
156 | | - $form .= Xml::hidden( 'utm_source', $data['utm_source'] ) . |
157 | | - Xml::hidden( 'utm_medium', $data['utm_medium'] ) . |
158 | | - Xml::hidden( 'utm_campaign', $data['utm_campaign'] ) . |
159 | | - Xml::hidden( 'language', $data['language'] ) . |
160 | | - Xml::hidden( 'referrer', $data['referrer'] ) . |
161 | | - Xml::hidden( 'comment', $data['comment'] ) . |
162 | | - Xml::hidden( 'comment-option', $data['anonymous'] ) . |
163 | | - Xml::hidden( 'email', $data['optout'] ); |
164 | | - |
165 | | - // create drop down of countries |
| 179 | + // create drop down of countries |
166 | 180 | $countries = countryCodes(); |
167 | 181 | |
168 | 182 | foreach( $countries as $value => $fullName ) { |
— | — | @@ -170,11 +184,20 @@ |
171 | 185 | |
172 | 186 | // Form |
173 | 187 | $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ) . |
174 | | - Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)' ) ) . |
175 | | - Xml::element( 'legend', array( 'class' => 'mw-creditcard-amount' ), wfMsg( 'payflowpro_gateway-amount-legend' ) . $data['amount'] ) . |
176 | | - Xml::hidden( 'amount', $data['amount'] ); |
| 188 | + Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)' ) ); |
| 189 | + |
| 190 | + // add hidden fields |
| 191 | + $form .= Xml::hidden( 'utm_source', $data['utm_source'] ) . |
| 192 | + Xml::hidden( 'utm_medium', $data['utm_medium'] ) . |
| 193 | + Xml::hidden( 'utm_campaign', $data['utm_campaign'] ) . |
| 194 | + Xml::hidden( 'language', $data['language'] ) . |
| 195 | + Xml::hidden( 'referrer', $data['referrer'] ) . |
| 196 | + Xml::hidden( 'comment', $data['comment'] ) . |
| 197 | + Xml::hidden( 'comment-option', $data['anonymous'] ) . |
| 198 | + Xml::hidden( 'email', $data['optout'] ); |
177 | 199 | |
178 | 200 | $donorInput = array( |
| 201 | + Xml::inputLabel(wfMsg( 'payflowpro_gateway-amount-legend' ), 'amount', 'input_amount_other', '7', $data['amount'] ) . '<span class="creditcard_error_msg">' . ' ' . $error['invalidamount'] . '</span>', |
179 | 202 | Xml::inputLabel( wfMsg( 'payflowpro_gateway-donor-email' ), 'emailAdd', 'emailAdd', '30', $data['email'], array( 'maxlength' => '64' ) ) . '<span class="creditcard_error_msg">' . ' ' . $error['emailAdd'] . '</span>', |
180 | 203 | Xml::inputLabel( wfMsg( 'payflowpro_gateway-donor-fname' ), 'fname', 'fname', '20', $data['fname'], array( 'maxlength' => '15', 'class' => 'required' ) ) . '<span class="creditcard_error_msg">' . ' ' . $error['fname'] . '</span>', |
181 | 204 | Xml::inputLabel( wfMsg( 'payflowpro_gateway-donor-mname' ), 'mname', 'mname', '20', $data['mname'], array( 'maxlength' => '15' ) ), |
— | — | @@ -272,7 +295,7 @@ |
273 | 296 | wfMsg( 'payflowpro_gateway-donor-currency-msg', $data['currency'] ) |
274 | 297 | ); |
275 | 298 | // Theming |
276 | | - global $wgDonationInterfaceTomasSkin; |
| 299 | + /*global $wgDonationInterfaceTomasSkin; |
277 | 300 | |
278 | 301 | if ( $wgDonationInterfaceTomasSkin ) { |
279 | 302 | $language = 'en'; |
— | — | @@ -297,6 +320,8 @@ |
298 | 321 | } else { |
299 | 322 | $wgOut->addHTML( $form ); |
300 | 323 | } |
| 324 | + */ |
| 325 | + $wgOut->addHTML( $form ); |
301 | 326 | } |
302 | 327 | |
303 | 328 | /** |
— | — | @@ -304,6 +329,8 @@ |
305 | 330 | */ |
306 | 331 | private function fnPayflowValidateForm( $data, &$error ) { |
307 | 332 | global $wgOut; |
| 333 | + |
| 334 | + $error = ''; |
308 | 335 | |
309 | 336 | // begin with no errors |
310 | 337 | $error_result = '0'; |
— | — | @@ -311,17 +338,17 @@ |
312 | 339 | // create the human-speak message for required fields |
313 | 340 | // does not include fields that are not required |
314 | 341 | $msg = array( |
315 | | - 'amount' => 'donation amount', |
316 | | - 'emailAdd' => 'email address', |
317 | | - 'fname' => 'first name', |
318 | | - 'lname' => 'last name', |
319 | | - 'street' => 'street address', |
320 | | - 'city' => 'city', |
321 | | - 'state' => 'state', |
322 | | - 'zip' => 'zip code', |
323 | | - 'card_num' => 'credit card number', |
324 | | - 'expiration' => "card's expiration date", |
325 | | - 'cvv' => 'the CVV from the back of your card', |
| 342 | + 'amount' => wfMsg( 'payflowpro_gateway-error-msg-amount' ), |
| 343 | + 'emailAdd' => wfMsg( 'payflowpro_gateway-error-msg-emailAdd' ), |
| 344 | + 'fname' => wfMsg( 'payflowpro_gateway-error-msg-fname' ), |
| 345 | + 'lname' => wfMsg( 'payflowpro_gateway-error-msg-lname' ), |
| 346 | + 'street' => wfMsg( 'payflowpro_gateway-error-msg-street' ), |
| 347 | + 'city' => wfMsg( 'payflowpro_gateway-error-msg-city' ), |
| 348 | + 'state' => wfMsg( 'payflowpro_gateway-error-msg-state' ), |
| 349 | + 'zip' => wfMsg( 'payflowpro_gateway-error-msg-zip' ), |
| 350 | + 'card_num' => wfMsg( 'payflowpro_gateway-error-msg-card_num' ), |
| 351 | + 'expiration' => wfMsg( 'payflowpro_gateway-error-msg-expiration' ), |
| 352 | + 'cvv' => wfMsg( 'payflowpro_gateway-error-msg-cvv' ), |
326 | 353 | ); |
327 | 354 | |
328 | 355 | // find all empty fields and create message |
— | — | @@ -334,7 +361,13 @@ |
335 | 362 | } |
336 | 363 | } |
337 | 364 | } |
338 | | - |
| 365 | + |
| 366 | + //check amount |
| 367 | + if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data['amount'] ) || $data['amount'] == "0.00" ) { |
| 368 | + $error['invalidamount'] = wfMsg( 'payflowpro_gateway-error-msg-invalid-amount' ); |
| 369 | + $error_result = '1'; |
| 370 | + } |
| 371 | + |
339 | 372 | // is email address valid? |
340 | 373 | $isEmail = User::isValidEmailAddr( $data['email'] ); |
341 | 374 | |
— | — | @@ -343,15 +376,15 @@ |
344 | 377 | $error['emailAdd'] = wfMsg( 'payflowpro_gateway-error-msg-email' ); |
345 | 378 | $error_result = '1'; |
346 | 379 | } |
347 | | - |
| 380 | + |
348 | 381 | // validate that credit card number entered is correct for the brand |
349 | 382 | switch( $data['card'] ) { |
350 | 383 | case 'american': |
351 | 384 | // pattern for Amex |
352 | | - $pattern = "/^3[47][0-9]{13}$/"; |
| 385 | + $pattern = '/^3[47][0-9]{13}$/'; |
353 | 386 | |
354 | 387 | // if the pattern doesn't match |
355 | | - if( !preg_match( $pattern, $data['card_num'] ) ) { |
| 388 | + if( !preg_match( $pattern, $data['card_num'] ) ) { |
356 | 389 | $error_result = '1'; |
357 | 390 | $error['card'] = wfMsg( 'payflowpro_gateway-error-msg-amex' ); |
358 | 391 | } |
— | — | @@ -360,7 +393,7 @@ |
361 | 394 | |
362 | 395 | case 'mastercard': |
363 | 396 | // pattern for Mastercard |
364 | | - $pattern = "/^5[1-5][0-9]{14}$/"; |
| 397 | + $pattern = '/^5[1-5][0-9]{14}$/'; |
365 | 398 | |
366 | 399 | // if pattern doesn't match |
367 | 400 | if( !preg_match( $pattern, $data['card_num'] ) ) { |
— | — | @@ -372,7 +405,7 @@ |
373 | 406 | |
374 | 407 | case 'visa': |
375 | 408 | // pattern for Visa |
376 | | - $pattern = "/^4[0-9]{12}(?:[0-9]{3})?$/"; |
| 409 | + $pattern = '/^4[0-9]{12}(?:[0-9]{3})?$/'; |
377 | 410 | |
378 | 411 | // if pattern doesn't match |
379 | 412 | if( !preg_match( $pattern, $data['card_num'] ) ) { |
— | — | @@ -381,8 +414,9 @@ |
382 | 415 | } |
383 | 416 | |
384 | 417 | break; |
| 418 | + |
385 | 419 | } // end switch |
386 | | - |
| 420 | + |
387 | 421 | return $error_result; |
388 | 422 | } |
389 | 423 | |
— | — | @@ -398,24 +432,24 @@ |
399 | 433 | |
400 | 434 | // create payflow query string, include string lengths |
401 | 435 | $queryArray = array( |
402 | | - 'TRXTYPE' => $payflow_data[trxtype], |
403 | | - 'TENDER' => $payflow_data[tender], |
404 | | - 'USER' => $payflow_data[user], |
405 | | - 'VENDOR' => $payflow_data[vendor], |
406 | | - 'PARTNER' => $payflow_data[partner], |
407 | | - 'PWD' => $payflow_data[password], |
408 | | - 'ACCT' => $data[card_num], |
409 | | - 'EXPDATE' => $data[expiration], |
410 | | - 'AMT' => $data[amount], |
411 | | - 'FIRSTNAME' => $data[fname], |
412 | | - 'LASTNAME' => $data[lname], |
413 | | - 'STREET' => $data[street], |
414 | | - 'ZIP' => $data[zip], |
415 | | - 'INVNUM' => $payflow_data[order_id], |
416 | | - 'CVV2' => $data[cvv], |
417 | | - 'CURRENCY' => $data[currency], |
418 | | - 'VERBOSITY' => $payflow_data[verbosity], |
419 | | - 'CUSTIP' => $payflow_data[user_ip], |
| 436 | + 'TRXTYPE' => $payflow_data['trxtype'], |
| 437 | + 'TENDER' => $payflow_data['tender'], |
| 438 | + 'USER' => $payflow_data['user'], |
| 439 | + 'VENDOR' => $payflow_data['vendor'], |
| 440 | + 'PARTNER' => $payflow_data['partner'], |
| 441 | + 'PWD' => $payflow_data['password'], |
| 442 | + 'ACCT' => $data['card_num'], |
| 443 | + 'EXPDATE' => $data['expiration'], |
| 444 | + 'AMT' => $data['amount'], |
| 445 | + 'FIRSTNAME' => $data['fname'], |
| 446 | + 'LASTNAME' => $data['lname'], |
| 447 | + 'STREET' => $data['street'], |
| 448 | + 'ZIP' => $data['zip'], |
| 449 | + 'INVNUM' => $payflow_data['order_id'], |
| 450 | + 'CVV2' => $data['cvv'], |
| 451 | + 'CURRENCY' => $data['currency'], |
| 452 | + 'VERBOSITY' => $payflow_data['verbosity'], |
| 453 | + 'CUSTIP' => $payflow_data['user_ip'], |
420 | 454 | ); |
421 | 455 | |
422 | 456 | foreach( $queryArray as $name => $value ) { |
— | — | @@ -436,10 +470,10 @@ |
437 | 471 | $headers[] = 'Content-Length : ' . strlen( $payflow_query ); |
438 | 472 | $headers[] = 'X-VPS-Client-Timeout: 45'; |
439 | 473 | $headers[] = 'X-VPS-Request-ID:' . $payflow_data['order_id']; |
440 | | - |
441 | 474 | $ch = curl_init(); |
442 | 475 | $paypalPostTo = isset ( $wgDonationTestingMode ) ? 'testingurl' : 'paypalurl'; |
443 | | - curl_setopt( $ch, CURLOPT_URL, $payflow_data[ $paypalPostTo ] ); |
| 476 | + //curl_setopt( $ch, CURLOPT_URL, $payflow_data[ $paypalPostTo ] ); |
| 477 | + curl_setopt($ch, CURLOPT_URL, $payflow_data['testingurl']); |
444 | 478 | curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); |
445 | 479 | curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent ); |
446 | 480 | curl_setopt( $ch, CURLOPT_HEADER, 1 ); |
— | — | @@ -528,13 +562,13 @@ |
529 | 563 | // give user a second chance to enter incorrect data |
530 | 564 | } elseif( ( $errorCode == '3' ) && ( $data['numAttempt'] < '2' ) ) { |
531 | 565 | // pass responseMsg as an array key as required by displayForm |
532 | | - $tryAgainResponse[$responseMsg] = $responseMsg; |
533 | | - $this->fnPayflowDisplayForm( $data, $tryAgainResponse ); |
| 566 | + $tryAgainResponse[$responseMsg] = $responseMsg; |
| 567 | + $this->fnPayflowDisplayForm( $data, $tryAgainResponse ); |
534 | 568 | // if declined or if user has already made two attempts, decline |
535 | 569 | } elseif( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '2' ) ) { |
536 | | - $this->fnPayflowDisplayDeclinedResults( $responseMsg ); |
| 570 | + $this->fnPayflowDisplayDeclinedResults( $responseMsg ); |
537 | 571 | } elseif( ( $errorCode == '4' ) ) { |
538 | | - $this->fnPayflowDisplayOtherResults( $responseMsg ); |
| 572 | + $this->fnPayflowDisplayOtherResults( $responseMsg ); |
539 | 573 | } |
540 | 574 | |
541 | 575 | }// end display results |
— | — | @@ -608,8 +642,16 @@ |
609 | 643 | function fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ) { |
610 | 644 | global $wgOut; |
611 | 645 | $transaction = ''; |
| 646 | + $tracked = ''; |
612 | 647 | |
613 | 648 | require_once( 'includes/countryCodes.inc' ); |
| 649 | + |
| 650 | + //save data to the contribution tracking database |
| 651 | + if ( !$tracked = $this->fnPayflowSaveContributionTracking( $data ) ) { |
| 652 | + $when = time(); |
| 653 | + wfDebugLog( 'payflowpro_gateway', 'Unable to save data to the contribution_tracking table ' . $when ); |
| 654 | + } |
| 655 | + |
614 | 656 | |
615 | 657 | // display response message |
616 | 658 | $wgOut->addHTML( '<h3 class="response_message">' . $responseMsg . '</h3>' ); |
— | — | @@ -638,6 +680,10 @@ |
639 | 681 | $transaction['country_code'] = $data['country']; |
640 | 682 | // put all data into one array |
641 | 683 | $transaction += array_merge( $data, $responseArray ); |
| 684 | + |
| 685 | + //enable if we need this to get the Civi data to display correctly |
| 686 | + $transaction['optout'] = ($transaction['optout'] == "1") ? '0' : '1'; |
| 687 | + $transaction['anonymous'] = ($transaction['anonymous'] == "1") ? '0' : '1'; |
642 | 688 | |
643 | 689 | // hook to call stomp functions |
644 | 690 | wfRunHooks( 'gwStomp', array( &$transaction ) ); |
— | — | @@ -672,5 +718,39 @@ |
673 | 719 | // display response message |
674 | 720 | $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . $responseMsg . '</h3>' ); |
675 | 721 | } |
| 722 | + |
| 723 | + function fnPayflowSaveContributionTracking( $data ) { |
| 724 | + $db = payflowGatewayConnection(); |
| 725 | + |
| 726 | + if (!$db) { return true ; } |
676 | 727 | |
| 728 | + $ts = $db->timestamp(); |
| 729 | + |
| 730 | + $tracked_contribution = array( |
| 731 | + 'note' => $data['comment'], |
| 732 | + 'referrer' => $data['referrer'], |
| 733 | + 'anonymous' => $data['anonymous'], |
| 734 | + 'utm_source' => $data['utm_source'], |
| 735 | + 'utm_medium' => $data['utm_medium'], |
| 736 | + 'utm_campaign' => $data['utm_campaign'], |
| 737 | + 'optout' => $data['optout'], |
| 738 | + 'language' => $data['language'], |
| 739 | + 'ts' => $ts, |
| 740 | + ); |
| 741 | + |
| 742 | + // Make all empty strings NULL |
| 743 | + foreach ($tracked_contribution as $key => $value) { |
| 744 | + if ($value === '') { |
| 745 | + $tracked_contribution[$key] = NULL; |
| 746 | + } |
| 747 | + } |
| 748 | + |
| 749 | + // Store the contribution data |
| 750 | + if ($db->insert( 'contribution_tracking', $tracked_contribution ) ) { |
| 751 | + return true; |
| 752 | + } else { return false; } |
| 753 | + |
| 754 | + } |
| 755 | + |
| 756 | + |
677 | 757 | } // end class |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php |
— | — | @@ -38,10 +38,23 @@ |
39 | 39 | 'payflowpro_gateway-donor-submit' => 'Donate', |
40 | 40 | 'payflowpro_gateway-donor-currency-msg' => 'This donation is being made in $1', |
41 | 41 | 'payflowpro_gateway-error-msg' => 'Please enter your $1', |
| 42 | + 'payflowpro_gateway-error-msg-js' => 'Please enter your ', |
| 43 | + 'payflowpro_gateway-error-msg-invalid-amount' => '**Please enter a valid amount**', |
42 | 44 | 'payflowpro_gateway-error-msg-email' => '**Please enter a valid e-mail address**', |
43 | 45 | 'payflowpro_gateway-error-msg-amex' => '**Please enter a correct card number for American Express.**', |
44 | 46 | 'payflowpro_gateway-error-msg-mc' => '**Please enter a correct card number for MasterCard.**', |
45 | 47 | 'payflowpro_gateway-error-msg-visa' => '**Please enter a correct card number for Visa.**', |
| 48 | + 'payflowpro_gateway-error-msg-amount' => 'donation amount', |
| 49 | + 'payflowpro_gateway-error-msg-emailAdd' => 'email address', |
| 50 | + 'payflowpro_gateway-error-msg-fname' => 'first name', |
| 51 | + 'payflowpro_gateway-error-msg-lname' => 'last name', |
| 52 | + 'payflowpro_gateway-error-msg-street' => 'street address', |
| 53 | + 'payflowpro_gateway-error-msg-city' => 'city', |
| 54 | + 'payflowpro_gateway-error-msg-state' => 'state', |
| 55 | + 'payflowpro_gateway-error-msg-zip' => 'zip code', |
| 56 | + 'payflowpro_gateway-error-msg-card_num' => 'credit card number', |
| 57 | + 'payflowpro_gateway-error-msg-expiration' => "card's expiration date", |
| 58 | + 'payflowpro_gateway-error-msg-cvv' => 'the CVV from the back of your card', |
46 | 59 | 'payflowpro_gateway-response-0' => 'Your transaction has been approved. |
47 | 60 | Thank you for your donation!', |
48 | 61 | 'payflowpro_gateway-response-126' => 'Your transaction is pending approval.', |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -35,6 +35,29 @@ |
36 | 36 | $wgPayflowProUserID = ''; //if one or more users are set up, authorized user ID, else same as VENDOR |
37 | 37 | $wgPayflowProPassword = ''; //merchant login password |
38 | 38 | |
| 39 | +$wgPayflowGatewayDBserver = $wgDBserver; |
| 40 | +$wgPayflowGatewayDBname = $wgDBname; |
| 41 | +$wgPayflowGatewayDBuser = $wgDBuser; |
| 42 | +$wgPayflowGatewayDBpassword = $wgDBpassword; |
| 43 | + |
| 44 | +function payflowGatewayConnection() { |
| 45 | + global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname; |
| 46 | + global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword; |
| 47 | + |
| 48 | + static $db; |
| 49 | + |
| 50 | + if ( !$db ) { |
| 51 | + $db = new DatabaseMysql( |
| 52 | + $wgPayflowGatewayDBserver, |
| 53 | + $wgPayflowGatewayDBuser, |
| 54 | + $wgPayflowGatewayDBpassword, |
| 55 | + $wgPayflowGatewayDBname ); |
| 56 | + $db->query( "SET names utf8" ); |
| 57 | + } |
| 58 | + |
| 59 | + return $db; |
| 60 | +} |
| 61 | + |
39 | 62 | /** |
40 | 63 | * Hooks required to interface with the donation extension (include <donate> on page) |
41 | 64 | * |
— | — | @@ -88,7 +111,8 @@ |
89 | 112 | function pfpGatewayPage( &$url ) { |
90 | 113 | global $wgScript; |
91 | 114 | |
92 | | - $url['payflow'] = 'https://payments.wikimedia.org/index.php' . '?title=Special:PayflowProGateway'; |
93 | | - |
| 115 | + //$url['payflow'] = 'https://payments.wikimedia.org/index.php' . '?title=Special:PayflowProGateway'; |
| 116 | + //$url['payflow'] = 'http://c2p2.fkbuild.com/index.php?title=Special:PayflowProGateway'; |
| 117 | + $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway"; |
94 | 118 | return true; |
95 | 119 | } |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php |
— | — | @@ -27,13 +27,13 @@ |
28 | 28 | $wgExtensionMessagesFiles['DonateInterface'] = $dir . 'donate_interface.i18n.php'; |
29 | 29 | |
30 | 30 | $wgHooks['ParserFirstCallInit'][] = 'efDonateSetup'; |
31 | | -$wgHooks['MediaWikiPerformAction'][] = 'fnProcessDonateForm'; |
| 31 | +$wgHooks['DonationInterface_DisplayForm'][] = 'fnProcessDonationForm'; |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Create <donate /> tag to include landing page donation form |
35 | 35 | */ |
36 | 36 | function efDonateSetup( &$parser ) { |
37 | | - global $wgHooks; |
| 37 | + global $wgHooks, $wgRequest; |
38 | 38 | |
39 | 39 | //load extension messages |
40 | 40 | wfLoadExtensionMessages( 'DonateInterface' ); |
— | — | @@ -41,14 +41,15 @@ |
42 | 42 | $parser->disableCache(); |
43 | 43 | |
44 | 44 | $parser->setHook( 'donate', 'efDonateRender' ); |
45 | | - |
| 45 | + |
46 | 46 | //process form |
47 | | - wfRunHooks( 'MediaWikiPerformAction', array( $output, |
48 | | -$article, $title, $user, $request, $this)); |
| 47 | + wfRunHooks( 'DonationInterface_DisplayForm' ); |
49 | 48 | |
50 | 49 | return true; |
51 | 50 | } |
52 | 51 | |
| 52 | + |
| 53 | + |
53 | 54 | /** |
54 | 55 | * Function called by the <donate> parser tag |
55 | 56 | * |
— | — | @@ -61,7 +62,8 @@ |
62 | 63 | $parser->disableCache(); |
63 | 64 | |
64 | 65 | // if chapter exists for user's country, redirect |
65 | | - $chapter = fnDonateChapterRedirect(); |
| 66 | + //not currently in use - in place for adding it when ready |
| 67 | + //$chapter = fnDonateChapterRedirect(); |
66 | 68 | |
67 | 69 | // add JavaScript validation to <head> |
68 | 70 | $wgOut->addScriptFile( $wgScriptPath . '/extensions/DonationInterface/donate_interface/donate_interface_validate_donation.js' ); |
— | — | @@ -139,7 +141,8 @@ |
140 | 142 | Xml::hidden( 'utm_medium', $utm_medium ) . |
141 | 143 | Xml::hidden( 'utm_campaign', $utm_campaign ) . |
142 | 144 | Xml::hidden( 'language', $language ) . |
143 | | - Xml::hidden( 'referrer', $referrer ); |
| 145 | + Xml::hidden( 'referrer', $referrer ) . |
| 146 | + XML::hidden('process', '_yes_'); |
144 | 147 | |
145 | 148 | $amount = array( |
146 | 149 | Xml::radioLabel(wfMsg( 'donate_interface-big-amount-display' ), 'amount', wfMsg( 'donate_interface-big-amount-value' ), 'input_amount_3', false ), |
— | — | @@ -234,8 +237,8 @@ |
235 | 238 | |
236 | 239 | $wgOut->redirect( |
237 | 240 | $url[$chosenGateway] . '&' . $redirectionData |
238 | | - ); |
239 | | - |
| 241 | + ); |
| 242 | + |
240 | 243 | } |
241 | 244 | |
242 | 245 | /** |
— | — | @@ -302,7 +305,7 @@ |
303 | 306 | |
304 | 307 | } |
305 | 308 | |
306 | | -function fnProcessDonateForm( $output, $article, $title, $user, $request, $wiki ) { |
| 309 | +function fnProcessDonationForm( ) { |
307 | 310 | global $wgRequest, $wgOut; |
308 | 311 | |
309 | 312 | // declare variables used to hold post data |
— | — | @@ -320,8 +323,8 @@ |
321 | 324 | 'email' => '', |
322 | 325 | ); |
323 | 326 | |
324 | | - // if form has been submitted, assign data and redirect user to chosen payment gateway |
325 | | - if ( $wgRequest->wasPosted() ) { |
| 327 | + // if form has been submitted, assign data and redirect user to chosen payment gateway |
| 328 | + if ($_POST['process'] == "_yes_") { |
326 | 329 | //find out which amount option was chosen for amount, redefined buttons or text box |
327 | 330 | if ( isset($_POST['amount']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount')) ) { |
328 | 331 | $amount = number_format( $wgRequest->getText('amount'), 2 ); |
— | — | @@ -351,7 +354,7 @@ |
352 | 355 | $url = ''; |
353 | 356 | |
354 | 357 | if ( wfRunHooks('DonationInterface_Page', array(&$url)) ) { |
355 | | - |
| 358 | + |
356 | 359 | // send user to correct page for payment |
357 | 360 | fnDonateRedirectToProcessorPage( $userInput, $url ); |
358 | 361 | |
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -71,6 +71,7 @@ |
72 | 72 | global $wgStompServer, $wgStompQueueName; |
73 | 73 | |
74 | 74 | $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test'; |
| 75 | + |
75 | 76 | // include a library |
76 | 77 | require_once("Stomp.php"); |
77 | 78 | |