r101174 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101173‎ | r101174 | r101175 >
Date:19:13, 28 October 2011
Author:awjrichards
Status:deferred
Tags:
Comment:
Modified paths:
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/ccfd/HTTPBase.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/donation.api.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects_2_3step.js (modified) (history)

Diff [purge]

Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/ccfd/HTTPBase.php
@@ -161,6 +161,7 @@
162162 } else {
163163 //otherwise, this thing complains loudly when the file doesn't exist.
164164 $datetime = time();
 165+ $ipstr = false;
165166 }
166167
167168 // if the ip addresses expired or don't exist then
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras
___________________________________________________________________
Modified: svn:mergeinfo
168169 Merged /trunk/extensions/DonationInterface/extras:r101163
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects_2_3step.js
@@ -159,6 +159,11 @@
160160 'payment_method': 'card',
161161 'language': language,
162162 'card_type': $( "input[name='cardtype']" ).val().toLowerCase(),
 163+ 'contribution_tracking_id': $( "input[name='contribution_tracking_id']" ).val(),
 164+ 'numAttempt': $( "input[name='numAttempt']" ).val(),
 165+ 'utm_source': $( "input[name='utm_source']" ).val(),
 166+ 'utm_campaign': $( "input[name='utm_campaign']" ).val(),
 167+ 'utm_medium': $( "input[name='utm_medium']" ).val(),
163168 'format': 'json'
164169 };
165170 $.ajax( {
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -1241,21 +1241,6 @@
12421242 return;
12431243 }
12441244
1245 - $data = $this->getTransactionData();
1246 -
1247 - //Gah. I might want to move all this data prep business upstream more than somewhat.
1248 - //...but that's for later.
1249 - // Add the session vars to the data object
1250 - if ( $this->transaction_option( 'pullDonorDataFromSession' ) ) {
1251 - $this->dataObj->populateDonorFromSession();
1252 - }
1253 -
1254 - // refresh our data directly, which we should NEVER EVER DO WITHOUT STAGING.
1255 - $this->postdata = $this->dataObj->getData();
1256 -
1257 - // stage the gateway data
1258 - $this->stageData( 'response' );
1259 -
12601245 // send the thing.
12611246 $transaction = array(
12621247 'response' => $this->getTransactionMessage(),
@@ -1263,7 +1248,7 @@
12641249 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
12651250 //'language' => '',
12661251 );
1267 - $transaction += $this->getData();
 1252+ $transaction += $this->getDisplayData();
12681253
12691254 self::log( "Intended STOMP transaction: " . print_r( $transaction, true ) );
12701255
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/donation.api.php
@@ -107,6 +107,11 @@
108108 'payment_submethod' => $this->defineParam( false ),
109109 'language' => $this->defineParam( false ),
110110 'order_id' => $this->defineParam( false ),
 111+ 'contribution_tracking_id' => $this->defineParam( false ),
 112+ 'numAttempt' => $this->defineParam( false ),
 113+ 'utm_source' => $this->defineParam( false ),
 114+ 'utm_campaign' => $this->defineParam( false ),
 115+ 'utm_medium' => $this->defineParam( false ),
111116 );
112117 }
113118
@@ -170,6 +175,11 @@
171176 'payment_submethod' => 'Payment submethod to use',
172177 'language' => 'Language code',
173178 'order_id' => 'Order ID (if a donation has already been started)',
 179+ 'contribution_tracking_id' => 'ID for contribution tracking table',
 180+ 'numAttempt' => 'How many attempts have been made to donate',
 181+ 'utm_source' => 'Tracking variable',
 182+ 'utm_campaign' => 'Tracking variable',
 183+ 'utm_medium' => 'Tracking variable',
174184 );
175185 }
176186
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
@@ -87,21 +87,47 @@
8888 $this->setVal( 'posted', false );
8989 }
9090 }
 91+
 92+ //if we have saved any donation data to the session, pull them in as well.
 93+ $this->integrateDataFromSession();
 94+
