Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -120,8 +120,7 @@ |
121 | 121 | //Display form for the first time |
122 | 122 | $this->fnPayflowDisplayForm($data, $error); |
123 | 123 | } |
124 | | - } // end $success |
125 | | - |
| 124 | + } |
126 | 125 | } |
127 | 126 | |
128 | 127 | /* |
— | — | @@ -169,17 +168,17 @@ |
170 | 169 | XML::hidden('amount', $data['amount']); |
171 | 170 | |
172 | 171 | $donorInput = array( |
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>', |
| 172 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-email' ), "emailAdd", "emailAdd", "30", $data['email'], array('maxlength' => "64")) . '<span class="creditcard_error_msg">'. " " . $error['emailAdd'].'</span>', |
| 173 | + 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>', |
| 174 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "15")), |
| 175 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "15")) . '<span class="creditcard_error_msg">'. " " . $error['lname'].'</span>', |
| 176 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "30")) . '<span class="creditcard_error_msg">'. " " . $error['street'].'</span>', |
| 177 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-city' ), "city", "city", "20", $data['city'], array('maxlength' => "20")) . '<span class="creditcard_error_msg">'. " " . $error['city'].'</span>', |
179 | 178 | XML::label(wfMsg( 'payflowpro_gateway-donor-state' ), "state") . |
180 | 179 | XML::openElement('select', array('name' => "state", 'id' => "state", 'value' => $data['state'])) . |
181 | 180 | statesMenuXML() . |
182 | 181 | XML::closeElement('select') . '<span class="creditcard_error_msg">'. " " . $error['state'].'</span>', |
183 | | - XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "18")) . '<span class="creditcard_error_msg">'. " " . $error['zip'].'</span>', |
| 182 | + XML::inputLabel(wfMsg( 'payflowpro_gateway-donor-postal' ), "zip", "zip", "15", $data['zip'], array('maxlength' => "9")) . '<span class="creditcard_error_msg">'. " " . $error['zip'].'</span>', |
184 | 183 | XML::label(wfMsg( 'payflowpro_gateway-donor-country' ), "country") . |
185 | 184 | XML::openElement('select', array('name' => "country", 'id' => "country", 'value' => $data['country'])) . |
186 | 185 | $countryMenu . |
— | — | @@ -213,7 +212,6 @@ |
214 | 213 | $expMos = ''; |
215 | 214 | |
216 | 215 | for($i=1; $i<13; $i++) { |
217 | | - //$expMos .= XML::option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); |
218 | 216 | $expMos .= XML::option($wgLang->getMonthName( $i ), str_pad($i, 2, '0', STR_PAD_LEFT)); |
219 | 217 | |
220 | 218 | } |
— | — | @@ -303,8 +301,7 @@ |
304 | 302 | } |
305 | 303 | } |
306 | 304 | |
307 | | - //is email address valid? |
308 | | - //$isEmail = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email']); |
| 305 | + //is email address valid |
309 | 306 | $isEmail = User::isValidEmailAddr($data['email']); |
310 | 307 | |
311 | 308 | //create error message (supercedes empty field message) |
— | — | @@ -318,7 +315,7 @@ |
319 | 316 | { |
320 | 317 | case 'american' : |
321 | 318 | //pattern for Amex |
322 | | - $pattern = "/^([34|37]{2})([0-9]{13})$/"; |
| 319 | + $pattern = "/^3[47][0-9]{13}$/"; |
323 | 320 | |
324 | 321 | //if the pattern doesn't match |
325 | 322 | if (!preg_match($pattern,$data['card_num'])) { |
— | — | @@ -330,7 +327,7 @@ |
331 | 328 | |
332 | 329 | case 'mastercard' : |
333 | 330 | //pattern for Mastercard |
334 | | - $pattern = "/^([51|52|53|54|55]{2})([0-9]{14})$/"; |
| 331 | + $pattern = "/^5[1-5][0-9]{14}$/"; |
335 | 332 | |
336 | 333 | //if pattern doesn't match |
337 | 334 | if (!preg_match($pattern,$data['card_num'])) { |
— | — | @@ -342,7 +339,7 @@ |
343 | 340 | |
344 | 341 | case 'visa' : |
345 | 342 | //pattern for Visa |
346 | | - $pattern = "/^([4]{1})([0-9]{12,15})$/"; |
| 343 | + $pattern = "/^4[0-9]{12}(?:[0-9]{3})?$/"; |
347 | 344 | |
348 | 345 | //if pattern doesn't match |
349 | 346 | if (!preg_match($pattern,$data['card_num'])) { |
— | — | @@ -368,15 +365,45 @@ |
369 | 366 | private function fnPayflowProcessTransaction($data, $payflow_data) { |
370 | 367 | global $wgOut; |
371 | 368 | |
372 | | - /* Create name-value pair query string */ |
| 369 | + //create payflow query string, include string lengths |
| 370 | + $queryArray = array( |
| 371 | + 'TRXTYPE' => $payflow_data[trxtype], |
| 372 | + 'TENDER' => $payflow_data[tender], |
| 373 | + 'USER' => $payflow_data[user], |
| 374 | + 'VENDOR' => $payflow_data[vendor], |
| 375 | + 'PARTNER' => $payflow_data[partner], |
| 376 | + 'PWD' => $payflow_data[password], |
| 377 | + 'ACCT' => $data[card_num], |
| 378 | + 'EXPDATE' => $data[expiration], |
| 379 | + 'AMT' => $data[amount], |
| 380 | + 'FIRSTNAME' => $data[fname], |
| 381 | + 'LASTNAME' => $data[lname], |
| 382 | + 'STREET' => $data[street], |
| 383 | + 'ZIP' => $data[zip], |
| 384 | + 'INVNUM' => $payflow_data[order_id], |
| 385 | + 'CVV2' => $data[cvv], |
| 386 | + 'CURRENCY' => $data[currency], |
| 387 | + 'VERBOSITY' => $payflow_data[verbosity], |
| 388 | + 'CUSTIP' => $payflow_data[user_ip], |
| 389 | + ); |
| 390 | + |
| 391 | + foreach ($queryArray as $name => $value) { |
| 392 | + $query[] = $name . '[' . strlen($value) . ']=' . $value; |
| 393 | + } |
| 394 | + |
| 395 | + $queryString = implode('&', $query); |
| 396 | + |
| 397 | + /* FOR TESTING: This is what the NV pair looks like, with string length included |
373 | 398 | $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]"; |
| 399 | + */ |
374 | 400 | |
| 401 | + $payflow_query = $queryString; |
375 | 402 | |
376 | 403 | // assign header data necessary for the curl_setopt() function |
377 | | - $user_agent = $_SERVER['HTTP_USER_AGENT']; |
378 | | - $headers[] = "Content-Type: text/xml"; |
| 404 | + $user_agent = Http::userAgent(); |
| 405 | + $headers[] = "Content-Type: text/namevalue"; |
379 | 406 | $headers[] = "Content-Length : " . strlen ($payflow_query); |
380 | | - $headers[] = "X-VPS-Timeout: 45"; |
| 407 | + $headers[] = "X-VPS-Client-Timeout: 45"; |
381 | 408 | $headers[] = "X-VPS-Request-ID:" . $payflow_data['order_id']; |
382 | 409 | |
383 | 410 | $ch = curl_init(); |
— | — | @@ -401,15 +428,17 @@ |
402 | 429 | $result = curl_exec($ch); |
403 | 430 | $headers = curl_getinfo($ch); |
404 | 431 | |
405 | | - if ($headers['http_code'] != 200) { |
| 432 | + if ($headers['http_code'] != 200 && $headers['http_code'] != 403) { |
406 | 433 | sleep(5); |
407 | | - } else if ($headers['http_code'] == 200) { |
| 434 | + } else if ($headers['http_code'] == 200 || $headers['http_code'] == 403) { |
408 | 435 | break; |
409 | 436 | } |
410 | 437 | } |
411 | 438 | |
412 | 439 | if ($headers['http_code'] != 200) { |
413 | 440 | $wgOut->addHTML('<h3>No response from credit card processor. Please try again later!</h3><p>'); |
| 441 | + $when = time(); |
| 442 | + wfDebugLog( 'payflowpro_gateway', 'No response from credit card processor ' . $when ); |
414 | 443 | curl_close($ch); |
415 | 444 | exit; |
416 | 445 | } |
— | — | @@ -475,6 +504,8 @@ |
476 | 505 | // if declined or if user has already made two attempts, decline |
477 | 506 | } else if (($errorCode == '2') || ($data['numAttempt'] >= '2')) { |
478 | 507 | $this->fnPayflowDisplayDeclinedResults($responseMsg); |
| 508 | + } else if (($errorCode == '4')) { |
| 509 | + $this->fnPayflowDisplayOtherResults($responseMsg); |
479 | 510 | } |
480 | 511 | |
481 | 512 | }// end display results |
— | — | @@ -607,6 +638,26 @@ |
608 | 639 | $wgOut->addHTML('<h3 class="response_message">' . $declinedDefault . $responseMsg . "</h3>"); |
609 | 640 | |
610 | 641 | |
| 642 | + } |
| 643 | + |
| 644 | + /* |
| 645 | + * Display response message when there is a system error unrelated to user's entry |
| 646 | + * |
| 647 | + * @params |
| 648 | + * $data array of posted data from form |
| 649 | + * $responseMsg message supplied by getResults function |
| 650 | + * |
| 651 | + */ |
| 652 | + function fnPayflowDisplayOtherResults($responseMsg) { |
| 653 | + global $wgOut; |
| 654 | + |
| 655 | + //general decline message |
| 656 | + $declinedDefault = wfMsg( 'php-response-declined' ); |
| 657 | + |
| 658 | + // display response message |
| 659 | + $wgOut->addHTML('<h3 class="response_message">' . $declinedDefault . $responseMsg . "</h3>"); |
| 660 | + |
| 661 | + |
611 | 662 | } |
612 | 663 | |
613 | 664 | |
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php |
— | — | @@ -118,8 +118,11 @@ |
119 | 119 | } |
120 | 120 | |
121 | 121 | //get available currencies |
| 122 | + |
122 | 123 | foreach($values as $key) { |
123 | | - $currencies = $key['currencies']; |
| 124 | + if (isset($key['currencies'])) { |
| 125 | + $currencies = $key['currencies']; |
| 126 | + } else { $currencies = array( 'USD' => "USD: U.S. Dollar" ); } |
124 | 127 | } |
125 | 128 | |
126 | 129 | $currencyMenu = ''; |
— | — | @@ -223,18 +226,18 @@ |
224 | 227 | function fnDonateRedirectToProcessorPage($userInput, $url) { |
225 | 228 | global $wgOut,$wgPaymentGatewayHost; |
226 | 229 | |
227 | | - $chosenGateway = $userInput['payment_method']; |
| 230 | + $chosenGateway = $userInput['gateway']; |
228 | 231 | |
| 232 | + $redirectionData = wfArrayToCGI( $userInput ); |
| 233 | + |
| 234 | + //$wgOut->redirect( |
| 235 | + //$wgPaymentGatewayHost . $url[$chosenGateway] . $redirectionData |
| 236 | + //); |
| 237 | + |
229 | 238 | $wgOut->redirect( |
230 | | - $wgPaymentGatewayHost . $url[$chosenGateway] . '&amount=' . |
231 | | - $userInput['amount'] . '¤cy_code=' . $userInput['currency'] . |
232 | | - '&gateway=' . $userInput['payment_method'] . '&referrer=' . |
233 | | - $userInput['referrer'] . '&utm_source=' . $userInput['utm_source'] . |
234 | | - '&utm_medium=' . $userInput['utm_medium'] . '&utm_campaign=' . |
235 | | - $userInput['utm_campaign'] .'&language=' . $userInput['language'] . |
236 | | - '&comment=' . $userInput['comment'] . '&comment-option=' . |
237 | | - $userInput['comment-option'] .'&email=' . $userInput['email'] |
238 | | - ); |
| 239 | + $url[$chosenGateway] . '&' . $redirectionData |
| 240 | + ); |
| 241 | + |
239 | 242 | } |
240 | 243 | |
241 | 244 | /** |
— | — | @@ -306,9 +309,9 @@ |
307 | 310 | |
308 | 311 | // declare variables used to hold post data |
309 | 312 | $userInput = array ( |
310 | | - 'currency' => 'USD', |
| 313 | + 'currency_code' => 'USD', |
311 | 314 | 'amount' => '0.00', |
312 | | - 'payment_method' => '', |
| 315 | + 'gateway' => '', |
313 | 316 | 'referrer' => '', |
314 | 317 | 'utm_source' => '', |
315 | 318 | 'utm_medium' => '', |
— | — | @@ -333,9 +336,9 @@ |
334 | 337 | |
335 | 338 | // create array of user input from post data |
336 | 339 | $userInput = array ( |
337 | | - 'currency' => $wgRequest->getText( 'currency_code', 'USD' ), |
| 340 | + 'currency_code' => $wgRequest->getText( 'currency_code', 'USD' ), |
338 | 341 | 'amount' => $amount, |
339 | | - 'payment_method' => $wgRequest->getText( 'payment_method', 'payflow' ), |
| 342 | + 'gateway' => $wgRequest->getText( 'payment_method', 'payflow' ), |
340 | 343 | 'referrer' => $wgRequest->getText( 'referrer', '' ), |
341 | 344 | 'utm_source' => $wgRequest->getText( 'utm_source', '' ), |
342 | 345 | 'utm_medium' => $wgRequest->getText( 'utm_medium', '' ), |
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -69,7 +69,6 @@ |
70 | 70 | function sendSTOMP($transaction) { |
71 | 71 | global $wgOut; |
72 | 72 | global $wgStompServer; |
73 | | - //var_dump($wgStompServer); |
74 | 73 | |
75 | 74 | // include a library |
76 | 75 | require_once("Stomp.php"); |
— | — | @@ -85,7 +84,9 @@ |
86 | 85 | // send a message to the queue |
87 | 86 | $result = $con->send("/queue/test", $message, array('persistent' => 'true')); |
88 | 87 | |
89 | | - // TODO: Add back up logging if no result! |
| 88 | + if (!$result) { |
| 89 | + wfDebugLog('activemq_stomp', 'Send to Q failed for this message: ' . $message); |
| 90 | +} |
90 | 91 | |
91 | 92 | $con->disconnect(); |
92 | 93 | |