Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -340,6 +340,11 @@ |
341 | 341 | //update the contribution tracking data |
342 | 342 | $this->incrementNumAttempt(); |
343 | 343 | |
| 344 | + //if we're supposed to add the donor data to the session, do that. |
| 345 | + if ( $this->transaction_option( 'addDonorDataToSession' ) ) { |
| 346 | + $this->addDonorDataToSession(); |
| 347 | + } |
| 348 | + |
344 | 349 | $this->runPreProcess(); //many hooks get fired here... |
345 | 350 | //TODO: Uhmmm... what if none of the validate hooks are enabled? |
346 | 351 | //Currently, I think that means the transaction stops here, and that's not quite right. |
— | — | @@ -359,11 +364,10 @@ |
360 | 365 | } |
361 | 366 | |
362 | 367 | // expose a hook for external handling of trxns ready for processing |
363 | | - if (array_key_exists('do_processhooks', $this->transactions[$this->currentTransaction()]) && |
364 | | - $this->transactions[$this->currentTransaction()]['do_processhooks'] === 'true'){ |
| 368 | + if ( $this->transaction_option( 'do_processhooks' ) ) { |
365 | 369 | wfRunHooks( 'GatewayProcess', array( &$this ) ); //don't think anybody is using this yet, but you could! |
366 | 370 | } |
367 | | - |
| 371 | + |
368 | 372 | $this->dataObj->updateContributionTracking( defined( 'OWA' ) ); |
369 | 373 | if ( $this->getCommunicationType() === 'xml' ) { |
370 | 374 | $this->getStopwatch( "buildRequestXML" ); |
— | — | @@ -377,11 +381,58 @@ |
378 | 382 | $curlme = $this->buildRequestNameValueString(); |
379 | 383 | $this->saveCommunicationStats( "buildRequestNameValueString", $transaction ); |
380 | 384 | } |
381 | | - |
382 | | - $txn_ok = $this->curl_transaction( $curlme ); |
383 | 385 | |
| 386 | + //start looping here, if we're the sort of transaction that needs to do that. |
| 387 | + $stopflag = false; |
| 388 | + $counter = 0; |
| 389 | + $statuses = $this->transaction_option( 'loop_for_status' ); |
| 390 | + $this->getStopwatch( __FUNCTION__, true ); |
| 391 | + while ( $stopflag === false ) { |
| 392 | + $stopflag = true; |
| 393 | + $counter += 1; |
| 394 | + $txn_ok = $this->curl_transaction( $curlme ); |
| 395 | + |
| 396 | + if ( $txn_ok === true ) { //We have something to slice and dice. |
| 397 | + self::log( "RETURNED FROM CURL:" . print_r( $this->getTransactionAllResults(), true ) ); |
| 398 | + |
| 399 | + //set the status of the response. This is the COMMUNICATION status, and has nothing |
| 400 | + //to do with the result of the transaction. |
| 401 | + $formatted = $this->getFormattedResponse( $this->getTransactionRawResponse() ); |
| 402 | + $this->setTransactionResult( $this->getResponseStatus( $formatted ), 'status' ); |
| 403 | + |
| 404 | + //set errors |
| 405 | + //TODO: This "errors" business is becoming a bit of a misnomer, as the result code and message |
| 406 | + //are frequently packaged togther in the same place, whether the transaction passed or failed. |
| 407 | + $this->setTransactionResult( $this->getResponseErrors( $formatted ), 'errors' ); |
| 408 | + |
| 409 | + //if we're still okay (hey, even if we're not), get relevent dataz. |
| 410 | + $pulled_data = $this->getResponseData( $formatted ); |
| 411 | + $this->setTransactionResult( $pulled_data, 'data' ); |
| 412 | + |
| 413 | + //TODO: Death to the pulled_data parameter! |
| 414 | + $this->processResponse( $pulled_data ); //now we've set all the transaction results... |
| 415 | + } else { |
| 416 | + self::log( "Transaction Communication failed" . print_r( $this->getTransactionAllResults(), true ) ); |
| 417 | + } |
| 418 | + |
| 419 | + if ( is_array( $statuses ) ) { //only then will we consider doing this again. |
| 420 | + global $wgDonationInterfaceRetrySeconds; //TODO: Deal with this global in the new usual way, once the DI install mess gets cleaned up |
| 421 | + if ( $this->getStopwatch( __FUNCTION__ ) < $wgDonationInterfaceRetrySeconds ) { |
| 422 | + if ( $txn_ok === false ) { |
| 423 | + $stopflag = false; |
| 424 | + } else { |
| 425 | + if ( !in_array( $this->getTransactionWMFStatus(), $statuses ) ) { |
| 426 | + $stopflag = false; |
| 427 | + } |
| 428 | + } |
| 429 | + } |
| 430 | + } |
| 431 | + } |
| 432 | + |
| 433 | + //Log out how many times we looped, and what the clock is now. |
| 434 | + $this->saveCommunicationStats( __FUNCTION__, $transaction, "counter = $counter" ); |
| 435 | + |
384 | 436 | if ( $txn_ok === false ) { //nothing to process, so we have to build it manually |
385 | | - self::log( "Transaction Communication failed" . print_r( $this->getTransactionAllResults(), true ) ); |
386 | 437 | return array( |
387 | 438 | 'status' => false, |
388 | 439 | 'message' => "$transaction Communication Failed!", |
— | — | @@ -391,28 +442,12 @@ |
392 | 443 | ); |
393 | 444 | } |
394 | 445 | |
395 | | - self::log( "RETURNED FROM CURL:" . print_r( $this->getTransactionAllResults(), true ) ); |
396 | | - |
397 | | - //set the status of the response |
398 | | - $formatted = $this->getFormattedResponse( $this->getTransactionRawResponse() ); |
399 | | - $this->setTransactionResult( $this->getResponseStatus( $formatted ), 'status' ); |
400 | | - |
401 | | - //set errors |
402 | | - //TODO: This "errors" business is becoming a bit of a misnomer, as the result code and message |
403 | | - //are frequently packaged togther in the same place, whether the transaction passed or failed. |
404 | | - $this->setTransactionResult( $this->getResponseErrors( $formatted ), 'errors' ); |
405 | | - |
406 | | - //if we're still okay (hey, even if we're not), get relevent dataz. |
407 | | - $pulled_data = $this->getResponseData( $formatted ); |
408 | | - $this->setTransactionResult( $pulled_data, 'data' ); |
409 | | - |
410 | 446 | // expose a hook for any post processing |
411 | | - if (array_key_exists('do_processhooks', $this->transactions[$this->currentTransaction()]) && |
412 | | - $this->transactions[$this->currentTransaction()]['do_processhooks'] === 'true'){ |
| 447 | + if ( $this->transaction_option( 'do_processhooks' ) ) { |
413 | 448 | wfRunHooks( 'GatewayPostProcess', array( &$this ) ); //conversion log (at least) |
| 449 | + $this->doStompTransaction(); |
414 | 450 | } |
415 | 451 | |
416 | | - $this->processResponse( $pulled_data ); |
417 | 452 | $this->dataObj->unsetEditToken(); |
418 | 453 | |
419 | 454 | //TODO: Actually pull these from somewhere legit. |
— | — | @@ -641,14 +676,25 @@ |
642 | 677 | return $c::IDENTIFIER; |
643 | 678 | } |
644 | 679 | |
| 680 | + /** |
| 681 | + * getStopwatch keeps track of how long things take, for logging, |
| 682 | + * output, determining if we should loop on some method again... whatever. |
| 683 | + * @staticvar array $start The microtime at which a stopwatch was started. |
| 684 | + * @param string $string Some identifier for each stopwatch value we want to |
| 685 | + * keep. Each unique $string passed in will get its own value in $start. |
| 686 | + * @param bool $reset If this is set to true, it will reset any $start value |
| 687 | + * recorded for the $string identifier. |
| 688 | + * @return numeric The difference in microtime (rounded to 4 decimal places) |
| 689 | + * between the $start value, and now. |
| 690 | + */ |
645 | 691 | public function getStopwatch( $string, $reset = false ) { |
646 | | - static $start = null; |
| 692 | + static $start = array( ); |
647 | 693 | $now = microtime( true ); |
648 | 694 | |
649 | | - if ( $start == null || $reset === true ) { |
650 | | - $start = $now; |
| 695 | + if ( empty( $start ) || !array_key_exists( $string, $start ) || $reset === true ) { |
| 696 | + $start[$string] = $now; |
651 | 697 | } |
652 | | - $clock = round( $now - $start, 4 ); |
| 698 | + $clock = round( $now - $start[$string], 4 ); |
653 | 699 | self::log( "\nClock at $string: $clock ($now)" ); |
654 | 700 | return $clock; |
655 | 701 | } |
— | — | @@ -752,8 +798,11 @@ |
753 | 799 | $this->dataObj->unsetAllDDSessionData(); |
754 | 800 | } |
755 | 801 | |
756 | | - function doStompTransaction( $responseArray, $responseMsg, $status, $useSession = false ) { |
| 802 | + function doStompTransaction() { |
| 803 | + $this->debugarray[] = "Attempting Stomp Transaction!"; |
757 | 804 | $hook = ''; |
| 805 | + |
| 806 | + $status = $this->getTransactionWMFStatus(); |
758 | 807 | switch ( $status ) { |
759 | 808 | case 'complete': |
760 | 809 | $hook = 'gwStomp'; |
— | — | @@ -764,26 +813,19 @@ |
765 | 814 | break; |
766 | 815 | } |
767 | 816 | if ( $hook === '' ) { |
| 817 | + $this->debugarray[] = "No Stomp Hook Found for WMF_Status $status"; |
768 | 818 | return; |
769 | 819 | } |
770 | 820 | |
771 | | - foreach ( $responseArray as $key => $val ) { |
772 | | - if ( array_key_exists( $key, $this->var_map ) ) { |
773 | | - $responseArray[$this->var_map[$key]] = $val; |
774 | | - unset( $responseArray[$key] ); |
775 | | - } |
776 | | - } |
| 821 | + $data = $this->getTransactionData(); |
777 | 822 | |
778 | 823 | //Gah. I might want to move all this data prep business upstream more than somewhat. |
779 | 824 | //...but that's for later. |
780 | 825 | // Add the session vars to the data object |
781 | | - if ( $useSession ) { |
| 826 | + if ( $this->transaction_option( 'pullDonorDataFromSession' ) ) { |
782 | 827 | $this->dataObj->populateDonorFromSession(); |
783 | 828 | } |
784 | 829 | |
785 | | - // Add our response vars to the data object. |
786 | | - $this->dataObj->addData( $responseArray ); |
787 | | - |
788 | 830 | // refresh our data |
789 | 831 | $this->postdata = $this->dataObj->getData(); |
790 | 832 | |
— | — | @@ -792,7 +834,7 @@ |
793 | 835 | |
794 | 836 | // send the thing. |
795 | 837 | $transaction = array( |
796 | | - 'response' => $responseMsg, |
| 838 | + 'response' => $this->getTransactionMessage(), |
797 | 839 | 'date' => time(), |
798 | 840 | ); |
799 | 841 | $transaction += $this->getData(); |
— | — | @@ -887,6 +929,15 @@ |
888 | 930 | } |
889 | 931 | } |
890 | 932 | |
| 933 | + /** |
| 934 | + * SetTransactionResult sets the gateway adapter object's |
| 935 | + * $transaction_results value. |
| 936 | + * If a $key is specified, it only sets the specified key's value. If no |
| 937 | + * $key is specified, it resets the value of the entire array. |
| 938 | + * @param mixed $value The value to set in $transaction_results |
| 939 | + * @param mixed $key Optional: A specific key to set, or false (default) to |
| 940 | + * reset the entire result array. |
| 941 | + */ |
891 | 942 | public function setTransactionResult( $value, $key = false ) { |
892 | 943 | if ( $key === false ) { |
893 | 944 | $this->transaction_results = $value; |
— | — | @@ -903,6 +954,11 @@ |
904 | 955 | } |
905 | 956 | } |
906 | 957 | |
| 958 | + /** |
| 959 | + * If it has been set: returns the Transaction Status in the |
| 960 | + * $transaction_results array. Otherwise, returns false. |
| 961 | + * @return mixed Transaction results status, or false if not set. |
| 962 | + */ |
907 | 963 | public function getTransactionStatus() { |
908 | 964 | if ( array_key_exists( 'status', $this->transaction_results ) ) { |
909 | 965 | return $this->transaction_results['status']; |
— | — | @@ -911,6 +967,29 @@ |
912 | 968 | } |
913 | 969 | } |
914 | 970 | |
| 971 | + /** |
| 972 | + * If it has been set: returns the WMF Transaction Status in the |
| 973 | + * $transaction_results array. This is the one we care about for switching |
| 974 | + * on overall behavior. Otherwise, returns false. |
| 975 | + * @return mixed WMF Transaction results status, or false if not set. |
| 976 | + */ |
| 977 | + public function getTransactionWMFStatus() { |
| 978 | + if ( array_key_exists( 'data', $this->transaction_results ) && |
| 979 | + array_key_exists( 'WMF_STATUS', $this->transaction_results['data'] ) ) { |
| 980 | + return $this->transaction_results['data']['WMF_STATUS']; |
| 981 | + } else { |
| 982 | + return false; |
| 983 | + } |
| 984 | + } |
| 985 | + |
| 986 | + /** |
| 987 | + * Sets the WMF Transaction Status. This is the one we care about for |
| 988 | + * switching on behavior. |
| 989 | + */ |
| 990 | + public function setTransactionWMFStatus( $status ) { |
| 991 | + $this->transaction_results['data']['WMF_STATUS'] = $status; |
| 992 | + } |
| 993 | + |
915 | 994 | public function getTransactionMessage() { |
916 | 995 | if ( array_key_exists( 'txn_message', $this->transaction_results ) ) { |
917 | 996 | return $this->transaction_results['txn_message']; |
— | — | @@ -919,7 +998,11 @@ |
920 | 999 | } |
921 | 1000 | } |
922 | 1001 | |
923 | | - public function getTransactionData() { //this is the FORMATTED data returned from the reply. |
| 1002 | + /** |
| 1003 | + * Returns the FORMATTED data harvested from the reply, or false if it is not set. |
| 1004 | + * @return mixed An array of returned data, or false. |
| 1005 | + */ |
| 1006 | + public function getTransactionData() { |
924 | 1007 | if ( array_key_exists( 'data', $this->transaction_results ) ) { |
925 | 1008 | return $this->transaction_results['data']; |
926 | 1009 | } else { |
— | — | @@ -977,8 +1060,7 @@ |
978 | 1061 | } |
979 | 1062 | |
980 | 1063 | function runPreProcess() { |
981 | | - if (array_key_exists('do_validation', $this->transactions[$this->currentTransaction()]) && |
982 | | - $this->transactions[$this->currentTransaction()]['do_validation'] === 'true'){ |
| 1064 | + if ( $this->transaction_option( 'do_validation' ) ) { |
983 | 1065 | // allow any external validators to have their way with the data |
984 | 1066 | self::log( $this->getData( 'order_id' ) . " Preparing to query MaxMind" ); |
985 | 1067 | wfRunHooks( 'GatewayValidate', array( &$this ) ); |
— | — | @@ -1003,8 +1085,22 @@ |
1004 | 1086 | $this->dataObj->unsetEditToken(); |
1005 | 1087 | } |
1006 | 1088 | } else { |
1007 | | - $this->action = 'process'; |
| 1089 | + $this->action = 'process'; //we have to do this so do_transaction doesn't kick out. |
1008 | 1090 | } |
1009 | 1091 | } |
1010 | 1092 | |
| 1093 | + function transaction_option( $option_value ) { |
| 1094 | + //ooo, ugly. |
| 1095 | + if ( array_key_exists( $option_value, $this->transactions[$this->currentTransaction()] ) ) { |
| 1096 | + if ( $this->transactions[$this->currentTransaction()][$option_value] === true ) { |
| 1097 | + return true; |
| 1098 | + } |
| 1099 | + if ( is_array( $this->transactions[$this->currentTransaction()][$option_value] ) && |
| 1100 | + !empty( $this->transactions[$this->currentTransaction()][$option_value] ) ) { |
| 1101 | + return $this->transactions[$this->currentTransaction()][$option_value]; |
| 1102 | + } |
| 1103 | + } |
| 1104 | + return false; |
| 1105 | + } |
| 1106 | + |
1011 | 1107 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -662,7 +662,8 @@ |
663 | 663 | 'state', |
664 | 664 | 'zip', |
665 | 665 | 'country', |
666 | | - 'contribution_tracking_id' |
| 666 | + 'contribution_tracking_id', |
| 667 | + 'referrer' |
667 | 668 | ); |
668 | 669 | |
669 | 670 | foreach ( $donordata as $item ) { |
— | — | @@ -713,6 +714,7 @@ |
714 | 715 | |
715 | 716 | public function decrementNumAttempt() { |
716 | 717 | //minfraud... |
| 718 | + //TODO: Determine if I killed this or not. |
717 | 719 | if ( $this->isSomething( 'numAttempt' ) ) { |
718 | 720 | $attempts = $this->getVal( 'numAttempt' ); |
719 | 721 | if ( is_numeric( $attempts ) ) { |
Index: branches/fundraising/extensions/DonationInterface/donationinterface.php |
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | * The URL to redirect a transaction to PayPal |
134 | 134 | */ |
135 | 135 | $wgDonationInterfacePaypalURL = ''; |
| 136 | +$wgDonationInterfaceRetrySeconds = 5; |
136 | 137 | |
137 | 138 | function efDonationInterfaceUnitTests( &$files ) { |
138 | 139 | //$files[] = dirname( __FILE__ ) . '/tests/AllTests.php'; |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php |
— | — | @@ -78,8 +78,8 @@ |
79 | 79 | 'TENDER' => 'C', |
80 | 80 | 'VERBOSITY' => 'MEDIUM', |
81 | 81 | ), |
82 | | - 'do_validation' => 'true', |
83 | | - 'do_processhooks' => 'true', |
| 82 | + 'do_validation' => true, |
| 83 | + 'do_processhooks' => true, |
84 | 84 | ); |
85 | 85 | } |
86 | 86 | |
— | — | @@ -201,6 +201,7 @@ |
202 | 202 | //OUR field names. |
203 | 203 | $this->staged_vars = array( |
204 | 204 | 'card_num', |
| 205 | + 'user_ip' |
205 | 206 | ); |
206 | 207 | } |
207 | 208 | |
— | — | @@ -209,4 +210,14 @@ |
210 | 211 | $this->postdata['card_num'] = str_replace( ' ', '', $this->postdata['card_num'] ); |
211 | 212 | } |
212 | 213 | |
| 214 | + //TODO: Something much fancier here. |
| 215 | + protected function stage_user_ip( $type = 'request' ) { |
| 216 | + if ( $this->postdata['user_ip'] === '127.0.0.1' ) { |
| 217 | + global $wgDonationInterfaceIPAddress; |
| 218 | + if ( !empty( $wgDonationInterfaceIPAddress ) ) { |
| 219 | + $this->postdata['user_ip'] = $wgDonationInterfaceIPAddress; |
| 220 | + } |
| 221 | + } |
| 222 | + } |
| 223 | + |
213 | 224 | } |
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | static function onFilter( &$gateway_adapter, &$custom_filter_object ) { |
| 33 | + $gateway_adapter->debugarray[] = 'minfraud onFilter hook!'; |
33 | 34 | return self::singleton( &$gateway_adapter )->filter( $custom_filter_object ); |
34 | 35 | } |
35 | 36 | |
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | static function onFilter( &$custom_filter_object ) { |
| 51 | + $gateway_adapter->debugarray[] = 'referrer onFilter hook!'; |
51 | 52 | return self::singleton( $custom_filter_object )->filter(); |
52 | 53 | } |
53 | 54 | |
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | static function onFilter( &$custom_filter_object ) { |
| 51 | + $gateway_adapter->debugarray[] = 'source onFilter hook!'; |
51 | 52 | return self::singleton( $custom_filter_object )->filter(); |
52 | 53 | } |
53 | 54 | |
Index: branches/fundraising/extensions/DonationInterface/extras/conversion_log/conversion_log.body.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | } |
29 | 29 | |
30 | 30 | static function onPostProcess( &$gateway_adapter ) { |
| 31 | + $gateway_adapter->debugarray[] = 'conversion log onPostProcess hook!'; |
31 | 32 | return self::singleton( $gateway_adapter )->post_process(); |
32 | 33 | } |
33 | 34 | |
Index: branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Validates a transaction against MaxMind's minFraud service |
5 | 6 | */ |
6 | | - |
7 | 7 | class Gateway_Extras_reCaptcha extends Gateway_Extras { |
8 | 8 | |
9 | 9 | /** |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | |
20 | 20 | public function __construct( &$gateway_adapter ) { |
21 | 21 | parent::__construct( $gateway_adapter ); |
22 | | - |
| 22 | + |
23 | 23 | //stash all the vars that reCaptcha is going to need in a global just for it. |
24 | 24 | //I know this is vaguely unpleasant, but it's the quickest way back to zero. |
25 | 25 | global $wgReCaptchaConfData; |
— | — | @@ -28,7 +28,6 @@ |
29 | 29 | $wgReCaptchaConfData['UseSSL'] = $this->getGlobal( 'RecaptchaUseSSL' ); |
30 | 30 | $wgReCaptchaConfData['ComsRetryLimit'] = $this->getGlobal( 'RecaptchaComsRetryLimit' ); |
31 | 31 | $wgReCaptchaConfData['GatewayClass'] = $this->gateway_adapter->getGatewayAdapterClass(); //for properly routing the logging |
32 | | - |
33 | 32 | // load the reCaptcha API |
34 | 33 | require_once( dirname( __FILE__ ) . '/recaptcha-php/recaptchalib.php' ); |
35 | 34 | } |
— | — | @@ -38,7 +37,7 @@ |
39 | 38 | */ |
40 | 39 | public function challenge() { |
41 | 40 | // if captcha posted, validate |
42 | | - if ( isset( $_POST[ 'recaptcha_response_field' ] ) ) { |
| 41 | + if ( isset( $_POST['recaptcha_response_field'] ) ) { |
43 | 42 | // check the captcha response |
44 | 43 | $captcha_resp = $this->check_captcha(); |
45 | 44 | if ( $captcha_resp->is_valid ) { |
— | — | @@ -72,10 +71,9 @@ |
73 | 72 | $captcha_html .= recaptcha_get_html( $publicKey, $this->recap_err, $useSSL ); |
74 | 73 | $captcha_html .= '<span class="creditcard-error-msg">' . wfMsg( $this->gateway_adapter->getIdentifier() . '_gateway-error-msg-captcha-please' ) . '</span>'; |
75 | 74 | $captcha_html .= Xml::closeElement( 'div' ); // close div#mw-donate-captcha |
76 | | - |
77 | 75 | // load up the form class |
78 | 76 | $form_class = $this->gateway_adapter->getFormClass(); |
79 | | - |
| 77 | + |
80 | 78 | //hmm. Looking at this now, makes me want to say |
81 | 79 | //TODO: Refactor the Form Class constructors. Again. Because the next three lines of code anger me deeply. |
82 | 80 | //#1 - all three things are clearly in the gateway adapter, and we're passing that already. |
— | — | @@ -97,15 +95,13 @@ |
98 | 96 | public function check_captcha() { |
99 | 97 | global $wgRequest; |
100 | 98 | $privateKey = $this->getGlobal( 'RecaptchaPrivateKey' ); |
101 | | - $resp = recaptcha_check_answer( $privateKey, |
102 | | - wfGetIP(), |
103 | | - $wgRequest->getText( 'recaptcha_challenge_field' ), |
104 | | - $wgRequest->getText( 'recaptcha_response_field' ) ); |
| 99 | + $resp = recaptcha_check_answer( $privateKey, wfGetIP(), $wgRequest->getText( 'recaptcha_challenge_field' ), $wgRequest->getText( 'recaptcha_response_field' ) ); |
105 | 100 | |
106 | 101 | return $resp; |
107 | 102 | } |
108 | 103 | |
109 | 104 | static function onChallenge( &$gateway_adapter ) { |
| 105 | + $gateway_adapter->debugarray[] = 'recaptcha onChallenge hook!'; |
110 | 106 | return self::singleton( $gateway_adapter )->challenge(); |
111 | 107 | } |
112 | 108 | |
— | — | @@ -115,4 +111,5 @@ |
116 | 112 | } |
117 | 113 | return self::$instance; |
118 | 114 | } |
| 115 | + |
119 | 116 | } |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -51,9 +51,8 @@ |
52 | 52 | $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 310, 350 ); |
53 | 53 | $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'revised', 400 ); |
54 | 54 | $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending_poke', 525 ); |
55 | | - $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending', 550, 850 ); |
56 | | - $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending', 900 ); //There's two 900s in the doc. The heck? |
57 | | - $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending', 950, 975 ); |
| 55 | + $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending', 550, 650 ); |
| 56 | + $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete', 800, 975 ); //these are all post-authorized, but technically pre-settled... |
58 | 57 | $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete', 1000, 1050 ); |
59 | 58 | $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 1100, 99999 ); |
60 | 59 | } |
— | — | @@ -155,8 +154,8 @@ |
156 | 155 | 'HOSTEDINDICATOR' => '1', |
157 | 156 | //'PAYMENTPRODUCTID' => '11', |
158 | 157 | ), |
159 | | - 'do_validation' => 'true', |
160 | | - 'do_processhooks' => 'true', |
| 158 | + 'do_validation' => true, |
| 159 | + 'addDonorDataToSession' => true, |
161 | 160 | ); |
162 | 161 | |
163 | 162 | $this->transactions['TEST_CONNECTION'] = array( |
— | — | @@ -195,6 +194,15 @@ |
196 | 195 | 'values' => array( |
197 | 196 | 'ACTION' => 'GET_ORDERSTATUS', |
198 | 197 | 'VERSION' => '2.0' |
| 198 | + ), |
| 199 | + 'do_processhooks' => true, |
| 200 | + 'pullDonorDataFromSession' => true, |
| 201 | + 'loop_for_status' => array( |
| 202 | + //'pending', |
| 203 | + 'pending_poke', |
| 204 | + 'complete', |
| 205 | + 'failed', |
| 206 | + 'revised', |
199 | 207 | ) |
200 | 208 | ); |
201 | 209 | } |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class GlobalCollectGatewayResult extends UnlistedSpecialPage { |
| 4 | +class GlobalCollectGatewayResult extends GatewayForm { |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Defines the action to take on a PFP transaction. |
— | — | @@ -26,10 +26,8 @@ |
27 | 27 | * Constructor - set up the new special page |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | | - parent::__construct( 'GlobalCollectGatewayResult' ); |
31 | | - $this->errors = $this->getPossibleErrors(); |
32 | | - |
33 | 30 | $this->adapter = new GlobalCollectAdapter(); |
| 31 | + parent::__construct(); //the next layer up will know who we are. |
34 | 32 | } |
35 | 33 | |
36 | 34 | /** |
— | — | @@ -80,25 +78,15 @@ |
81 | 79 | |
82 | 80 | switch ( $result['data']['WMF_STATUS'] ) { |
83 | 81 | case 'complete': |
84 | | - $wgOut->addHTML( "Add successful stomp message, go to the thank you page..." ); |
85 | | - $go = $this->adapter->getThankYouPage(); |
86 | | - break; |
87 | 82 | case 'pending': |
88 | | - $wgOut->addHTML( "Add pending stomp message, go to the thank you page..." ); |
89 | | - $go = $this->adapter->getThankYouPage(); |
90 | | - break; |
91 | 83 | case 'pending-poke': |
92 | | - $wgOut->addHTML( "Add pending stomp message, go to the thank you page, add some indicator that we need to do something." ); |
93 | 84 | $go = $this->adapter->getThankYouPage(); |
94 | 85 | break; |
95 | 86 | case 'failed': |
96 | | - $wgOut->addHTML( "Toss it, go to fail page..." ); |
97 | 87 | $go = $this->adapter->getFailPage(); |
98 | 88 | break; |
99 | 89 | } |
100 | | - $this->adapter->doStompTransaction( $result['data'], $result['message'], $result['data']['WMF_STATUS'], true ); |
101 | 90 | |
102 | | - $this->adapter->unsetAllGatewaySessionData(); |
103 | 91 | $wgOut->addHTML( "<br>Redirecting to page $go" ); |
104 | 92 | $wgOut->redirect( $go ); |
105 | 93 | } |
— | — | @@ -110,133 +98,6 @@ |
111 | 99 | } |
112 | 100 | } |
113 | 101 | } |
114 | | - |
115 | | - function displayResultsForDebug( $results ) { |
116 | | - global $wgOut; |
117 | | - $wgOut->addHTML( $results['message'] ); |
118 | | - |
119 | | - if ( !empty( $results['errors'] ) ) { |
120 | | - $wgOut->addHTML( "<ul>" ); |
121 | | - foreach ( $results['errors'] as $code => $value ) { |
122 | | - $wgOut->addHTML( "<li>Error $code: $value" ); |
123 | | - } |
124 | | - $wgOut->addHTML( "</ul>" ); |
125 | | - } |
126 | | - |
127 | | - if ( !empty( $results['data'] ) ) { |
128 | | - $wgOut->addHTML( "<ul>" ); |
129 | | - foreach ( $results['data'] as $key => $value ) { |
130 | | - if ( is_array( $value ) ) { |
131 | | - $wgOut->addHTML( "<li>$key:<ul>" ); |
132 | | - foreach ( $value as $key2 => $val2 ) { |
133 | | - $wgOut->addHTML( "<li>$key2: $val2" ); |
134 | | - } |
135 | | - $wgOut->addHTML( "</ul>" ); |
136 | | - } else { |
137 | | - $wgOut->addHTML( "<li>$key: $value" ); |
138 | | - } |
139 | | - } |
140 | | - $wgOut->addHTML( "</ul>" ); |
141 | | - } else { |
142 | | - $wgOut->addHTML( "Empty Results" ); |
143 | | - } |
144 | | - if ( array_key_exists( 'Donor', $_SESSION ) ) { |
145 | | - $wgOut->addHTML( "Session Donor Vars:<ul>" ); |
146 | | - foreach ( $_SESSION['Donor'] as $key => $val ) { |
147 | | - $wgOut->addHTML( "<li>$key: $val" ); |
148 | | - } |
149 | | - $wgOut->addHTML( "</ul>" ); |
150 | | - } else { |
151 | | - $wgOut->addHTML( "No Session Donor Vars:<ul>" ); |
152 | | - } |
153 | | - } |
154 | | - |
155 | | - /** |
156 | | - * Prepares the transactional message to be sent via Stomp to queueing service |
157 | | - * |
158 | | - * @param array $data |
159 | | - * @param array $resposneArray |
160 | | - * @param array $responseMsg |
161 | | - * @return array |
162 | | - */ |
163 | | - public function prepareStompTransaction( $data, $responseArray, $responseMsg ) { |
164 | | - $countries = GatewayForm::getCountries(); |
165 | | - |
166 | | - $transaction = array( ); |
167 | | - |
168 | | - // include response message |
169 | | - $transaction['response'] = $responseMsg; |
170 | | - |
171 | | - // include date |
172 | | - $transaction['date'] = time(); |
173 | | - |
174 | | - // put all data into one array |
175 | | - $optout = $this->determineOptOut( $data ); |
176 | | - $data['anonymous'] = $optout['anonymous']; |
177 | | - $data['optout'] = $optout['optout']; |
178 | | - |
179 | | - $transaction += array_merge( $data, $responseArray ); |
180 | | - |
181 | | - return $transaction; |
182 | | - } |
183 | | - |
184 | | - public function getPossibleErrors() { |
185 | | - return array( |
186 | | - 'general' => '', |
187 | | - 'retryMsg' => '', |
188 | | - 'invalidamount' => '', |
189 | | - 'card_num' => '', |
190 | | - 'card_type' => '', |
191 | | - 'cvv' => '', |
192 | | - 'fname' => '', |
193 | | - 'lname' => '', |
194 | | - 'city' => '', |
195 | | - 'country' => '', |
196 | | - 'street' => '', |
197 | | - 'state' => '', |
198 | | - 'zip' => '', |
199 | | - 'emailAdd' => '', |
200 | | - ); |
201 | | - } |
202 | | - |
203 | | - /** |
204 | | - * Handle redirection of form content to PayPal |
205 | | - * |
206 | | - * @fixme If we can update contrib tracking table in ContributionTracking |
207 | | - * extension, we can probably get rid of this method and just submit the form |
208 | | - * directly to the paypal URL, and have all processing handled by ContributionTracking |
209 | | - * This would make this a lot less hack-ish |
210 | | - */ |
211 | | - public function paypalRedirect( &$data ) { |
212 | | - global $wgPayflowProGatewayPaypalURL, $wgOut; |
213 | | - |
214 | | - // if we don't have a URL enabled throw a graceful error to the user |
215 | | - if ( !strlen( $wgPayflowProGatewayPaypalURL ) ) { |
216 | | - $this->errors['general']['nopaypal'] = wfMsg( 'payflow_gateway-error-msg-nopaypal' ); |
217 | | - return; |
218 | | - } |
219 | | - |
220 | | - // update the utm source to set the payment instrument to pp rather than cc |
221 | | - $utm_source_parts = explode( ".", $data['utm_source'] ); |
222 | | - $utm_source_parts[2] = 'pp'; |
223 | | - $data['utm_source'] = implode( ".", $utm_source_parts ); |
224 | | - $data['gateway'] = 'paypal'; |
225 | | - $data['currency_code'] = $data['currency']; |
226 | | - /** |
227 | | - * update contribution tracking |
228 | | - */ |
229 | | - $this->updateContributionTracking( $data, true ); |
230 | | - |
231 | | - $wgPayflowProGatewayPaypalURL .= "/" . $data['language'] . "?gateway=paypal"; |
232 | | - |
233 | | - // submit the data to the paypal redirect URL |
234 | | - $wgOut->redirect( $wgPayflowProGatewayPaypalURL . '&' . http_build_query( $data ) ); |
235 | | - } |
236 | | - |
237 | | - public static function log( $msg, $log_level=LOG_INFO ) { |
238 | | - $this->adapter->log( $msg, $log_level ); |
239 | | - } |
240 | | - |
241 | 102 | } |
242 | 103 | |
243 | 104 | // end class |