r98826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98825‎ | r98826 | r98827 >
Date:23:09, 3 October 2011
Author:khorn
Status:ok
Tags:
Comment:
More bug squashing surrounding the extras in DonationInterface. r98498
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/extras/minfraud/ccfd/HTTPBase.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/GatewayForm.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -80,6 +80,7 @@
8181 if ( $this->adapter->action == 'process' ) {
8282 $this->fnPayflowDisplayResults( $result );
8383 }
 84+ $this->displayResultsForDebug( $result );
8485 }
8586 } else {
8687 // Display form for the first time
@@ -117,25 +118,31 @@
118119
119120 // if approved, display results and send transaction to the queue
120121 if ( $errorCode == '1' ) {
121 - self::log( $oid . " " . $i_oid . " Transaction approved.", LOG_DEBUG );
122 - $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg );
 122+ $this->log( $oid . " " . $i_oid . " Transaction approved.", LOG_DEBUG );
 123+ $this->fnPayflowDisplayApprovedResults( $data, $responseMsg );
123124 // give user a second chance to enter incorrect data
124125 } elseif ( ( $errorCode == '3' ) && ( $data['numAttempt'] < '5' ) ) {
125 - self::log( $oid . " " . $i_oid . " Transaction unsuccessful (invalid info).", LOG_DEBUG );
 126+ $this->log( $oid . " " . $i_oid . " Transaction unsuccessful (invalid info).", LOG_DEBUG );
126127 // pass responseMsg as an array key as required by displayForm
127128 $this->errors['retryMsg'] = $responseMsg;
128129 $this->fnPayflowDisplayForm( $data, $this->errors );
129130 // if declined or if user has already made two attempts, decline
130131 } elseif ( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '3' ) ) {
131 - self::log( $oid . " " . $i_oid . " Transaction declined.", LOG_DEBUG );
 132+ $this->log( $oid . " " . $i_oid . " Transaction declined.", LOG_DEBUG );
132133 $this->fnPayflowDisplayDeclinedResults( $responseMsg );
133134 } elseif ( ( $errorCode == '4' ) ) {
134 - self::log( $oid . " " . $i_oid . " Transaction unsuccessful.", LOG_DEBUG );
 135+ $this->log( $oid . " " . $i_oid . " Transaction unsuccessful.", LOG_DEBUG );
135136 $this->fnPayflowDisplayOtherResults( $responseMsg );
136137 } elseif ( ( $errorCode == '5' ) ) {
137 - self::log( $oid . " " . $i_oid . " Transaction pending.", LOG_DEBUG );
138 - $this->fnPayflowDisplayPending( $data, $responseArray, $responseMsg );
 138+ $this->log( $oid . " " . $i_oid . " Transaction pending.", LOG_DEBUG );
 139+ $this->fnPayflowDisplayPending( $data, $responseMsg );
 140+ } elseif ( ( $errorCode == '1000000' ) ) { //TODO: This is temporary until we can decide on the actual error codes WE control.
 141+ $this->log( $oid . " " . $i_oid . " Transaction unsuccessful (communication failure).", LOG_DEBUG );
 142+ $this->fnPayflowDisplayOtherResults( $responseMsg );
 143+ $this->errors['retryMsg'] = $responseMsg;
 144+ $this->fnPayflowDisplayForm( $data, $this->errors );
139145 }
 146+ $this->displayResultsForDebug( $result );
