Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -252,6 +252,12 @@ |
253 | 253 | return $checkResult; |
254 | 254 | } |
255 | 255 | |
| 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 | + */ |
256 | 262 | function getData( $val = '' ) { |
257 | 263 | if ( $val === '' ) { |
258 | 264 | return $this->postdata; |
— | — | @@ -275,8 +281,16 @@ |
276 | 282 | return $this->dataObj; |
277 | 283 | } |
278 | 284 | |
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 | + } |
281 | 295 | } |
282 | 296 | |
283 | 297 | function isCache() { |
— | — | @@ -1259,7 +1273,7 @@ |
1260 | 1274 | //what do we do in the event that we're still nothing? (just move on.) |
1261 | 1275 | } |
1262 | 1276 | } |
1263 | | - |
| 1277 | + |
1264 | 1278 | /** |
1265 | 1279 | * |
1266 | 1280 | * @param type $type Whatever types of staging you feel like having in your child class. |
— | — | @@ -1274,24 +1288,29 @@ |
1275 | 1289 | $function_name = 'stage_' . $field; |
1276 | 1290 | if ( method_exists( $this, $function_name ) ) { |
1277 | 1291 | $this->{$function_name}( $type ); |
1278 | | - } |
1279 | 1292 | } |
1280 | 1293 | } |
| 1294 | + } |
1281 | 1295 | |
1282 | 1296 | function getPaypalRedirectURL() { |
1283 | 1297 | $utm_source = $this->getData( 'utm_source' ); |
1284 | 1298 | |
1285 | 1299 | // 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'; |
1290 | 1301 | $data['currency_code'] = isset( $data['currency'] ) ? $data['currency'] : 'USD'; |
1291 | 1302 | |
1292 | 1303 | // 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]. |
1294 | 1305 | // 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! |
1296 | 1315 | |
1297 | 1316 | //update contribution tracking |
1298 | 1317 | $this->dataObj->updateContributionTracking( true ); |
— | — | @@ -1334,9 +1353,9 @@ |
1335 | 1354 | ); |
1336 | 1355 | $ret = array(); |
1337 | 1356 | foreach ( $paypalkeys as $key ){ |
1338 | | - $val = $this->getData( $key ); |
| 1357 | + $val = $this->getDisplayData( $key ); |
1339 | 1358 | if (!is_null( $val )){ |
1340 | | - $ret[$key] = $this->getData( $key ); |
| 1359 | + $ret[$key] = $this->getDisplayData( $key ); |
1341 | 1360 | } |
1342 | 1361 | } |
1343 | 1362 | return $ret; |
— | — | @@ -1522,8 +1541,8 @@ |
1523 | 1542 | } |
1524 | 1543 | } else { |
1525 | 1544 | $this->action = 'process'; //we have to do this so do_transaction doesn't kick out. |
1526 | | - } |
1527 | 1545 | } |
| 1546 | + } |
1528 | 1547 | |
1529 | 1548 | function transaction_option( $option_value ) { |
1530 | 1549 | //ooo, ugly. |
— | — | @@ -1567,5 +1586,5 @@ |
1568 | 1587 | unset( $this->displaydata[$val] ); |
1569 | 1588 | } |
1570 | 1589 | } |
1571 | | - |
| 1590 | + |
1572 | 1591 | } |