r99036 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99035‎ | r99036 | r99037 >
Date:19:52, 5 October 2011
Author:khorn
Status:ok
Tags:fundraising 
Comment:
Latest round of bug fixes and additions for DonationInterface:
Added some helpful debug statements to $gateway_adapter->debugarray[], particularly in the extras hooks so we can tell what got fired off.
Added $wgDonationInterfaceRetrySeconds (amount of time after which to bail out on looping for a response we like)
Added 'do_validation', 'do_processhooks', 'addDonorDataToSession', 'pullDonorDataFromSession', 'loop_for_status' options to the transaction definitions, so we can not fire off transactional extras for inappropriate types.
Altered do_transaction to accomidate those transaction types that we want to retry until we get something in a set of answers.
Added 'referrer' to the list of items that get saved in the sesson's donor object for the sorts of transactions that need donor data saved and used (for an iframe or whatever)
Killed off most of the globalcollect resultswitcher (which I predict will die entirely, and soon.)
Changed a couple code ranges in the globalcollect adapter to better reflect reality.
Yes, this is still followup r98498
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/donationinterface.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/conversion_log/conversion_log.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -340,6 +340,11 @@
341341 //update the contribution tracking data
342342 $this->incrementNumAttempt();
343343
 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+
344349 $this->runPreProcess(); //many hooks get fired here...
345350 //TODO: Uhmmm... what if none of the validate hooks are enabled?
346351 //Currently, I think that means the transaction stops here, and that's not quite right.
@@ -359,11 +364,10 @@
360365 }
361366
362367 // 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' ) ) {
365369 wfRunHooks( 'GatewayProcess', array( &$this ) ); //don't think anybody is using this yet, but you could!
366370 }
367 -
 371+
368372 $this->dataObj->updateContributionTracking( defined( 'OWA' ) );
369373 if ( $this->getCommunicationType() === 'xml' ) {
370374 $this->getStopwatch( "buildRequestXML" );
@@ -377,11 +381,58 @@
378382 $curlme = $this->buildRequestNameValueString();
379383 $this->saveCommunicationStats( "buildRequestNameValueString", $transaction );
380384 }
381 -
382 - $txn_ok = $this->curl_transaction( $curlme );
383385
 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+
384436 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 ) );
386437 return array(
387438 'status' => false,
388439 'message' => "$transaction Communication Failed!",
@@ -391,28 +442,12 @@
392443 );
393444 }
394445
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 -
410446 // 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' ) ) {
413448 wfRunHooks( 'GatewayPostProcess', array( &$this ) ); //conversion log (at least)
 449+ $this->doStompTransaction();
414450 }
415451
416 - $this->processResponse( $pulled_data );
417452 $this->dataObj->unsetEditToken();
418453
419454 //TODO: Actually pull these from somewhere legit.
@@ -641,14 +676,25 @@
642677 return $c::IDENTIFIER;
643678 }
644679
 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+ */