9195 $this->doCacheStuff();
9296
9397 $this->normalizeAndSanitize();
9498
95 - //TODO: test with _cache_ on.
96 -// if ( !empty( $this->normalized ) &&
97 -// ( $this->getVal( 'numAttempt' ) == '0' &&
98 -// ((!$this->getVal( 'utm_source_id' ) == false ) ||
99 -// is_null($this->getVal( '_cache_' )) ) ) ) {
100 -// error_log('about to save contribution tracking from an initial populate: ' . $this->getVal('contribution_tracking_id'));
101 -
102 - if (!$this->isSomething( 'contribution_tracking_id' )){
103 - $this->saveContributionTracking();
104 - }
10599 }
 100+
 101+ /**
 102+ * populateData helper function
 103+ * If donor session data has been set, pull the fields in the session that
 104+ * are populated, and merge that with the data set we already have.
 105+ * Then, unset the session variable to avoid later confusion.
 106+ */
 107+ function integrateDataFromSession(){
 108+ self::ensureSession();
 109+ if ( array_key_exists( 'Donor', $_SESSION ) ) {
 110+ //if the thing coming in from the session isn't already something,
 111+ //replace it.
 112+ //if it is: assume that the session data was meant to be replaced
 113+ //with better data.
 114+ //...unless it's referrer.
 115+ //TODO: Keep an eye on anything that is calculated programmatically
 116+ //during the form data pull, and not afterward in the normalize bits.
 117+ //TODO: Stop calculating things during the actual data pull, because
 118+ //that's totally bogus.
 119+ foreach ( $_SESSION['Donor'] as $key => $val ){
 120+ if ( !$this->isSomething( $key ) ){
 121+ $this->setVal( $key, $val );
 122+ } else {
 123+ //TODO: Change this to a switch statement if we get more
 124+ //fields in here.
 125+ if ( $key === 'referrer' ){
 126+ $this->setVal( $key, $val );
 127+ }
 128+ }
 129+ }
 130+ }
 131+ }
106132
107133 function getData() {
108134 return $this->normalized;
@@ -184,6 +210,11 @@
185211 }
186212 }
187213
 214+ /**
 215+ * Tells you if a value is something or not.
 216+ * @param string $key The field you would like to determine if it exists or not.
 217+ * @return boolean true if the field is something. False if it is null, or an empty string.
 218+ */
188219 function isSomething( $key ) {
189220 if ( array_key_exists( $key, $this->normalized ) ) {
190221 if ( is_null($this->normalized[$key]) || $this->normalized[$key] === '' ) {
@@ -220,12 +251,39 @@
221252 $this->setGateway();
222253 $this->setNormalizedOptOuts();
223254 $this->setLanguage();
 255+ $this->handleContributionTrackingID();
224256 array_walk( $this->normalized, array( $this, 'sanitizeInput' ) );
225257 }
226258 }
 259+
 260+ /**
 261+ * normalizeAndSanitize helper function.
 262+ * Assures that if no contribution_tracking_id is present, a row is created
 263+ * in the Contribution tracking table, and that row is assigned to the
 264+ * current contribution we're tracking.
 265+ * If a contribution tracking id is already present, no new rows will be
 266+ * assigned.
 267+ */
 268+ function handleContributionTrackingID(){
 269+ //TODO: test with _cache_ on.
 270+
 271+ //what follows here is the original horrible if statement for comparison to the new line (below).
 272+ //TODO: whack this when we know the replacement is solid.
 273+// if ( !empty( $this->normalized ) &&
 274+// ( $this->getVal( 'numAttempt' ) == '0' &&
 275+// ((!$this->getVal( 'utm_source_id' ) == false ) ||
 276+// is_null($this->getVal( '_cache_' )) ) ) ) {
 277+// $this->saveContributionTracking();
 278+// }
 279+
 280+ if ( !$this->isSomething( 'contribution_tracking_id' ) &&
 281+ ( $this->getVal( 'utm_source_id' ) !== false || !$this->isSomething( '_cache_' ) ) ){
 282+ $this->saveContributionTracking();
 283+ }
 284+ }
227285
228286 /**
229 - * normalizeAndSanitize helper function
 287+ * normalizeAndSanitize helper function.
230288 * Takes all possible sources for the intended donation amount, and
231289 * normalizes them into the 'amount' field.
232290 */
@@ -242,7 +300,7 @@
243301 }
244302
245303 /**
246 - * normalizeAndSanitize helper function
 304+ * normalizeAndSanitize helper function.
247305 * Ensures that order_id and i_order_id are ready to go, depending on what
248306 * comes in populated or not, and where it came from.
249307 * @return null
@@ -276,9 +334,9 @@
277335 }
278336
279337 /**
280 - * Sanitize user input
 338+ * Sanitize user input.
281339 *
282 - * Intended to be used with something like array_walk
 340+ * Intended to be used with something like array_walk.
283341 *
284342 * @param $value The value of the array
285343 * @param $key The key of the array
@@ -326,7 +384,7 @@
327385 }
328386
329387 /**
330 - * normalizeAndSanitize helper function
 388+ * normalizeAndSanitize helper function.
331389 * If the language has not yet been set, pulls the language code
332390 * from the current global language object.
333391 */
@@ -364,7 +422,7 @@
365423 }
366424
367425 /**
368 - * Establish an 'edit' token to help prevent CSRF, etc
 426+ * Establish an 'edit' token to help prevent CSRF, etc.
369427 *
370428 * We use this in place of $wgUser->editToken() b/c currently
371429 * $wgUser->editToken() is broken (apparently by design) for
@@ -427,7 +485,7 @@
428486 }
429487
430488 /**
431 - * Unset the payflow edit token from a user's session
 489+ * Unset the payflow edit token from a user's session.
432490 *
433491 * TODO: Get rid of this, if we end up using the new, much more draconian
434492 * killAllSessionEverything().
@@ -441,7 +499,7 @@
442500 }
443501
444502 /**
445 - * Ensure that we have a session set for the current user
 503+ * Ensure that we have a session set for the current user.
446504 *
447505 * If we do not have a session set for the current user,
448506 * start the session.
@@ -606,8 +664,11 @@
607665 return $tracking_data;
608666 }
609667
610 - //if ( !empty($data) && ( $data[ 'numAttempt' ] == '0' && ( !$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) ) {
611 - //so, basically, if this is the first attempt. This seems to get called nowhere else.
 668+ /**
 669+ * Saves a NEW ROW in the Contribution Tracking table and returns the new ID.
 670+ * @return boolean true if we got a contribution tracking # back, false if
 671+ * something went wrong.
 672+ */