140147 }
141148
142149 /**
@@ -144,19 +151,9 @@
145152 * @param $data Array: array of posted data from form
146153 * @param $responseMsg String: message supplied by getResults function
147154 */
148 - function fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ) {
 155+ function fnPayflowDisplayApprovedResults( $data, $responseMsg ) {
149156 global $wgOut, $wgExternalThankYouPage;
150157
151 - $transaction = $this->prepareStompTransaction( $data, $responseArray, $responseMsg );
152 -
153 - /**
154 - * hook to call stomp functions
155 - *
156 - * Sends transaction to Stomp-based queueing service,
157 - * eg ActiveMQ
158 - */
159 - wfRunHooks( 'gwStomp', array( $transaction ) );
160 -
161158 if ( $wgExternalThankYouPage ) {
162159 $wgOut->redirect( $wgExternalThankYouPage . "/" . $data['language'] );
163160 } else {
@@ -200,23 +197,14 @@
201198 * @param $responseMsg String: message supplied by getResults function
202199 */
203200 function fnPayflowDisplayOtherResults( $responseMsg ) {
204 - global $wgOut;
205 -
206 - // general decline message
207 - $declinedDefault = wfMsg( 'php-response-declined' );
208 -
209 - // display response message
210 - $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . ' ' . $responseMsg . '</h3>' );
 201+ //I have collapsed it like this because the contents were identical.
 202+ //TODO: Determine if we need to be switching on anything else in the display here.
 203+ $this->fnPayflowDisplayDeclinedResults( $responseMsg );
211204 }
212205
213 - function fnPayflowDisplayPending( $data, $responseArray, $responseMsg ) {
 206+ function fnPayflowDisplayPending( $responseMsg ) {
214207 global $wgOut;
215208
216 - $transaction = $this->prepareStompTransaction( $data, $responseArray, $responseMsg );
217 -
218 - // hook to call stomp functions
219 - wfRunHooks( 'gwPendingStomp', array( $transaction ) );
220 -
221209 $thankyou = wfMsg( 'payflowpro_gateway-thankyou' );
222210
223211 // display response message
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -32,15 +32,15 @@
3333
3434
3535 // set defaults, these should be assigned in LocalSettings.php
36 -$wgPayflowProURL = 'https://payflowpro.paypal.com';
37 -$wgPayflowProTestingURL = 'https://pilot-payflowpro.paypal.com'; // Payflow testing URL
 36+$wgPayflowProGatewayURL = 'https://payflowpro.paypal.com';
 37+$wgPayflowProGatewayTestingURL = 'https://pilot-payflowpro.paypal.com'; // Payflow testing URL
3838
3939 $wgPayFlowProGatewayCSSVersion = 1;
4040
41 -$wgPayflowProPartnerID = ''; // PayPal or original authorized reseller
42 -$wgPayflowProVendorID = ''; // paypal merchant login ID
43 -$wgPayflowProUserID = ''; // if one or more users are set up, authorized user ID, else same as VENDOR
44 -$wgPayflowProPassword = ''; // merchant login password
 41+$wgPayflowProGatewayPartnerID = ''; // PayPal or original authorized reseller
 42+$wgPayflowProGatewayVendorID = ''; // paypal merchant login ID
 43+$wgPayflowProGatewayUserID = ''; // if one or more users are set up, authorized user ID, else same as VENDOR
 44+$wgPayflowProGatewayPassword = ''; // merchant login password
4545 // a boolean to determine if we're in testing mode
4646 $wgPayflowProGatewayTest = FALSE;
4747
Index: branches/fundraising/extensions/DonationInterface/extras/minfraud/ccfd/HTTPBase.php
@@ -158,6 +158,9 @@
159159 $datetime = fgets( $fh, 1024 );
160160 $datetime = rtrim( $datetime );
161161 fclose( $fh );
 162+ } else {
 163+ //otherwise, this thing complains loudly when the file doesn't exist.
 164+ $datetime = time();
162165 }
163166
164167 // if the ip addresses expired or don't exist then
Index: branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.body.php
@@ -270,7 +270,7 @@
271271 }
272272
273273 static function onValidate( &$gateway_adapter ) {
274 - $gateway_adapter->debugarray[] = "Running an onValidate hook!";
 274+ $gateway_adapter->debugarray[] = "minfraud onValidate hook!";
275275 return self::singleton( $gateway_adapter )->validate();
276276 }
277277
Index: branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php
@@ -17,7 +17,7 @@
1818 public $recap_err;
1919
2020 public function __construct( &$gateway_adapter ) {
21 - parent::__construct( &$gateway_adapter );
 21+ parent::__construct( $gateway_adapter );
2222
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.
@@ -77,8 +77,12 @@
7878 $form_class = $this->gateway_adapter->getFormClass();
7979
8080 //hmm. Looking at this now, makes me want to say
81 - //TODO: Refactor the Form Class constructors. Again.
82 - $form_obj = new $form_class( $this->gateway_adapter->getData(), $this->gateway_adapter->getValidationErrors(), $this->gateway_adapter);
 81+ //TODO: Refactor the Form Class constructors. Again. Because the next three lines of code anger me deeply.
 82+ //#1 - all three things are clearly in the gateway adapter, and we're passing that already.
 83+ //#2 - I have to stuff them in variables because Form wants parameters by reference.
 84+ $data = $this->gateway_adapter->getData();
 85+ $erros = $this->gateway_adapter->getValidationErrors();
 86+ $form_obj = new $form_class( $data, $errors, $this->gateway_adapter );
8387
8488 // set the captcha HTML to use in the form
8589 $form_obj->setCaptchaHTML( $captcha_html );
@@ -102,12 +106,12 @@
103107 }
104108
105109 static function onChallenge( &$gateway_adapter ) {
106 - return self::singleton( &$gateway_adapter )->challenge();
 110+ return self::singleton( $gateway_adapter )->challenge();
107111 }
108112
109113 static function singleton( &$gateway_adapter ) {
110114 if ( !self::$instance ) {
111 - self::$instance = new self( &$gateway_adapter );
 115+ self::$instance = new self( $gateway_adapter );
112116 }
113117 return self::$instance;
114118 }
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -354,7 +354,7 @@
355355
356356 // expose a hook for external handling of trxns ready for processing
357357 wfRunHooks( 'GatewayProcess', array( &$this ) ); //don't think anybody is using this yet, but you could!
358 -
 358+
359359 $this->dataObj->updateContributionTracking( defined( 'OWA' ) );
360360 if ( $this->getCommunicationType() === 'xml' ) {
361361 $this->getStopwatch( "buildRequestXML" );
@@ -365,7 +365,6 @@
366366 }
367367
368368 if ( $this->getCommunicationType() === 'namevalue' ) {
369 - $namevalue = $this->postdata;
370369 //buildRequestNameValueString()
371370 $this->getStopwatch( "buildRequestNameValueString" );
372371 $namevalstring = $this->buildRequestNameValueString();
Index: branches/fundraising/extensions/DonationInterface/gateway_common/GatewayForm.php
@@ -43,6 +43,7 @@
4444 $me = get_called_class();
4545 parent::__construct( $me );
4646 $this->errors = $this->getPossibleErrors();
 47+ $this->setFormClass();
4748 }
4849
4950 /**
@@ -406,7 +407,10 @@
407408 }
408409
409410 function displayResultsForDebug( $results ) {
410 - global $wgOut;
 411+ global $wgOut, $wgDonationInterfaceDisplayDebug;
 412+ if ( $wgDonationInterfaceDisplayDebug !== true ){
 413+ return;
 414+ }
411415 $wgOut->addHTML( $results['message'] );
412416
413417 if ( !empty( $results['errors'] ) ) {
@@ -552,7 +556,7 @@
553557 return $usd_amount;
554558 }
555559
556 - public static function log( $msg, $log_level=LOG_INFO ) {
 560+ public function log( $msg, $log_level=LOG_INFO ) {
557561 $this->adapter->log( $msg, $log_level );
558562 }
559563

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