645691 public function getStopwatch( $string, $reset = false ) {
646 - static $start = null;
 692+ static $start = array( );
647693 $now = microtime( true );
648694
649 - if ( $start == null || $reset === true ) {
650 - $start = $now;
 695+ if ( empty( $start ) || !array_key_exists( $string, $start ) || $reset === true ) {
 696+ $start[$string] = $now;
651697 }
652 - $clock = round( $now - $start, 4 );
 698+ $clock = round( $now - $start[$string], 4 );
653699 self::log( "\nClock at $string: $clock ($now)" );
654700 return $clock;
655701 }
@@ -752,8 +798,11 @@
753799 $this->dataObj->unsetAllDDSessionData();
754800 }
755801
756 - function doStompTransaction( $responseArray, $responseMsg, $status, $useSession = false ) {
 802+ function doStompTransaction() {
 803+ $this->debugarray[] = "Attempting Stomp Transaction!";
757804 $hook = '';
 805+
 806+ $status = $this->getTransactionWMFStatus();
758807 switch ( $status ) {
759808 case 'complete':
760809 $hook = 'gwStomp';
@@ -764,26 +813,19 @@
765814 break;
766815 }
767816 if ( $hook === '' ) {
 817+ $this->debugarray[] = "No Stomp Hook Found for WMF_Status $status";
768818 return;
769819 }
770820
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();
777822
778823 //Gah. I might want to move all this data prep business upstream more than somewhat.
779824 //...but that's for later.
780825 // Add the session vars to the data object
781 - if ( $useSession ) {
 826+ if ( $this->transaction_option( 'pullDonorDataFromSession' ) ) {
782827 $this->dataObj->populateDonorFromSession();
783828 }
784829
785 - // Add our response vars to the data object.
786 - $this->dataObj->addData( $responseArray );
787 -
788830 // refresh our data
789831 $this->postdata = $this->dataObj->getData();
790832
@@ -792,7 +834,7 @@
793835
794836 // send the thing.
795837 $transaction = array(
796 - 'response' => $responseMsg,
 838+ 'response' => $this->getTransactionMessage(),
797839 'date' => time(),
798840 );
799841 $transaction += $this->getData();
@@ -887,6 +929,15 @@
888930 }
889931 }
890932
 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+ */
891942 public function setTransactionResult( $value, $key = false ) {
892943 if ( $key === false ) {
893944 $this->transaction_results = $value;
@@ -903,6 +954,11 @@
904955 }
905956 }
906957
 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+ */
907963 public function getTransactionStatus() {
908964 if ( array_key_exists( 'status', $this->transaction_results ) ) {
909965 return $this->transaction_results['status'];
@@ -911,6 +967,29 @@
912968 }
913969 }
914970
 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+
915994 public function getTransactionMessage() {
916995 if ( array_key_exists( 'txn_message', $this->transaction_results ) ) {
917996 return $this->transaction_results['txn_message'];
@@ -919,7 +998,11 @@
920999 }
9211000 }
9221001
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() {
9241007 if ( array_key_exists( 'data', $this->transaction_results ) ) {
9251008 return $this->transaction_results['data'];
9261009 } else {
@@ -977,8 +1060,7 @@
9781061 }
9791062
9801063 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' ) ) {
9831065 // allow any external validators to have their way with the data
9841066 self::log( $this->getData( 'order_id' ) . " Preparing to query MaxMind" );
9851067 wfRunHooks( 'GatewayValidate', array( &$this ) );
@@ -1003,8 +1085,22 @@
10041086 $this->dataObj->unsetEditToken();
10051087 }
10061088 } else {
1007 - $this->action = 'process';
 1089+ $this->action = 'process'; //we have to do this so do_transaction doesn't kick out.
10081090 }
10091091 }
10101092
 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+
10111107 }
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
@@ -662,7 +662,8 @@
663663 'state',
664664 'zip',
665665 'country',
666 - 'contribution_tracking_id'
 666+ 'contribution_tracking_id',
 667+ 'referrer'
667668 );
668669
669670 foreach ( $donordata as $item ) {
@@ -713,6 +714,7 @@
714715
715716 public function decrementNumAttempt() {
716717 //minfraud...
 718+ //TODO: Determine if I killed this or not.
717719 if ( $this->isSomething( 'numAttempt' ) ) {
718720 $attempts = $this->getVal( 'numAttempt' );
719721 if ( is_numeric( $attempts ) ) {
Index: branches/fundraising/extensions/DonationInterface/donationinterface.php
@@ -132,6 +132,7 @@
133133 * The URL to redirect a transaction to PayPal
134134 */
135135 $wgDonationInterfacePaypalURL = '';
 136+$wgDonationInterfaceRetrySeconds = 5;
136137
137138 function efDonationInterfaceUnitTests( &$files ) {
138139 //$files[] = dirname( __FILE__ ) . '/tests/AllTests.php';
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php
@@ -78,8 +78,8 @@
7979 'TENDER' => 'C',
8080 'VERBOSITY' => 'MEDIUM',
8181 ),
82 - 'do_validation' => 'true',
83 - 'do_processhooks' => 'true',
 82+ 'do_validation' => true,
 83+ 'do_processhooks' => true,
8484 );
8585 }
8686
@@ -201,6 +201,7 @@
202202 //OUR field names.
203203 $this->staged_vars = array(
204204 'card_num',
 205+ 'user_ip'
205206 );
206207 }
207208
@@ -209,4 +210,14 @@
210211 $this->postdata['card_num'] = str_replace( ' ', '', $this->postdata['card_num'] );
211212 }
212213
 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+
