Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/ccfd/HTTPBase.php |
— | — | @@ -161,6 +161,7 @@ |
162 | 162 | } else { |
163 | 163 | //otherwise, this thing complains loudly when the file doesn't exist. |
164 | 164 | $datetime = time(); |
| 165 | + $ipstr = false; |
165 | 166 | } |
166 | 167 | |
167 | 168 | // 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 |
168 | 169 | 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 @@ |
160 | 160 | 'payment_method': 'card', |
161 | 161 | 'language': language, |
162 | 162 | '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(), |
163 | 168 | 'format': 'json' |
164 | 169 | }; |
165 | 170 | $.ajax( { |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -1241,21 +1241,6 @@ |
1242 | 1242 | return; |
1243 | 1243 | } |
1244 | 1244 | |
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 | | - |
1260 | 1245 | // send the thing. |
1261 | 1246 | $transaction = array( |
1262 | 1247 | 'response' => $this->getTransactionMessage(), |
— | — | @@ -1263,7 +1248,7 @@ |
1264 | 1249 | 'gateway_txn_id' => $this->getTransactionGatewayTxnID(), |
1265 | 1250 | //'language' => '', |
1266 | 1251 | ); |
1267 | | - $transaction += $this->getData(); |
| 1252 | + $transaction += $this->getDisplayData(); |
1268 | 1253 | |
1269 | 1254 | self::log( "Intended STOMP transaction: " . print_r( $transaction, true ) ); |
1270 | 1255 | |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/donation.api.php |
— | — | @@ -107,6 +107,11 @@ |
108 | 108 | 'payment_submethod' => $this->defineParam( false ), |
109 | 109 | 'language' => $this->defineParam( false ), |
110 | 110 | '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 ), |
111 | 116 | ); |
112 | 117 | } |
113 | 118 | |
— | — | @@ -170,6 +175,11 @@ |
171 | 176 | 'payment_submethod' => 'Payment submethod to use', |
172 | 177 | 'language' => 'Language code', |
173 | 178 | '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', |
174 | 184 | ); |
175 | 185 | } |
176 | 186 | |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -87,21 +87,47 @@ |
88 | 88 | $this->setVal( 'posted', false ); |
89 | 89 | } |
90 | 90 | } |
| 91 | + |
| 92 | + //if we have saved any donation data to the session, pull them in as well. |
| 93 | + $this->integrateDataFromSession(); |
| 94 | + |
91 | 95 | $this->doCacheStuff(); |
92 | 96 | |
93 | 97 | $this->normalizeAndSanitize(); |
94 | 98 | |
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 | | - } |
105 | 99 | } |
| 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 | + } |
106 | 132 | |
107 | 133 | function getData() { |
108 | 134 | return $this->normalized; |
— | — | @@ -184,6 +210,11 @@ |
185 | 211 | } |
186 | 212 | } |
187 | 213 | |
| 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 | + */ |
188 | 219 | function isSomething( $key ) { |
189 | 220 | if ( array_key_exists( $key, $this->normalized ) ) { |
190 | 221 | if ( is_null($this->normalized[$key]) || $this->normalized[$key] === '' ) { |
— | — | @@ -220,12 +251,39 @@ |
221 | 252 | $this->setGateway(); |
222 | 253 | $this->setNormalizedOptOuts(); |
223 | 254 | $this->setLanguage(); |
| 255 | + $this->handleContributionTrackingID(); |
224 | 256 | array_walk( $this->normalized, array( $this, 'sanitizeInput' ) ); |
225 | 257 | } |
226 | 258 | } |
| 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 | + } |
227 | 285 | |
228 | 286 | /** |
229 | | - * normalizeAndSanitize helper function |
| 287 | + * normalizeAndSanitize helper function. |
230 | 288 | * Takes all possible sources for the intended donation amount, and |
231 | 289 | * normalizes them into the 'amount' field. |
232 | 290 | */ |
— | — | @@ -242,7 +300,7 @@ |
243 | 301 | } |
244 | 302 | |
245 | 303 | /** |
246 | | - * normalizeAndSanitize helper function |
| 304 | + * normalizeAndSanitize helper function. |
247 | 305 | * Ensures that order_id and i_order_id are ready to go, depending on what |
248 | 306 | * comes in populated or not, and where it came from. |
249 | 307 | * @return null |
— | — | @@ -276,9 +334,9 @@ |
277 | 335 | } |
278 | 336 | |
279 | 337 | /** |
280 | | - * Sanitize user input |
| 338 | + * Sanitize user input. |
281 | 339 | * |
282 | | - * Intended to be used with something like array_walk |
| 340 | + * Intended to be used with something like array_walk. |
283 | 341 | * |
284 | 342 | * @param $value The value of the array |
285 | 343 | * @param $key The key of the array |
— | — | @@ -326,7 +384,7 @@ |
327 | 385 | } |
328 | 386 | |
329 | 387 | /** |
330 | | - * normalizeAndSanitize helper function |
| 388 | + * normalizeAndSanitize helper function. |
331 | 389 | * If the language has not yet been set, pulls the language code |
332 | 390 | * from the current global language object. |
333 | 391 | */ |
— | — | @@ -364,7 +422,7 @@ |
365 | 423 | } |
366 | 424 | |
367 | 425 | /** |
368 | | - * Establish an 'edit' token to help prevent CSRF, etc |
| 426 | + * Establish an 'edit' token to help prevent CSRF, etc. |
369 | 427 | * |
370 | 428 | * We use this in place of $wgUser->editToken() b/c currently |
371 | 429 | * $wgUser->editToken() is broken (apparently by design) for |
— | — | @@ -427,7 +485,7 @@ |
428 | 486 | } |
429 | 487 | |
430 | 488 | /** |
431 | | - * Unset the payflow edit token from a user's session |
| 489 | + * Unset the payflow edit token from a user's session. |
432 | 490 | * |
433 | 491 | * TODO: Get rid of this, if we end up using the new, much more draconian |
434 | 492 | * killAllSessionEverything(). |
— | — | @@ -441,7 +499,7 @@ |
442 | 500 | } |
443 | 501 | |
444 | 502 | /** |
445 | | - * Ensure that we have a session set for the current user |
| 503 | + * Ensure that we have a session set for the current user. |
446 | 504 | * |
447 | 505 | * If we do not have a session set for the current user, |
448 | 506 | * start the session. |
— | — | @@ -606,8 +664,11 @@ |
607 | 665 | return $tracking_data; |
608 | 666 | } |
609 | 667 | |
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 | + */ |
612 | 673 | function saveContributionTracking() { |
613 | 674 | |
614 | 675 | $tracked_contribution = $this->getCleanTrackingData(); |
— | — | @@ -685,19 +746,7 @@ |
686 | 747 | |
687 | 748 | public function addDonorDataToSession() { |
688 | 749 | 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(); |
702 | 751 | |
703 | 752 | foreach ( $donordata as $item ) { |
704 | 753 | if ( $this->isSomething( $item ) ) { |
— | — | @@ -706,12 +755,6 @@ |
707 | 756 | } |
708 | 757 | } |
709 | 758 | |
710 | | - public function populateDonorFromSession() { |
711 | | - if ( array_key_exists( 'Donor', $_SESSION ) ) { |
712 | | - $this->addData( $_SESSION['Donor'] ); |
713 | | - } |
714 | | - } |
715 | | - |
716 | 759 | /** |
717 | 760 | * Unsets the session data, in the case that we've saved it for gateways |
718 | 761 | * like GlobalCollect that require it to persist over here through their |
— | — | @@ -764,6 +807,53 @@ |
765 | 808 | return false; |
766 | 809 | } |
767 | 810 | } |
| 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 | + } |
768 | 858 | |
769 | 859 | } |
770 | 860 | |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface |
___________________________________________________________________ |
Modified: svn:mergeinfo |
771 | 861 | Merged /trunk/extensions/DonationInterface:r101112,101163 |