612673 function saveContributionTracking() {
613674
614675 $tracked_contribution = $this->getCleanTrackingData();
@@ -685,19 +746,7 @@
686747
687748 public function addDonorDataToSession() {
688749 self::ensureSession();
689 - $donordata = array(
690 - 'email',
691 - 'fname',
692 - 'mname',
693 - 'lname',
694 - 'street',
695 - 'city',
696 - 'state',
697 - 'zip',
698 - 'country',
699 - 'contribution_tracking_id',
700 - 'referrer'
701 - );
 750+ $donordata = $this->getStompMessageFields();
702751
703752 foreach ( $donordata as $item ) {
704753 if ( $this->isSomething( $item ) ) {
@@ -706,12 +755,6 @@
707756 }
708757 }
709758
710 - public function populateDonorFromSession() {
711 - if ( array_key_exists( 'Donor', $_SESSION ) ) {
712 - $this->addData( $_SESSION['Donor'] );
713 - }
714 - }
715 -
716759 /**
717760 * Unsets the session data, in the case that we've saved it for gateways
718761 * like GlobalCollect that require it to persist over here through their
@@ -764,6 +807,53 @@
765808 return false;
766809 }
767810 }
 811+
 812+ /**
 813+ * Returns an array of field names we intend to send to activeMQ via a Stomp
 814+ * message. Note: These are field names from the FORM... not the field names
 815+ * that will appear in the stomp message.
 816+ * TODO: Move the mapping for donation data from
 817+ * /extensions/DonationData/activemq_stomp/activemq_stomp.php
 818+ * to somewhere in DonationData. *
 819+ */
 820+ function getStompMessageFields(){
 821+ $stomp_fields = array(
 822+ 'contribution_tracking_id',
 823+ 'optout',
 824+ 'anonymous',
 825+ 'comment',
 826+ 'size',
 827+ 'premium_language',
 828+ 'utm_source',
 829+ 'utm_medium',
 830+ 'utm_campaign',
 831+ 'language',
 832+ 'referrer',
 833+ 'email',
 834+ 'fname',
 835+ 'mname',
 836+ 'lname',
 837+ 'street',
 838+ 'city',
 839+ 'state',
 840+ 'country',
 841+ 'zip',
 842+ 'fname2',
 843+ 'lname2',
 844+ 'street2',
 845+ 'city2',
 846+ 'state2',
 847+ 'country2',
 848+ 'zip2',
 849+ 'gateway',
 850+ 'gateway_txn_id',
 851+ 'response',
 852+ 'currency',
 853+ 'amount',
 854+ 'date',
 855+ );
 856+ return $stomp_fields;
 857+ }
768858
769859 }
770860
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface
___________________________________________________________________
Modified: svn:mergeinfo
771861 Merged /trunk/extensions/DonationInterface:r101112,101163

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101112adding missing params to AJAX and API for globalcollectkaldari02:06, 28 October 2011
r101163DonationData session handling, for gateways (GlobalCollect) that require us t...khorn18:33, 28 October 2011

Status & tagging log