213224 }
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -29,6 +29,7 @@
3030 }
3131
3232 static function onFilter( &$gateway_adapter, &$custom_filter_object ) {
 33+ $gateway_adapter->debugarray[] = 'minfraud onFilter hook!';
3334 return self::singleton( &$gateway_adapter )->filter( $custom_filter_object );
3435 }
3536
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
@@ -47,6 +47,7 @@
4848 }
4949
5050 static function onFilter( &$custom_filter_object ) {
 51+ $gateway_adapter->debugarray[] = 'referrer onFilter hook!';
5152 return self::singleton( $custom_filter_object )->filter();
5253 }
5354
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
@@ -47,6 +47,7 @@
4848 }
4949
5050 static function onFilter( &$custom_filter_object ) {
 51+ $gateway_adapter->debugarray[] = 'source onFilter hook!';
5152 return self::singleton( $custom_filter_object )->filter();
5253 }
5354
Index: branches/fundraising/extensions/DonationInterface/extras/conversion_log/conversion_log.body.php
@@ -27,6 +27,7 @@
2828 }
2929
3030 static function onPostProcess( &$gateway_adapter ) {
 31+ $gateway_adapter->debugarray[] = 'conversion log onPostProcess hook!';
3132 return self::singleton( $gateway_adapter )->post_process();
3233 }
3334
Index: branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php
@@ -1,8 +1,8 @@
22 <?php
 3+
34 /**
45 * Validates a transaction against MaxMind's minFraud service
56 */
6 -
77 class Gateway_Extras_reCaptcha extends Gateway_Extras {
88
99 /**
@@ -18,7 +18,7 @@
1919
2020 public function __construct( &$gateway_adapter ) {
2121 parent::__construct( $gateway_adapter );
22 -
 22+
2323 //stash all the vars that reCaptcha is going to need in a global just for it.
2424 //I know this is vaguely unpleasant, but it's the quickest way back to zero.
2525 global $wgReCaptchaConfData;
@@ -28,7 +28,6 @@
2929 $wgReCaptchaConfData['UseSSL'] = $this->getGlobal( 'RecaptchaUseSSL' );
3030 $wgReCaptchaConfData['ComsRetryLimit'] = $this->getGlobal( 'RecaptchaComsRetryLimit' );
3131 $wgReCaptchaConfData['GatewayClass'] = $this->gateway_adapter->getGatewayAdapterClass(); //for properly routing the logging
32 -
3332 // load the reCaptcha API
3433 require_once( dirname( __FILE__ ) . '/recaptcha-php/recaptchalib.php' );
3534 }
@@ -38,7 +37,7 @@
3938 */
4039 public function challenge() {
4140 // if captcha posted, validate
42 - if ( isset( $_POST[ 'recaptcha_response_field' ] ) ) {
 41+ if ( isset( $_POST['recaptcha_response_field'] ) ) {
4342 // check the captcha response
4443 $captcha_resp = $this->check_captcha();
4544 if ( $captcha_resp->is_valid ) {
@@ -72,10 +71,9 @@
7372 $captcha_html .= recaptcha_get_html( $publicKey, $this->recap_err, $useSSL );
7473 $captcha_html .= '<span class="creditcard-error-msg">' . wfMsg( $this->gateway_adapter->getIdentifier() . '_gateway-error-msg-captcha-please' ) . '</span>';
7574 $captcha_html .= Xml::closeElement( 'div' ); // close div#mw-donate-captcha
76 -
7775 // load up the form class
7876 $form_class = $this->gateway_adapter->getFormClass();
79 -
 77+
8078 //hmm. Looking at this now, makes me want to say
8179 //TODO: Refactor the Form Class constructors. Again. Because the next three lines of code anger me deeply.
8280 //#1 - all three things are clearly in the gateway adapter, and we're passing that already.
@@ -97,15 +95,13 @@
9896 public function check_captcha() {
9997 global $wgRequest;
10098 $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' ) );
105100
106101 return $resp;
107102 }
108103
109104 static function onChallenge( &$gateway_adapter ) {
 105+ $gateway_adapter->debugarray[] = 'recaptcha onChallenge hook!';
110106 return self::singleton( $gateway_adapter )->challenge();
111107 }
112108
@@ -115,4 +111,5 @@
116112 }
117113 return self::$instance;
118114 }
 115+
119116 }
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -51,9 +51,8 @@
5252 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 310, 350 );
5353 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'revised', 400 );
5454 $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...
5857 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete', 1000, 1050 );
5958 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 1100, 99999 );
6059 }
@@ -155,8 +154,8 @@
156155 'HOSTEDINDICATOR' => '1',
157156 //'PAYMENTPRODUCTID' => '11',
158157 ),
159 - 'do_validation' => 'true',
160 - 'do_processhooks' => 'true',
 158+ 'do_validation' => true,
 159+ 'addDonorDataToSession' => true,
