r101669 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101668‎ | r101669 | r101670 >
Date:20:10, 2 November 2011
Author:khorn
Status:ok
Tags:
Comment:
The data used for a paypal redirect needs to be our raw, unstaged data: Not the data staged for a specific gateway. This wasn't a problem before, because I has been pulling it back from DonationData raw, and not staging it, which is both confusing, and bad form.
Additional: Since the utm_source calculation moved to DonationData, the paypal redirect didn't save the correct utm_source to contribution_tracking any longer. This corrects that issue as well.
r99606, r101441
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -252,6 +252,12 @@
253253 return $checkResult;
254254 }
255255
 256+ /**
 257+ * Returns staged data from the adapter object.
 258+ * @param string $val An optional specific key you want returned.
 259+ * @return mixed All the staged data held by the adapter, or if a key was
 260+ * set, the staged value for that key.
 261+ */
256262 function getData( $val = '' ) {
257263 if ( $val === '' ) {
258264 return $this->postdata;
@@ -275,8 +281,16 @@
276282 return $this->dataObj;
277283 }
278284
279 - function getDisplayData() {
280 - return $this->displaydata;
 285+ function getDisplayData( $val = '' ) {
 286+ if ( $val === '' ) {
 287+ return $this->displaydata;
 288+ } else {
 289+ if ( array_key_exists( $val, $this->displaydata ) ) {
 290+ return $this->displaydata[$val];
 291+ } else {
 292+ return null;
 293+ }
 294+ }
281295 }
282296
283297 function isCache() {
@@ -1259,7 +1273,7 @@
12601274 //what do we do in the event that we're still nothing? (just move on.)
12611275 }
12621276 }
1263 -
 1277+
12641278 /**
12651279 *
12661280 * @param type $type Whatever types of staging you feel like having in your child class.
@@ -1274,24 +1288,29 @@
12751289 $function_name = 'stage_' . $field;
12761290 if ( method_exists( $this, $function_name ) ) {
12771291 $this->{$function_name}( $type );
1278 - }
12791292 }
12801293 }
 1294+ }
12811295
12821296 function getPaypalRedirectURL() {
12831297 $utm_source = $this->getData( 'utm_source' );
12841298
12851299 // update the utm source to set the payment instrument to pp rather than cc
1286 - $utm_source_parts = explode( ".", $utm_source );
1287 - $utm_source_parts[2] = 'pp';
1288 - $data['utm_source'] = implode( ".", $utm_source_parts );
1289 - $data['gateway'] = 'paypal';
 1300+ $data['payment_method'] = 'pp';
12901301 $data['currency_code'] = isset( $data['currency'] ) ? $data['currency'] : 'USD';
12911302
12921303 // Add our response vars to the data object.
1293 - $this->dataObj->addData( $data );
 1304+ $this->dataObj->addData( $data ); //addData will, among other things, rebuild the utm_[stuff].
12941305 // refresh our data
1295 - $this->postdata = $this->dataObj->getData();
 1306+ foreach ( $data as $key => $value){
 1307+ $this->refreshGatewayValueFromSource( $key );
 1308+ }
 1309+ //TODO: Make an array of calculated fields in DonationData...
 1310+ //in other words: Fields that will get recalculated on a normalizeAndSanitize()...
 1311+ //so we don't have to _know_ to do this, when we add data.
 1312+ //In fact, put that in addData, and restage anything that's either the explicit key,
 1313+ //or any of the calculated keys.
 1314+ $this->refreshGatewayValueFromSource( 'utm_source' ); //calculated field!
12961315
12971316 //update contribution tracking
12981317 $this->dataObj->updateContributionTracking( true );
@@ -1334,9 +1353,9 @@
13351354 );
13361355 $ret = array();
13371356 foreach ( $paypalkeys as $key ){
1338 - $val = $this->getData( $key );
 1357+ $val = $this->getDisplayData( $key );
13391358 if (!is_null( $val )){
1340 - $ret[$key] = $this->getData( $key );
 1359+ $ret[$key] = $this->getDisplayData( $key );
13411360 }
13421361 }
13431362 return $ret;
@@ -1522,8 +1541,8 @@
15231542 }
15241543 } else {
15251544 $this->action = 'process'; //we have to do this so do_transaction doesn't kick out.
1526 - }
15271545 }
 1546+ }
15281547
15291548 function transaction_option( $option_value ) {
15301549 //ooo, ugly.
@@ -1567,5 +1586,5 @@
15681587 unset( $this->displaydata[$val] );
15691588 }
15701589 }
1571 -
 1590+
15721591 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r101746MFT r101074, r101217, r101236, r101382, r101501, r101503, r101504, r101512, r...awjrichards23:23, 2 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99606Only sends data paypal can process (that isn't null) on a paypal redirect....khorn00:18, 12 October 2011
r101441Fixes the api calls that handle gateway forms with _cache_ set to true, and a...khorn00:07, 1 November 2011

Status & tagging log