Index: branches/fundraising/extensions/DonationInterface/donationinterface.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | $donationinterface_dir = dirname( __FILE__ ) . '/'; |
23 | 23 | |
24 | 24 | require_once( $donationinterface_dir . 'donate_interface/donate_interface.php' ); |
| 25 | +require_once( $donationinterface_dir . 'activemq_stomp/activemq_stomp.php' ); |
25 | 26 | |
26 | 27 | |
27 | 28 | /** |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -127,7 +127,8 @@ |
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function getCountries() { |
131 | | - return PayflowProGateway::getCountries(); |
| 131 | + require_once( dirname( __FILE__ ) . '/includes/countryCodes.inc' ); |
| 132 | + return countryCodes(); |
132 | 133 | } |
133 | 134 | |
134 | 135 | /** |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php |
— | — | @@ -42,13 +42,13 @@ |
43 | 43 | $wgPayFlowProGatewayCSSVersion; |
44 | 44 | |
45 | 45 | $referrer = $wgRequest->getHeader( 'referer' ); |
46 | | - |
| 46 | + |
47 | 47 | global $wgServer; |
48 | 48 | //TODO: Whitelist! We only want to do this for servers we are configured to like! |
49 | 49 | //I didn't do this already, because this may turn out to be backwards anyway. It might be good to do the work in the iframe, |
50 | 50 | //and then pop out. Maybe. We're probably going to have to test it a couple different ways, for user experience. |
51 | 51 | //However, we're _definitely_ going to need to pop out _before_ we redirect to the thank you or fail pages. |
52 | | - if ( strpos( $referrer, $wgServer ) === false ) { |
| 52 | + if ( strpos( $referrer, $wgServer ) === false ) { |
53 | 53 | $wgOut->allowClickjacking(); |
54 | 54 | $wgOut->addModules( 'iframe.liberator' ); |
55 | 55 | return; |
— | — | @@ -96,8 +96,8 @@ |
97 | 97 | $go = $this->adapter->getFailPage(); |
98 | 98 | break; |
99 | 99 | } |
100 | | - |
101 | | - //TODO: Save your user session data before you get here... |
| 100 | + $this->adapter->doStompTransaction( $result['data'], $result['message'], $result['data']['WMF_STATUS'], true ); |
| 101 | + |
102 | 102 | $this->adapter->unsetAllGatewaySessionData(); |
103 | 103 | $wgOut->addHTML( "<br>Redirecting to page $go" ); |
104 | 104 | $wgOut->redirect( $go ); |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php |
— | — | @@ -103,11 +103,10 @@ |
104 | 104 | if ( $this->adapter->checkTokens() ) { |
105 | 105 | if ( $this->adapter->posted && $data['payment_method'] == 'processed' ) { |
106 | 106 | // The form was submitted and the payment method has been set |
107 | | - $this->adapter->log("Form posted and payment method set."); |
| 107 | + $this->adapter->log( "Form posted and payment method set." ); |
108 | 108 | |
109 | 109 | // increase the count of attempts |
110 | 110 | //++$data['numAttempt']; |
111 | | - |
112 | 111 | // Check form for errors |
113 | 112 | $form_errors = $this->fnPayflowValidateForm( $data, $this->errors ); |
114 | 113 | |
— | — | @@ -119,14 +118,13 @@ |
120 | 119 | $result = $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
121 | 120 | $this->adapter->addDonorDataToSession(); |
122 | 121 | //$result = $this->adapter->do_transaction( 'TEST_CONNECTION' ); |
123 | | - |
124 | | - $this->displayResultsForDebug($result); |
125 | 122 | |
| 123 | + $this->displayResultsForDebug( $result ); |
| 124 | + |
126 | 125 | if ( !empty( $result['data'] ) ) { |
127 | | - |
128 | | - if (array_key_exists('FORMACTION', $result['data'])){ |
129 | | - $paymentFrame = Xml::openElement( 'iframe', |
130 | | - array( |
| 126 | + |
| 127 | + if ( array_key_exists( 'FORMACTION', $result['data'] ) ) { |
| 128 | + $paymentFrame = Xml::openElement( 'iframe', array( |
131 | 129 | 'id' => 'globalcollectframe', |
132 | 130 | 'name' => 'globalcollectframe', |
133 | 131 | 'width' => '680', |
— | — | @@ -134,12 +132,11 @@ |
135 | 133 | 'frameborder' => '0', |
136 | 134 | 'style' => 'display:block;', |
137 | 135 | 'src' => $result['data']['FORMACTION'] |
138 | | - ) |
| 136 | + ) |
139 | 137 | ); |
140 | 138 | $paymentFrame .= Xml::closeElement( 'iframe' ); |
141 | 139 | |
142 | 140 | $wgOut->addHTML( $paymentFrame ); |
143 | | - |
144 | 141 | } |
145 | 142 | } |
146 | 143 | |
— | — | @@ -183,11 +180,10 @@ |
184 | 181 | } else { |
185 | 182 | // Display form for the first time |
186 | 183 | $oid = $wgRequest->getText( 'order_id' ); |
187 | | - if ($oid && !empty($oid)){ |
188 | | - $wgOut->addHTML("<pre>CAME BACK FROM SOMETHING.</pre>"); |
| 184 | + if ( $oid && !empty( $oid ) ) { |
| 185 | + $wgOut->addHTML( "<pre>CAME BACK FROM SOMETHING.</pre>" ); |
189 | 186 | $result = $this->adapter->do_transaction( 'GET_ORDERSTATUS' ); |
190 | | - $this->displayResultsForDebug($result); |
191 | | - |
| 187 | + $this->displayResultsForDebug( $result ); |
192 | 188 | } |
193 | 189 | $this->adapter->log( "Not posted, or not processed. Showing the form for the first time." ); |
194 | 190 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
— | — | @@ -200,11 +196,11 @@ |
201 | 197 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
202 | 198 | } |
203 | 199 | } |
204 | | - |
205 | | - function displayResultsForDebug($results){ |
| 200 | + |
| 201 | + function displayResultsForDebug( $results ) { |
206 | 202 | global $wgOut; |
207 | 203 | $wgOut->addHTML( $results['message'] ); |
208 | | - |
| 204 | + |
209 | 205 | if ( !empty( $results['errors'] ) ) { |
210 | 206 | $wgOut->addHTML( "<ul>" ); |
211 | 207 | foreach ( $results['errors'] as $code => $value ) { |
— | — | @@ -212,13 +208,13 @@ |
213 | 209 | } |
214 | 210 | $wgOut->addHTML( "</ul>" ); |
215 | 211 | } |
216 | | - |
| 212 | + |
217 | 213 | if ( !empty( $results['data'] ) ) { |
218 | 214 | $wgOut->addHTML( "<ul>" ); |
219 | 215 | foreach ( $results['data'] as $key => $value ) { |
220 | | - if (is_array($value)){ |
| 216 | + if ( is_array( $value ) ) { |
221 | 217 | $wgOut->addHTML( "<li>$key:<ul>" ); |
222 | | - foreach ($value as $key2 => $val2){ |
| 218 | + foreach ( $value as $key2 => $val2 ) { |
223 | 219 | $wgOut->addHTML( "<li>$key2: $val2" ); |
224 | 220 | } |
225 | 221 | $wgOut->addHTML( "</ul>" ); |
— | — | @@ -228,16 +224,16 @@ |
229 | 225 | } |
230 | 226 | $wgOut->addHTML( "</ul>" ); |
231 | 227 | } else { |
232 | | - $wgOut->addHTML("Empty Results"); |
| 228 | + $wgOut->addHTML( "Empty Results" ); |
233 | 229 | } |
234 | | - if (array_key_exists('Donor', $_SESSION)){ |
235 | | - $wgOut->addHTML("Session Donor Vars:<ul>"); |
236 | | - foreach ($_SESSION['Donor'] as $key=>$val){ |
| 230 | + if ( array_key_exists( 'Donor', $_SESSION ) ) { |
| 231 | + $wgOut->addHTML( "Session Donor Vars:<ul>" ); |
| 232 | + foreach ( $_SESSION['Donor'] as $key => $val ) { |
237 | 233 | $wgOut->addHTML( "<li>$key: $val" ); |
238 | 234 | } |
239 | | - $wgOut->addHTML("</ul>"); |
| 235 | + $wgOut->addHTML( "</ul>" ); |
240 | 236 | } else { |
241 | | - $wgOut->addHTML("No Session Donor Vars:<ul>"); |
| 237 | + $wgOut->addHTML( "No Session Donor Vars:<ul>" ); |
242 | 238 | } |
243 | 239 | } |
244 | 240 | |
— | — | @@ -509,8 +505,6 @@ |
510 | 506 | * @return array |
511 | 507 | */ |
512 | 508 | public function prepareStompTransaction( $data, $responseArray, $responseMsg ) { |
513 | | - $countries = $this->getCountries(); |
514 | | - |
515 | 509 | $transaction = array( ); |
516 | 510 | |
517 | 511 | // include response message |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -6,48 +6,6 @@ |
7 | 7 | const COMMUNICATION_TYPE = 'xml'; |
8 | 8 | const GLOBAL_PREFIX = 'wgGlobalCollectGateway'; |
9 | 9 | |
10 | | - /** |
11 | | - * stageData should alter the postdata array in all ways necessary in preparation for |
12 | | - * communication with the gateway. |
13 | | - */ |
14 | | - function stageData() { |
15 | | - $this->postdata['amount'] = $this->postdata['amount'] * 100; |
16 | | - |
17 | | - $card_type = ''; |
18 | | - if ( array_key_exists( 'card_type', $this->postdata ) && !empty( $this->postdata['card_type'] ) ) { |
19 | | - $card_type = $this->postdata['card_type']; |
20 | | - } else { |
21 | | - $card_type = $this->postdatadefaults['card_type']; |
22 | | - } |
23 | | - |
24 | | - switch ( $card_type ) { |
25 | | - case 'visa': |
26 | | - $this->postdata['card_type'] = 1; |
27 | | - break; |
28 | | - case 'mastercard': |
29 | | - $this->postdata['card_type'] = 3; |
30 | | - break; |
31 | | - case 'american': |
32 | | - $this->postdata['card_type'] = 2; |
33 | | - break; |
34 | | - case 'discover': |
35 | | - $this->postdata['card_type'] = 128; |
36 | | - break; |
37 | | - } |
38 | | - |
39 | | - $this->postdata['expiry'] = $this->postdata['expiration']; //. ($this->postdata['year'] % 100); |
40 | | - $this->postdata['card_num'] = str_replace( ' ', '', $this->postdata['card_num'] ); |
41 | | - |
42 | | - $returnto = ''; |
43 | | - if ( array_key_exists( 'returnto', $this->postdata ) ) { |
44 | | - $returnto = $this->postdata['returnto']; |
45 | | - } else { |
46 | | - $returnto = $this->postdatadefaults['returnto']; |
47 | | - } |
48 | | - |
49 | | - $this->postdata['returnto'] = $returnto . "?order_id=" . $this->postdata['order_id']; |
50 | | - } |
51 | | - |
52 | 10 | function defineAccountInfo() { |
53 | 11 | $this->accountInfo = array( |
54 | 12 | 'MERCHANTID' => self::getGlobal( 'MerchantID' ), |
— | — | @@ -68,7 +26,7 @@ |
69 | 27 | 'IPADDRESS' => 'user_ip', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm. |
70 | 28 | 'PAYMENTPRODUCTID' => 'card_type', |
71 | 29 | 'CVV' => 'cvv', |
72 | | - 'EXPIRYDATE' => 'expiry', |
| 30 | + 'EXPIRYDATE' => 'expiration', |
73 | 31 | 'CREDITCARDNUMBER' => 'card_num', |
74 | 32 | 'FIRSTNAME' => 'fname', |
75 | 33 | 'SURNAME' => 'lname', |
— | — | @@ -273,4 +231,58 @@ |
274 | 232 | //TODO: Stuff. |
275 | 233 | } |
276 | 234 | |
277 | | -} |
| 235 | + function defineStagedVars() { |
| 236 | + //OUR field names. |
| 237 | + $this->staged_vars = array( |
| 238 | + 'amount', |
| 239 | + 'card_type', |
| 240 | + 'card_num', |
| 241 | + 'returnto', |
| 242 | + 'order_id', //This may or may not oughta-be-here... |
| 243 | + ); |
| 244 | + } |
| 245 | + |
| 246 | + protected function stage_amount( $type = 'request' ) { |
| 247 | + switch ( $type ) { |
| 248 | + case 'request': |
| 249 | + $this->postdata['amount'] = $this->postdata['amount'] * 100; |
| 250 | + break; |
| 251 | + case 'response': |
| 252 | + $this->postdata['amount'] = $this->postdata['amount'] / 100; |
| 253 | + break; |
| 254 | + } |
| 255 | + } |
| 256 | + |
| 257 | + protected function stage_card_type( $type = 'request' ) { |
| 258 | + |
| 259 | + $types = array( |
| 260 | + 'visa' => '1', |
| 261 | + 'mastercard' => '3', |
| 262 | + 'american' => '2', |
| 263 | + 'discover' => '128' |
| 264 | + ); |
| 265 | + |
| 266 | + if ( $type === 'response' ) { |
| 267 | + $types = array_flip( $types ); |
| 268 | + } |
| 269 | + |
| 270 | + if ( array_key_exists( $this->postdata['card_type'], $types ) ) { |
| 271 | + $this->postdata['card_type'] = $types[$this->postdata['card_type']]; |
| 272 | + } else { |
| 273 | + //$this->postdata['card_type'] = ''; |
| 274 | + //iono: maybe nothing? |
| 275 | + } |
| 276 | + } |
| 277 | + |
| 278 | + protected function stage_card_num( $type = 'request' ) { |
| 279 | + //I realize that the $type isn't used. Voodoo. |
| 280 | + $this->postdata['card_num'] = str_replace( ' ', '', $this->postdata['card_num'] ); |
| 281 | + } |
| 282 | + |
| 283 | + protected function stage_returnto( $type = 'request' ) { |
| 284 | + if ( $type === 'request' ) { |
| 285 | + $this->postdata['returnto'] = $this->postdata['returnto'] . "?order_id=" . $this->postdata['order_id']; |
| 286 | + } |
| 287 | + } |
| 288 | + |
| 289 | +} |
\ No newline at end of file |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -35,9 +35,10 @@ |
36 | 36 | function processResponse( $response ); |
37 | 37 | |
38 | 38 | /** |
39 | | - * Anything we need to do to the data coming in, before we send it off. |
| 39 | + * Should be a list of our variables that need special staging. |
| 40 | + * Define $this->staged_vars |
40 | 41 | */ |
41 | | - function stageData(); |
| 42 | + function defineStagedVars(); |
42 | 43 | |
43 | 44 | /** |
44 | 45 | * defineTransactions will define the $transactions array. |
— | — | @@ -645,4 +646,84 @@ |
646 | 647 | $this->dataObj->unsetAllDDSessionData(); |
647 | 648 | } |
648 | 649 | |
| 650 | + function doStompTransaction( $responseArray, $responseMsg, $status, $useSession = false ) { |
| 651 | + $hook = ''; |
| 652 | + switch ( $status ) { |
| 653 | + case 'complete': |
| 654 | + $hook = 'gwStomp'; |
| 655 | + break; |
| 656 | + case 'pending': |
| 657 | + case 'pending-poke': |
| 658 | + $hook = 'gwPendingStomp'; |
| 659 | + break; |
| 660 | + } |
| 661 | + if ( $hook === '' ) { |
| 662 | + return; |
| 663 | + } |
| 664 | + |
| 665 | + foreach ( $responseArray as $key => $val ) { |
| 666 | + if ( array_key_exists( $key, $this->var_map ) ) { |
| 667 | + $responseArray[$this->var_map[$key]] = $val; |
| 668 | + unset( $responseArray[$key] ); |
| 669 | + } |
| 670 | + } |
| 671 | + |
| 672 | + //Gah. I might want to move all this data prep business upstream more than somewhat. |
| 673 | + //...but that's for later. |
| 674 | + // Add the session vars to the data object |
| 675 | + if ( $useSession ) { |
| 676 | + $this->dataObj->populateDonorFromSession(); |
| 677 | + } |
| 678 | + |
| 679 | + // Add our response vars to the data object. |
| 680 | + $this->dataObj->addData( $responseArray ); |
| 681 | + |
| 682 | + // refresh our data |
| 683 | + $this->postdata = $this->dataObj->getData(); |
| 684 | + |
| 685 | + // stage the gateway data |
| 686 | + $this->stageData( 'response' ); |
| 687 | + |
| 688 | + // send the thing. |
| 689 | + $transaction = array( |
| 690 | + 'response' => $responseMsg, |
| 691 | + 'date' => time(), |
| 692 | + ); |
| 693 | + $transaction += $this->getData(); |
| 694 | + |
| 695 | + self::log( "Intended STOMP transaction: " . print_r( $transaction, true ) ); |
| 696 | + |
| 697 | + wfRunHooks( $hook, array( $transaction ) ); |
| 698 | + } |
| 699 | + |
| 700 | + function smooshVarsForStaging() { |
| 701 | + |
| 702 | + foreach ( $this->staged_vars as $field ) { |
| 703 | + if ( !array_key_exists( $field, $this->postdata ) || empty( $this->postdata[$field] ) ) { |
| 704 | + if ( array_key_exists( $field, $this->postdatadefaults ) ) { |
| 705 | + $this->postdata[$field] = $this->postdatadefaults[$field]; |
| 706 | + } |
| 707 | + } |
| 708 | + //what do we do in the event that we're still nothing? (just move on.) |
| 709 | + } |
| 710 | + } |
| 711 | + |
| 712 | + /** |
| 713 | + * |
| 714 | + * @param type $type Whatever types of staging you feel like having in your child class. |
| 715 | + * ...but usually request and response. I think. |
| 716 | + */ |
| 717 | + function stageData( $type = 'request' ) { |
| 718 | + $this->defineStagedVars(); |
| 719 | + $this->smooshVarsForStaging(); //yup, we do need to do this seperately. |
| 720 | + //If we tried to piggyback off the same loop, all the vars wouldn't be ready, and some staging functions will require |
| 721 | + //multiple variables. |
| 722 | + foreach ( $this->staged_vars as $field ) { |
| 723 | + $function_name = 'stage_' . $field; |
| 724 | + if ( method_exists( $this, $function_name ) ) { |
| 725 | + $this->{$function_name}( $type ); |
| 726 | + } |
| 727 | + } |
| 728 | + } |
| 729 | + |
649 | 730 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -29,13 +29,8 @@ |
30 | 30 | } |
31 | 31 | $this->doCacheStuff(); |
32 | 32 | |
| 33 | + $this->normalizeAndSanitize(); |
33 | 34 | |
34 | | - if ( !empty( $this->normalized ) ) { |
35 | | - $this->setNormalizedAmount(); |
36 | | - $this->setNormalizedOrderIDs(); |
37 | | - $this->setGateway(); |
38 | | - array_walk( $this->normalized, array( $this, 'sanitizeInput' ) ); |
39 | | - } |
40 | 35 | //TODO: determine if _nocache_ is still a thing anywhere. |
41 | 36 | if ( !empty( $this->normalized ) && ( $this->getVal( 'numAttempt' ) == '0' && ((!$this->getVal( 'utm_source_id' ) == false ) || $this->getVal( '_nocache_' ) == 'true' ) ) ) { |
42 | 37 | $this->saveContributionTracking(); |
— | — | @@ -209,6 +204,16 @@ |
210 | 205 | } |
211 | 206 | } |
212 | 207 | |
| 208 | + function normalizeAndSanitize() { |
| 209 | + if ( !empty( $this->normalized ) ) { |
| 210 | + $this->setNormalizedAmount(); |
| 211 | + $this->setNormalizedOrderIDs(); |
| 212 | + $this->setGateway(); |
| 213 | + $this->setNormalizedOptOuts(); |
| 214 | + array_walk( $this->normalized, array( $this, 'sanitizeInput' ) ); |
| 215 | + } |
| 216 | + } |
| 217 | + |
213 | 218 | function setNormalizedAmount() { |
214 | 219 | |
215 | 220 | if ( !($this->isSomething( 'amount' )) || !(preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal( 'amount' ) ) ) ) { |
— | — | @@ -244,7 +249,6 @@ |
245 | 250 | } |
246 | 251 | |
247 | 252 | $this->setVal( 'order_id', $this->generateOrderId() ); |
248 | | - |
249 | 253 | if ( !$this->isSomething( 'i_order_id' ) ) { |
250 | 254 | $this->setVal( 'i_order_id', $this->generateOrderId() ); |
251 | 255 | } |
— | — | @@ -526,10 +530,14 @@ |
527 | 531 | * are backwards (they are really opt-in) relative to contribution_tracking |
528 | 532 | * (which is opt-out), we need to reverse the values |
529 | 533 | */ |
530 | | - public function getOptOuts() { |
| 534 | + function setNormalizedOptOuts() { |
531 | 535 | $optout['optout'] = ( $this->isSomething( 'email-opt' ) && $this->getVal( 'email-opt' ) == "1" ) ? '0' : '1'; |
532 | 536 | $optout['anonymous'] = ( $this->isSomething( 'comment-option' ) && $this->getVal( 'comment-option' ) == "1" ) ? '0' : '1'; |
533 | | - return $optout; |
| 537 | + foreach ( $optout as $thing => $stuff ) { |
| 538 | + $this->setVal( $thing, $stuff ); |
| 539 | + } |
| 540 | + $this->expunge( 'email-opt' ); |
| 541 | + $this->expunge( 'comment-option' ); |
534 | 542 | } |
535 | 543 | |
536 | 544 | /** |
— | — | @@ -540,7 +548,7 @@ |
541 | 549 | * 'null' values. |
542 | 550 | * @param bool $clean_opouts |
543 | 551 | */ |
544 | | - public function getCleanTrackingData( $clean_optouts = false ) { |
| 552 | + public function getCleanTrackingData() { |
545 | 553 | |
546 | 554 | // define valid tracking fields |
547 | 555 | $tracking_fields = array( |
— | — | @@ -563,13 +571,6 @@ |
564 | 572 | } |
565 | 573 | } |
566 | 574 | |
567 | | - // clean up the optout values if necessary |
568 | | - if ( $clean_optouts ) { |
569 | | - $optouts = $this->getOptOuts(); |
570 | | - $tracking_data['optout'] = $optouts['optout']; |
571 | | - $tracking_data['anonymous'] = $optouts['anonymous']; |
572 | | - } |
573 | | - |
574 | 575 | return $tracking_data; |
575 | 576 | } |
576 | 577 | |
— | — | @@ -577,7 +578,7 @@ |
578 | 579 | //so, basically, if this is the first attempt. This seems to get called nowhere else. |
579 | 580 | function saveContributionTracking() { |
580 | 581 | |
581 | | - $tracked_contribution = $this->getCleanTrackingData( true ); |
| 582 | + $tracked_contribution = $this->getCleanTrackingData(); |
582 | 583 | |
583 | 584 | // insert tracking data and get the tracking id |
584 | 585 | $result = self::insertContributionTracking( $tracked_contribution ); |
— | — | @@ -641,7 +642,7 @@ |
642 | 643 | return true; |
643 | 644 | } ///wait, what? TODO: This line was straight copied from the _gateway.body. Find out if there's a good reason we're not returning false here. |
644 | 645 | |
645 | | - $tracked_contribution = $this->getCleanTrackingData( true ); |
| 646 | + $tracked_contribution = $this->getCleanTrackingData(); |
646 | 647 | |
647 | 648 | // if contrib tracking id is not already set, we need to insert the data, otherwise update |
648 | 649 | if ( !$this->getVal( 'contribution_tracking_id' ) ) { |
— | — | @@ -673,6 +674,12 @@ |
674 | 675 | } |
675 | 676 | } |
676 | 677 | |
| 678 | + public function populateDonorFromSession() { |
| 679 | + if ( array_key_exists( 'Donor', $_SESSION ) ) { |
| 680 | + $this->addData( $_SESSION['Donor'] ); |
| 681 | + } |
| 682 | + } |
| 683 | + |
677 | 684 | /** |
678 | 685 | * TODO: Consider putting all the session data for a gateway under something like |
679 | 686 | * $_SESSION[$gateway_identifier] |
— | — | @@ -683,6 +690,17 @@ |
684 | 691 | $this->unsetEditToken(); |
685 | 692 | } |
686 | 693 | |
| 694 | + public function addData( $newdata ) { |
| 695 | + if ( is_array( $newdata ) && !empty( $newdata ) ) { |
| 696 | + foreach ( $newdata as $key => $val ) { |
| 697 | + if ( !is_array( $val ) ) { |
| 698 | + $this->setVal( $key, $val ); |
| 699 | + } |
| 700 | + } |
| 701 | + } |
| 702 | + $this->normalizeAndSanitize(); |
| 703 | + } |
| 704 | + |
687 | 705 | } |
688 | 706 | |
689 | 707 | ?> |
Index: branches/fundraising/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -1,11 +1,12 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
4 | 5 | if ( !defined( 'MEDIAWIKI' ) ) { |
5 | | - echo <<<EOT |
| 6 | + echo <<<EOT |
6 | 7 | To install my extension, put the following line in LocalSettings.php: |
7 | 8 | require_once( "\$IP/extensions/DonationInterface/activemq_stomp/activemq_stomp.php" ); |
8 | 9 | EOT; |
9 | | - exit( 1 ); |
| 10 | + exit( 1 ); |
10 | 11 | } |
11 | 12 | |
12 | 13 | $wgExtensionCredits['other'][] = array( |
— | — | @@ -19,15 +20,15 @@ |
20 | 21 | $dir = dirname( __FILE__ ) . '/'; |
21 | 22 | |
22 | 23 | $wgAutoloadClasses['activemq_stomp'] = $dir . 'activemq_stomp.php'; # Tell MediaWiki to load the extension body. |
23 | | - |
24 | 24 | // default variables that should be set in LocalSettings |
25 | 25 | $wgStompServer = ""; |
26 | 26 | |
27 | 27 | $wgHooks['ParserFirstCallInit'][] = 'efStompSetup'; |
28 | 28 | |
29 | 29 | /* |
30 | | -* Create <donate /> tag to include landing page donation form |
31 | | -*/ |
| 30 | + * Create <donate /> tag to include landing page donation form |
| 31 | + */ |
| 32 | + |
32 | 33 | function efStompSetup( &$parser ) { |
33 | 34 | // redundant and causes Fatal Error |
34 | 35 | // $parser->disableCache(); |
— | — | @@ -48,19 +49,20 @@ |
49 | 50 | } |
50 | 51 | |
51 | 52 | /** |
52 | | -* Hook to get user provided and order data |
53 | | -* |
54 | | -*/ |
| 53 | + * Hook to get user provided and order data |
| 54 | + * |
| 55 | + */ |
55 | 56 | $wgHooks['gwStomp'][] = 'sendSTOMP'; |
56 | 57 | $wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP'; |
57 | 58 | |
58 | 59 | /* |
59 | | -* Hook to send transaction information to ActiveMQ server |
60 | | -*/ |
| 60 | + * Hook to send transaction information to ActiveMQ server |
| 61 | + */ |
| 62 | + |
61 | 63 | function sendSTOMP( $transaction ) { |
62 | 64 | global $wgStompServer, $wgStompQueueName; |
63 | 65 | |
64 | | - $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test'; |
| 66 | + $queueName = isset( $wgStompQueueName ) ? $wgStompQueueName : 'test'; |
65 | 67 | |
66 | 68 | // include a library |
67 | 69 | require_once( "Stomp.php" ); |
— | — | @@ -77,7 +79,7 @@ |
78 | 80 | $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true' ) ); |
79 | 81 | |
80 | 82 | if ( !$result ) { |
81 | | - wfDebugLog( 'activemq_stomp', 'Send to Q failed for this message: ' . $message ); |
| 83 | + wfDebugLog( 'activemq_stomp', 'Send to Q failed for this message: ' . $message ); |
82 | 84 | } |
83 | 85 | |
84 | 86 | $con->disconnect(); |
— | — | @@ -86,12 +88,13 @@ |
87 | 89 | } |
88 | 90 | |
89 | 91 | /* |
90 | | -* Hook to send transaction information to ActiveMQ server |
91 | | -*/ |
| 92 | + * Hook to send transaction information to ActiveMQ server |
| 93 | + */ |
| 94 | + |
92 | 95 | function sendPendingSTOMP( $transaction ) { |
93 | 96 | global $wgStompServer, $wgPendingStompQueueName; |
94 | 97 | |
95 | | - $queueName = isset ( $wgPendingStompQueueName ) ? $wgPendingStompQueueName : 'pending'; |
| 98 | + $queueName = isset( $wgPendingStompQueueName ) ? $wgPendingStompQueueName : 'pending'; |
96 | 99 | |
97 | 100 | // include a library |
98 | 101 | require_once( "Stomp.php" ); |
— | — | @@ -108,7 +111,7 @@ |
109 | 112 | $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true' ) ); |
110 | 113 | |
111 | 114 | if ( !$result ) { |
112 | | - wfDebugLog( 'activemq_stomp', 'Send to Pending Q failed for this message: ' . $message ); |
| 115 | + wfDebugLog( 'activemq_stomp', 'Send to Pending Q failed for this message: ' . $message ); |
113 | 116 | } |
114 | 117 | |
115 | 118 | $con->disconnect(); |
— | — | @@ -134,44 +137,44 @@ |
135 | 138 | // edit this array to include/ignore transaction data sent to the server |
136 | 139 | $message = array( |
137 | 140 | 'contribution_tracking_id' => $transaction['contribution_tracking_id'], |
138 | | - 'optout' => $transaction['optout'], |
139 | | - 'anonymous' => $transaction['anonymous'], |
140 | | - 'comment' => $transaction['comment'], |
141 | | - 'size' => $transaction['size'], |
142 | | - 'premium_language' => $transaction['premium_language'], |
143 | | - 'utm_source' => $transaction['utm_source'], |
144 | | - 'utm_medium' => $transaction['utm_medium'], |
145 | | - 'utm_campaign' => $transaction['utm_campaign'], |
146 | | - 'language' => $transaction['language'], |
147 | | - 'referrer' => $transaction['referrer'], |
148 | | - 'email' => $transaction['email'], |
149 | | - 'first_name' => $transaction['fname'], |
150 | | - 'middle_name' => $transaction['mname'], |
151 | | - 'last_name' => $transaction['lname'], |
152 | | - 'street_address' => $transaction['street'], |
| 141 | + 'optout' => $transaction['optout'], |
| 142 | + 'anonymous' => $transaction['anonymous'], |
| 143 | + 'comment' => $transaction['comment'], |
| 144 | + 'size' => $transaction['size'], |
| 145 | + 'premium_language' => $transaction['premium_language'], |
| 146 | + 'utm_source' => $transaction['utm_source'], |
| 147 | + 'utm_medium' => $transaction['utm_medium'], |
| 148 | + 'utm_campaign' => $transaction['utm_campaign'], |
| 149 | + 'language' => $transaction['language'], |
| 150 | + 'referrer' => $transaction['referrer'], |
| 151 | + 'email' => $transaction['email'], |
| 152 | + 'first_name' => $transaction['fname'], |
| 153 | + 'middle_name' => $transaction['mname'], |
| 154 | + 'last_name' => $transaction['lname'], |
| 155 | + 'street_address' => $transaction['street'], |
153 | 156 | 'supplemental_address_1' => '', |
154 | | - 'city' => $transaction['city'], |
155 | | - 'state_province' => $transaction['state'], |
156 | | - 'country' => $transaction['country'], |
157 | | - 'postal_code' => $transaction['zip'], |
158 | | - 'first_name_2' => $transaction['fname2'], |
159 | | - 'last_name_2' => $transaction['lname2'], |
160 | | - 'street_address_2' => $transaction['street2'], |
| 157 | + 'city' => $transaction['city'], |
| 158 | + 'state_province' => $transaction['state'], |
| 159 | + 'country' => $transaction['country'], |
| 160 | + 'postal_code' => $transaction['zip'], |
| 161 | + 'first_name_2' => $transaction['fname2'], |
| 162 | + 'last_name_2' => $transaction['lname2'], |
| 163 | + 'street_address_2' => $transaction['street2'], |
161 | 164 | 'supplemental_address_2' => '', |
162 | | - 'city_2' => $transaction['city2'], |
163 | | - 'state_province_2' => $transaction['state2'], |
164 | | - 'country_2' => $transaction['country2'], |
165 | | - 'postal_code_2' => $transaction['zip'], |
166 | | - 'gateway' => $transaction[ 'gateway' ], |
167 | | - 'gateway_txn_id' => $transaction['PNREF'], |
168 | | - 'response' => $transaction['RESPMSG'], |
169 | | - 'currency' => $transaction['currency'], |
170 | | - 'original_currency' => $transaction['currency'], |
171 | | - 'original_gross' => $transaction['amount'], |
172 | | - 'fee' => '0', |
173 | | - 'gross' => $transaction['amount'], |
174 | | - 'net' => $transaction['amount'], |
175 | | - 'date' => $transaction['date'], |
| 165 | + 'city_2' => $transaction['city2'], |
| 166 | + 'state_province_2' => $transaction['state2'], |
| 167 | + 'country_2' => $transaction['country2'], |
| 168 | + 'postal_code_2' => $transaction['zip2'], |
| 169 | + 'gateway' => $transaction['gateway'], |
| 170 | + 'gateway_txn_id' => $transaction['order_id'], //pretty sure. |
| 171 | + 'response' => $transaction['response'], |
| 172 | + 'currency' => $transaction['currency'], |
| 173 | + 'original_currency' => $transaction['currency'], |
| 174 | + 'original_gross' => $transaction['amount'], |
| 175 | + 'fee' => '0', |
| 176 | + 'gross' => $transaction['amount'], |
| 177 | + 'net' => $transaction['amount'], |
| 178 | + 'date' => $transaction['date'], |
176 | 179 | ); |
177 | 180 | |
178 | 181 | return $message; |
Index: branches/fundraising/extensions/DonationInterface/activemq_stomp/Stomp.php |
— | — | @@ -456,6 +456,8 @@ |
457 | 457 | { |
458 | 458 | if ( $this->clientId != null ) { |
459 | 459 | $headers["client-id"] = $this->clientId; |
| 460 | + } else { |
| 461 | + $headers = array(); |
460 | 462 | } |
461 | 463 | |
462 | 464 | if ( is_resource( $this->_socket ) ) { |