161160 );
162161
163162 $this->transactions['TEST_CONNECTION'] = array(
@@ -195,6 +194,15 @@
196195 'values' => array(
197196 'ACTION' => 'GET_ORDERSTATUS',
198197 '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',
199207 )
200208 );
201209 }
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -class GlobalCollectGatewayResult extends UnlistedSpecialPage {
 4+class GlobalCollectGatewayResult extends GatewayForm {
55
66 /**
77 * Defines the action to take on a PFP transaction.
@@ -26,10 +26,8 @@
2727 * Constructor - set up the new special page
2828 */
2929 public function __construct() {
30 - parent::__construct( 'GlobalCollectGatewayResult' );
31 - $this->errors = $this->getPossibleErrors();
32 -
3330 $this->adapter = new GlobalCollectAdapter();
 31+ parent::__construct(); //the next layer up will know who we are.
3432 }
3533
3634 /**
@@ -80,25 +78,15 @@
8179
8280 switch ( $result['data']['WMF_STATUS'] ) {
8381 case 'complete':
84 - $wgOut->addHTML( "Add successful stomp message, go to the thank you page..." );
85 - $go = $this->adapter->getThankYouPage();
86 - break;
8782 case 'pending':
88 - $wgOut->addHTML( "Add pending stomp message, go to the thank you page..." );
89 - $go = $this->adapter->getThankYouPage();
90 - break;
9183 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." );
9384 $go = $this->adapter->getThankYouPage();
9485 break;
9586 case 'failed':
96 - $wgOut->addHTML( "Toss it, go to fail page..." );
9787 $go = $this->adapter->getFailPage();
9888 break;
9989 }
100 - $this->adapter->doStompTransaction( $result['data'], $result['message'], $result['data']['WMF_STATUS'], true );
10190
102 - $this->adapter->unsetAllGatewaySessionData();
10391 $wgOut->addHTML( "<br>Redirecting to page $go" );
10492 $wgOut->redirect( $go );
10593 }
@@ -110,133 +98,6 @@
11199 }
112100 }
113101 }
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 -
241102 }
242103
243104 // end class

Follow-up revisions

RevisionCommit summaryAuthorDate
r102047Establishes constraints on settable fields that should contain the over-archi...khorn21:09, 4 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98498Rebuilding the payflowpro gateway and adapter, Part 2 of Several!...khorn01:45, 30 September 2011

Status & tagging log