r96927 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96926‎ | r96927 | r96928 >
Date:22:33, 12 September 2011
Author:khorn
Status:deferred (Comments)
Tags:fundraising 
Comment:
Mods to make the DonationInterface tests accurate again.Fundraiser Card #285
Modifications to DonationInterface so RapidHTML works in a gateway-agnostic sort of way.
Also, some clean up: followup r95723, and mods to the tests.
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/donationinterface.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/RapidHtml.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/SingleColumn.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnPayPal.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter2.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/forms (added) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/forms/html (added) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/forms/html/demo.html (added) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/tests/DonationDataTest.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/tests/GatewayAdapterTest.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/donationinterface.php
@@ -18,27 +18,21 @@
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:DonationInterface',
2020 );
2121
22 -//This is going to be a little funky.
23 -//Override this in LocalSettings.php BEFORE you include this file, if you want
24 -//to disable gateways.
25 -//TODO: Unfunktify, if you have a better idea here for auto-loading the classes after LocalSettings.php runs all the way.
26 -if ( !isset( $wgDonationInterfaceEnabledGateways ) ) {
27 - $wgDonationInterfaceEnabledGateways = array(
28 - 'paypal',
29 - 'payflowpro',
30 - 'globalcollect'
31 - );
32 -}
33 -
3422 $donationinterface_dir = dirname( __FILE__ ) . '/';
3523
3624 require_once( $donationinterface_dir . 'donate_interface/donate_interface.php' );
3725
38 -foreach ( $wgDonationInterfaceEnabledGateways as $gateway ) {
39 - //include 'em
40 - require_once( $donationinterface_dir . $gateway . '_gateway/' . $gateway . '_gateway.php' );
41 -}
4226
 27+/**
 28+ * Global form dir and whitelist
 29+ */
 30+$wgDonationInterfaceHtmlFormDir = dirname( __FILE__ ) . "/gateway_forms/html";
 31+//ffname is the $key from now on.
 32+$wgDonationInterfaceAllowedHtmlForms = array(
 33+ 'demo' => $wgDonationInterfaceHtmlFormDir . "/demo.html",
 34+ 'globalcollect_test' => $wgDonationInterfaceHtmlFormDir . "/globalcollect_test.html",
 35+);
 36+
4337 //load all possible form classes
4438 $wgAutoloadClasses['Gateway_Form'] = $donationinterface_dir . 'gateway_forms/Form.php';
4539 $wgAutoloadClasses['Gateway_Form_OneStepTwoColumn'] = $donationinterface_dir . 'gateway_forms/OneStepTwoColumn.php';
@@ -60,9 +54,30 @@
6155 $wgAutoloadClasses['Gateway_Form_RapidHtml'] = $donationinterface_dir . 'gateway_forms/RapidHtml.php';
6256 $wgAutoloadClasses['Gateway_Form_SingleColumn'] = $donationinterface_dir . 'gateway_forms/SingleColumn.php';
6357
 58+
 59+$wgAutoloadClasses['DonationData'] = $donationinterface_dir . 'gateway_common/DonationData.php';
 60+$wgAutoloadClasses['GatewayAdapter'] = $donationinterface_dir . 'gateway_common/gateway.adapter.php';
 61+
6462 //THE GATEWAYS WILL RESET THIS when they are instantiated. You can override it, but it won't stick around that way.
6563 $wgDonationInterfaceTest = false;
6664
 65+//This is going to be a little funky.
 66+//Override this in LocalSettings.php BEFORE you include this file, if you want
 67+//to disable gateways.
 68+//TODO: Unfunktify, if you have a better idea here for auto-loading the classes after LocalSettings.php runs all the way.
 69+if ( !isset( $wgDonationInterfaceEnabledGateways ) ) {
 70+ $wgDonationInterfaceEnabledGateways = array(
 71+ 'paypal',
 72+ 'payflowpro',
 73+ 'globalcollect'
 74+ );
 75+}
 76+
 77+foreach ( $wgDonationInterfaceEnabledGateways as $gateway ) {
 78+ //include 'em
 79+ require_once( $donationinterface_dir . $gateway . '_gateway/' . $gateway . '_gateway.php' );
 80+}
 81+
6782 /**
6883 * Hooks required to interface with the donation extension (include <donate> on page)
6984 *
@@ -71,7 +86,6 @@
7287 */
7388 //$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue';
7489 //$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage';
75 -
7690 # Unit tests
7791 $wgHooks['UnitTestsList'][] = 'efDonationInterfaceUnitTests';
7892
Index: branches/fundraising/extensions/DonationInterface/tests/GatewayAdapterTest.php
@@ -81,10 +81,10 @@
8282
8383 class TestAdapter extends GatewayAdapter {
8484
85 - const gatewayname = 'Test Gateway';
86 - const identifier = 'testgateway';
87 - const communicationtype = 'xml';
88 - const globalprefix = 'wgTestAdapterGateway';
 85+ const GATEWAY_NAME = 'Test Gateway';
 86+ const IDENTIFIER = 'testgateway';
 87+ const COMMUNICATION_TYPE = 'xml';
 88+ const GLOBAL_PREFIX = 'wgTestAdapterGateway';
8989
9090 function stageData(){
9191 $this->postdata['amount'] = $this->postdata['amount'] * 1000;
@@ -96,7 +96,6 @@
9797 $wgTestAdapterGatewayTest = true;
9898 $wgTestAdapterGatewayTestVar = "Hi there!";
9999 $wgTestAdapterGatewayUseSyslog = true;
100 - $this->classlocation = __FILE__;
101100 parent::__construct();
102101
103102 }
Index: branches/fundraising/extensions/DonationInterface/tests/DonationDataTest.php
@@ -33,7 +33,7 @@
3434 'size' => 'Big mcLargeHuge',
3535 'premium_language' => 'fr',
3636 'card_num' => '42',
37 - 'card' => 'visa',
 37+ 'card_type' => 'visa',
3838 'expiration' => '1138',
3939 'cvv' => '665',
4040 'currency' => 'USD',
@@ -84,7 +84,7 @@
8585 'size' => '',
8686 'premium_language' => 'en',
8787 'card_num' => '',
88 - 'card' => '',
 88+ 'card_type' => '',
8989 'expiration' => '',
9090 'cvv' => '',
9191 'currency' => '',
@@ -137,7 +137,7 @@
138138 'size' => 'small',
139139 'premium_language' => 'es',
140140 'card_num' => '378282246310005',
141 - 'card' => 'american',
 141+ 'card_type' => 'american',
142142 'expiration' => '1012',
143143 'cvv' => '001',
144144 'currency' => 'USD',
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -20,7 +20,7 @@
2121 * Holds the PayflowPro response from a transaction
2222 * @var array
2323 */
24 - public $payflow_response = array();
 24+ public $payflow_response = array( );
2525
2626 /**
2727 * A container for the form class
@@ -34,7 +34,7 @@
3535 * An array of form errors
3636 * @var array
3737 */
38 - public $errors = array();
 38+ public $errors = array( );
3939
4040 /**
4141 * Constructor - set up the new special page
@@ -42,6 +42,8 @@
4343 public function __construct() {
4444 parent::__construct( 'PayflowProGateway' );
4545 $this->errors = $this->getPossibleErrors();
 46+
 47+ $this->adapter = new PayflowProAdapter();
4648 }
4749
4850 /**
@@ -51,8 +53,8 @@
5254 */
5355 public function execute( $par ) {
5456 global $wgRequest, $wgOut, $wgScriptPath,
55 - $wgPayFlowProGatewayCSSVersion,
56 - $wgPayflowProGatewaySalt;
 57+ $wgPayFlowProGatewayCSSVersion,
 58+ $wgPayflowProGatewaySalt;
5759
5860 $wgOut->addExtensionStyle(
5961 "{$wgScriptPath}/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css?284" .
@@ -80,14 +82,14 @@
8183 $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
8284
8385 // @fixme can this be moved into the form generators?
84 - $js = <<<EOT
 86+ $js = <<<EOT
8587 <script type="text/javascript">
8688 jQuery(document).ready(function() {
8789 jQuery("div#p-logo a").attr("href","#");
8890 });
8991 </script>
9092 EOT;
91 - $wgOut->addHeadItem( 'logolinkoverride', $js );
 93+ $wgOut->addHeadItem( 'logolinkoverride', $js );
9294
9395 // find out if amount was a radio button or textbox, set amount
9496 if ( isset( $_REQUEST['amount'] ) && preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount' ) ) ) {
@@ -101,7 +103,7 @@
102104 } else {
103105 $amount = '0.00';
104106 }
105 -
 107+
106108 // Get array of default account values necessary for Payflow
107109 require_once( 'includes/payflowUser.inc' );
108110
@@ -111,15 +113,15 @@
112114 $numAttempt = $wgRequest->getVal( 'numAttempt', 0 );
113115
114116 // make a log entry if the user has submitted the cc form
115 - if ( $wgRequest->wasPosted() && $wgRequest->getText( 'process', 0 )) {
116 - self::log( $payflow_data[ 'order_id' ] . " Transaction initiated." );
 117+ if ( $wgRequest->wasPosted() && $wgRequest->getText( 'process', 0 ) ) {
 118+ self::log( $payflow_data['order_id'] . " Transaction initiated." );
117119 } else {
118 - self::log( $payflow_data[ 'order_id' ] . " " . $payflow_data[ 'i_order_id' ] . " Initial credit card form request.", 'payflowpro_gateway', LOG_DEBUG );
 120+ self::log( $payflow_data['order_id'] . " " . $payflow_data['i_order_id'] . " Initial credit card form request.", 'payflowpro_gateway', LOG_DEBUG );
119121 }
120122
121123 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
122124 if ( $wgRequest->getText( '_cache_', false ) ) {
123 - self::log( $payflow_data[ 'order_id' ] . " " . $payflow_data[ 'i_order_id' ] . " Cache requested", 'payflowpro_gateway', LOG_DEBUG );
 125+ self::log( $payflow_data['order_id'] . " " . $payflow_data['i_order_id'] . " Cache requested", 'payflowpro_gateway', LOG_DEBUG );
124126 $cache = true;
125127 $token = '';
126128 $token_match = false;
@@ -127,23 +129,23 @@
128130 // if we have squid caching enabled, set the maxage
129131 global $wgUseSquid, $wgPayflowProSMaxAge;
130132 if ( $wgUseSquid ) {
131 - self::log( $payflow_data[ 'order_id' ] . " " . $payflow_data[ 'i_order_id' ] . " Setting s-max-age: " . $wgPayflowProSMaxAge, 'payflowpro_gateway', LOG_DEBUG );
132 - $wgOut->setSquidMaxage( $wgPayflowProSMaxAge );
 133+ self::log( $payflow_data['order_id'] . " " . $payflow_data['i_order_id'] . " Setting s-max-age: " . $wgPayflowProSMaxAge, 'payflowpro_gateway', LOG_DEBUG );
 134+ $wgOut->setSquidMaxage( $wgPayflowProSMaxAge );
133135 }
134136 } else {
135137 $cache = false;
136138
137139 // establish the edit token to prevent csrf
138140 $token = self::fnPayflowEditToken( $wgPayflowProGatewaySalt );
139 -
140 - self::log( $payflow_data[ 'order_id' ] . " " . $payflow_data[ 'i_order_id' ] . " fnPayflowEditToken: " . $token, 'payflowpro_gateway', LOG_DEBUG );
141 -
 141+
 142+ self::log( $payflow_data['order_id'] . " " . $payflow_data['i_order_id'] . " fnPayflowEditToken: " . $token, 'payflowpro_gateway', LOG_DEBUG );
 143+
142144 // match token
143145 $token_check = ( $wgRequest->getText( 'token' ) ) ? $wgRequest->getText( 'token' ) : $token;
144146 $token_match = $this->fnPayflowMatchEditToken( $token_check, $wgPayflowProGatewaySalt );
145147 if ( $wgRequest->wasPosted() ) {
146 - self::log( $payflow_data[ 'order_id' ] . " " . $payflow_data[ 'i_order_id' ] . " Submitted edit token: " . $wgRequest->getText( 'token', 'None' ), 'payflowpro_gateway', LOG_DEBUG);
147 - self::log( $payflow_data[ 'order_id' ] . " " . $payflow_data[ 'i_order_id' ] . " Token match: " . ($token_match ? 'true' : 'false' ), 'payflowpro_gateway', LOG_DEBUG );
 148+ self::log( $payflow_data['order_id'] . " " . $payflow_data['i_order_id'] . " Submitted edit token: " . $wgRequest->getText( 'token', 'None' ), 'payflowpro_gateway', LOG_DEBUG );
 149+ self::log( $payflow_data['order_id'] . " " . $payflow_data['i_order_id'] . " Token match: " . ($token_match ? 'true' : 'false' ), 'payflowpro_gateway', LOG_DEBUG );
148150 }
149151 }
150152
@@ -166,7 +168,7 @@
167169 // dispatch forms/handling
168170 if ( $token_match ) {
169171 if ( $data['payment_method'] == 'processed' ) {
170 -
 172+
171173 // increase the count of attempts
172174 ++$data['numAttempt'];
173175
@@ -177,14 +179,14 @@
178180 $this->fnPayflowDisplayForm( $data, $this->errors );
179181 } else { // The submitted form data is valid, so process it
180182 // allow any external validators to have their way with the data
181 - self::log( $data[ 'order_id' ] . " Preparing to query MaxMind" );
 183+ self::log( $data['order_id'] . " Preparing to query MaxMind" );
182184 wfRunHooks( 'PayflowGatewayValidate', array( &$this, &$data ) );
183 - self::log( $data[ 'order_id' ] . ' Finished querying Maxmind' );
 185+ self::log( $data['order_id'] . ' Finished querying Maxmind' );
184186
185187 // if the transaction was flagged for review
186188 if ( $this->action == 'review' ) {
187189 // expose a hook for external handling of trxns flagged for review
188 - wfRunHooks( 'PayflowGatewayReview', array( &$this, &$data ));
 190+ wfRunHooks( 'PayflowGatewayReview', array( &$this, &$data ) );
189191 }
190192
191193 // if the transaction was flagged to be 'challenged'
@@ -237,16 +239,16 @@
238240 global $wgOut, $wgRequest;
239241
240242 // save contrib tracking id early to track abondonment
241 - if ( $data[ 'numAttempt' ] == '0' && ( !$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) {
 243+ if ( $data['numAttempt'] == '0' && (!$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) {
242244 $tracked = $this->fnPayflowSaveContributionTracking( $data );
243245 if ( !$tracked ) {
244246 $when = time();
245 - self::log( $data[ 'order_id' ] . ' Unable to save data to the contribution_tracking table ' . $when );
 247+ self::log( $data['order_id'] . ' Unable to save data to the contribution_tracking table ' . $when );
246248 }
247249 }
248250
249251 $form_class = $this->getFormClass();
250 - $form_obj = new $form_class( $data, $error );
 252+ $form_obj = new $form_class( $data, $error, $this->adapter );
251253 $form = $form_obj->getForm();
252254 $wgOut->addHTML( $form );
253255 }
@@ -281,7 +283,7 @@
282284 * Using logic in setFormClass()
283285 * @return string
284286 */
285 - public function getFormClass( ) {
 287+ public function getFormClass() {
286288 if ( !isset( $this->form_class ) ) {
287289 $this->setFormClass();
288290 }
@@ -293,7 +295,7 @@
294296 */
295297 private function fnPayflowValidateForm( &$data, &$error ) {
296298 global $wgPayflowProGatewayPriceFloor, $wgPayflowProGatewayPriceCeiling;
297 -
 299+
298300 // begin with no errors
299301 $error_result = '0';
300302
@@ -315,7 +317,7 @@
316318
317319 // find all empty fields and create message
318320 foreach ( $data as $key => $value ) {
319 - if ( $value == '' || ($key == 'state' && $value == 'YY' )) {
 321+ if ( $value == '' || ($key == 'state' && $value == 'YY' ) ) {
320322 // ignore fields that are not required
321323 if ( isset( $msg[$key] ) ) {
322324 $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />";
@@ -325,9 +327,9 @@
326328 }
327329
328330 // check amount
329 - if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data[ 'amount' ] ) ||
330 - ( (float) $this->convert_to_usd( $data[ 'currency' ], $data[ 'amount' ] ) < (float) $wgPayflowProGatewayPriceFloor ||
331 - (float) $this->convert_to_usd( $data[ 'currency' ], $data[ 'amount' ] ) > (float) $wgPayflowProGatewayPriceCeiling ) ) {
 331+ if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data['amount'] ) ||
 332+ ( ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) < ( float ) $wgPayflowProGatewayPriceFloor ||
 333+ ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) > ( float ) $wgPayflowProGatewayPriceCeiling ) ) {
332334 $error['invalidamount'] = wfMsg( 'payflowpro_gateway-error-msg-invalid-amount' );
333335 $error_result = '1';
334336 }
@@ -342,19 +344,19 @@
343345 }
344346
345347 // validate that credit card number entered is correct and set the card type
346 - if ( preg_match( '/^3[47][0-9]{13}$/', $data[ 'card_num' ] ) ) { // american express
347 - $data[ 'card' ] = 'american';
348 - } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data[ 'card_num' ] ) ) { // mastercard
349 - $data[ 'card' ] = 'mastercard';
350 - } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data[ 'card_num' ] ) ) {// visa
351 - $data[ 'card' ] = 'visa';
352 - } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data[ 'card_num' ] ) ) { // discover
353 - $data[ 'card' ] = 'discover';
 348+ if ( preg_match( '/^3[47][0-9]{13}$/', $data['card_num'] ) ) { // american express
 349+ $data['card'] = 'american';
 350+ } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data['card_num'] ) ) { // mastercard
 351+ $data['card'] = 'mastercard';
 352+ } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data['card_num'] ) ) {// visa
 353+ $data['card'] = 'visa';
 354+ } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data['card_num'] ) ) { // discover
 355+ $data['card'] = 'discover';
354356 } else { // an invalid credit card number was entered
355357 $error_result = '1';
356 - $error[ 'card_num' ] = wfMsg( 'payflowpro_gateway-error-msg-card-num' );
 358+ $error['card_num'] = wfMsg( 'payflowpro_gateway-error-msg-card-num' );
357359 }
358 -
 360+
359361 return $error_result;
360362 }
361363
@@ -374,12 +376,12 @@
375377 // create payflow query string, include string lengths
376378 $queryArray = array(
377379 'TRXTYPE' => $payflow_data['trxtype'],
378 - 'TENDER' => $payflow_data['tender'],
379 - 'USER' => $payflow_data['user'],
 380+ 'TENDER' => $payflow_data['tender'],
 381+ 'USER' => $payflow_data['user'],
380382 'VENDOR' => $payflow_data['vendor'],
381383 'PARTNER' => $payflow_data['partner'],
382384 'PWD' => $payflow_data['password'],
383 - 'ACCT' => $data['card_num'],
 385+ 'ACCT' => $data['card_num'],
384386 'EXPDATE' => $data['expiration'],
385387 'AMT' => $data['amount'],
386388 'FIRSTNAME' => $data['fname'],
@@ -411,8 +413,8 @@
412414 $headers[] = 'X-VPS-Client-Timeout: 45';
413415 $headers[] = 'X-VPS-Request-ID:' . $data['order_id'];
414416 $ch = curl_init();
415 - $paypalPostTo = isset ( $wgDonationTestingMode ) ? 'testingurl' : 'paypalurl';
416 - curl_setopt( $ch, CURLOPT_URL, $payflow_data[ $paypalPostTo ] );
 417+ $paypalPostTo = isset( $wgDonationTestingMode ) ? 'testingurl' : 'paypalurl';
 418+ curl_setopt( $ch, CURLOPT_URL, $payflow_data[$paypalPostTo] );
417419 curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
418420 curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent );
419421 curl_setopt( $ch, CURLOPT_HEADER, 1 );
@@ -421,7 +423,7 @@
422424 curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 );
423425 curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
424426 curl_setopt( $ch, CURLOPT_POSTFIELDS, $payflow_query );
425 - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
 427+ curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
426428 curl_setopt( $ch, CURLOPT_FORBID_REUSE, true );
427429 curl_setopt( $ch, CURLOPT_POST, 1 );
428430
@@ -436,15 +438,15 @@
437439 $i = 1;
438440
439441 while ( $i++ <= 3 ) {
440 - self::log( $data[ 'order_id' ] . ' Preparing to send transaction to PayflowPro' );
 442+ self::log( $data['order_id'] . ' Preparing to send transaction to PayflowPro' );
441443 $result = curl_exec( $ch );
442444 $headers = curl_getinfo( $ch );
443445
444446 if ( $headers['http_code'] != 200 && $headers['http_code'] != 403 ) {
445 - self::log( $data[ 'order_id' ] . ' Failed sending transaction to PayflowPro, retrying' );
 447+ self::log( $data['order_id'] . ' Failed sending transaction to PayflowPro, retrying' );
446448 sleep( 1 );
447449 } elseif ( $headers['http_code'] == 200 || $headers['http_code'] == 403 ) {
448 - self::log( $data[ 'order_id' ] . ' Finished sending transaction to PayflowPro' );
 450+ self::log( $data['order_id'] . ' Finished sending transaction to PayflowPro' );
449451 break;
450452 }
451453 }
@@ -452,7 +454,7 @@
453455 if ( $headers['http_code'] != 200 ) {
454456 $wgOut->addHTML( '<h3>No response from credit card processor. Please try again later!</h3><p>' );
455457 $when = time();
456 - self::log( $data[ 'order_id' ] . ' No response from credit card processor: ' . curl_error( $ch ) );
 458+ self::log( $data['order_id'] . ' No response from credit card processor: ' . curl_error( $ch ) );
457459 curl_close( $ch );
458460 return;
459461 }
@@ -476,18 +478,18 @@
477479 */
478480 private function fnPayflowGetResults( $data, $result ) {
479481 // prepare NVP response for sorting and outputting
480 - $responseArray = array();
 482+ $responseArray = array( );
481483
482484 /**
483485 * The result response string looks like:
484 - * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1
 486+ * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1
485487 * We want to turn this into an array of key value pairs, so explode on '&' and then
486488 * split up the resulting strings into $key => $value
487489 */
488490 $result_arr = explode( "&", $result );
489491 foreach ( $result_arr as $result_pair ) {
490492 list( $key, $value ) = preg_split( "/=/", $result_pair );
491 - $responseArray[ $key ] = $value;
 493+ $responseArray[$key] = $value;
492494 }
493495
494496 // store the response array as an object property for easy retrival/manipulation elsewhere
@@ -503,33 +505,34 @@
504506 // interpret result code, return
505507 // approved (1), denied (2), try again (3), general error (4)
506508 $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg );
507 -
 509+
508510 // log that the transaction is essentially complete
509 - self::log( $data[ 'order_id' ] . " Transaction complete." );
510 -
 511+ self::log( $data['order_id'] . " Transaction complete." );
 512+
511513 // if approved, display results and send transaction to the queue
512514 if ( $errorCode == '1' ) {
513 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction approved.", 'payflowpro_gateway', LOG_DEBUG );
 515+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction approved.", 'payflowpro_gateway', LOG_DEBUG );
514516 $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg );
515517 // give user a second chance to enter incorrect data
516518 } elseif ( ( $errorCode == '3' ) && ( $data['numAttempt'] < '5' ) ) {
517 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction unsuccessful (invalid info).", 'payflowpro_gateway', LOG_DEBUG );
 519+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction unsuccessful (invalid info).", 'payflowpro_gateway', LOG_DEBUG );
518520 // pass responseMsg as an array key as required by displayForm
519521 $this->errors['retryMsg'] = $responseMsg;
520522 $this->fnPayflowDisplayForm( $data, $this->errors );
521523 // if declined or if user has already made two attempts, decline
522524 } elseif ( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '3' ) ) {
523 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction declined.", 'payflowpro_gateway', LOG_DEBUG );
 525+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction declined.", 'payflowpro_gateway', LOG_DEBUG );
524526 $this->fnPayflowDisplayDeclinedResults( $responseMsg );
525527 } elseif ( ( $errorCode == '4' ) ) {
526 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction unsuccessful.", 'payflowpro_gateway', LOG_DEBUG );
 528+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction unsuccessful.", 'payflowpro_gateway', LOG_DEBUG );
527529 $this->fnPayflowDisplayOtherResults( $responseMsg );
528530 } elseif ( ( $errorCode == '5' ) ) {
529 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction pending.", 'payflowpro_gateway', LOG_DEBUG );
 531+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction pending.", 'payflowpro_gateway', LOG_DEBUG );
530532 $this->fnPayflowDisplayPending( $data, $responseArray, $responseMsg );
531533 }
 534+ }
532535
533 - }// end display results
 536+// end display results
534537
535538 /**
536539 * Interpret response code, return
@@ -541,7 +544,7 @@
542545 function fnPayflowGetResponseMsg( $resultCode, &$responseMsg ) {
543546 $responseMsg = wfMsg( 'payflowpro_gateway-response-default' );
544547
545 - switch( $resultCode ) {
 548+ switch ( $resultCode ) {
546549 case '0':
547550 $responseMsg = wfMsg( 'payflowpro_gateway-response-0' );
548551 $errorCode = '1';
@@ -600,25 +603,25 @@
601604 */
602605 public function prepareStompTransaction( $data, $responseArray, $responseMsg ) {
603606 $countries = $this->getCountries();
604 -
605 - $transaction = array();
606607
 608+ $transaction = array( );
 609+
607610 // include response message
608611 $transaction['response'] = $responseMsg;
609 -
 612+
610613 // include date
611614 $transaction['date'] = time();
612 -
 615+
613616 // put all data into one array
614617 $optout = $this->determineOptOut( $data );
615 - $data[ 'anonymous' ] = $optout[ 'anonymous' ];
616 - $data[ 'optout' ] = $optout[ 'optout' ];
617 -
 618+ $data['anonymous'] = $optout['anonymous'];
 619+ $data['optout'] = $optout['optout'];
 620+
618621 $transaction += array_merge( $data, $responseArray );
619 -
 622+
620623 return $transaction;
621624 }
622 -
 625+
623626 /**
624627 * Fetch an array of country abbrevs => country names
625628 */
@@ -626,7 +629,7 @@
627630 require_once( 'includes/countryCodes.inc' );
628631 return countryCodes();
629632 }
630 -
 633+
631634 /**
632635 * Display response message to user with submitted user-supplied data
633636 *
@@ -732,8 +735,8 @@
733736 * (which is opt-out), we need to reverse the values
734737 */
735738 public static function determineOptOut( $data ) {
736 - $optout[ 'optout' ] = ( isset( $data[ 'email-opt' ] ) && $data[ 'email-opt' ] == "1" ) ? '0' : '1';
737 - $optout[ 'anonymous' ] = ( isset( $data[ 'comment-option' ] ) && $data[ 'comment-option' ] == "1" ) ? '0' : '1';
 739+ $optout['optout'] = ( isset( $data['email-opt'] ) && $data['email-opt'] == "1" ) ? '0' : '1';
 740+ $optout['anonymous'] = ( isset( $data['comment-option'] ) && $data['comment-option'] == "1" ) ? '0' : '1';
738741 return $optout;
739742 }
740743
@@ -744,11 +747,11 @@
745748 $tracked_contribution = array(
746749 'note' => $data['comment'],
747750 'referrer' => $data['referrer'],
748 - 'anonymous' => $optout[ 'anonymous' ],
 751+ 'anonymous' => $optout['anonymous'],
749752 'utm_source' => $data['utm_source'],
750753 'utm_medium' => $data['utm_medium'],
751754 'utm_campaign' => $data['utm_campaign'],
752 - 'optout' => $optout[ 'optout' ],
 755+ 'optout' => $optout['optout'],
753756 'language' => $data['language'],
754757 'ts' => '',
755758 );
@@ -756,7 +759,7 @@
757760 // insert tracking data and get the tracking id
758761 $data['contribution_tracking_id'] = self::insertContributionTracking( $tracked_contribution );
759762
760 - if ( !$data[ 'contribution_tracking_id' ] ) {
 763+ if ( !$data['contribution_tracking_id'] ) {
761764 return false;
762765 }
763766 return true;
@@ -772,16 +775,18 @@
773776 public static function insertContributionTracking( $tracking_data ) {
774777 $db = ContributionTrackingProcessor::contributionTrackingConnection();
775778
776 - if ( !$db ) { return false; }
 779+ if ( !$db ) {
 780+ return false;
 781+ }
777782
778783 // set the time stamp if it's not already set
779 - if ( !isset( $tracking_data[ 'ts' ] ) || !strlen( $tracking_data[ 'ts' ] ) ) {
780 - $tracking_data[ 'ts' ] = $db->timestamp();
 784+ if ( !isset( $tracking_data['ts'] ) || !strlen( $tracking_data['ts'] ) ) {
 785+ $tracking_data['ts'] = $db->timestamp();
781786 }
782787
783788 // Store the contribution data
784789 if ( $db->insert( 'contribution_tracking', $tracking_data ) ) {
785 - return $db->insertId();
 790+ return $db->insertId();
786791 } else {
787792 return false;
788793 }
@@ -801,8 +806,8 @@
802807 // clean up the optout values if necessary
803808 if ( $clean_optouts ) {
804809 $optouts = self::determineOptOut( $tracking_data );
805 - $tracking_data[ 'optout' ] = $optouts[ 'optout' ];
806 - $tracking_data[ 'anonymous' ] = $optouts[ 'anonymous' ];
 810+ $tracking_data['optout'] = $optouts['optout'];
 811+ $tracking_data['anonymous'] = $optouts['anonymous'];
807812 }
808813
809814 // define valid tracking fields
@@ -822,7 +827,7 @@
823828 foreach ( $tracking_data as $key => $value ) {
824829 // Make sure we only have valid fields
825830 if ( !in_array( $key, $tracking_fields ) ) {
826 - unset( $tracking_data[ $key ] );
 831+ unset( $tracking_data[$key] );
827832 }
828833
829834 // Make all empty strings NULL
@@ -852,12 +857,12 @@
853858 // make sure we have a session open for tracking a CSRF-prevention token
854859 self::fnPayflowEnsureSession();
855860
856 - if ( !isset( $_SESSION[ 'payflowEditToken' ] ) ) {
 861+ if ( !isset( $_SESSION['payflowEditToken'] ) ) {
857862 // generate unsalted token to place in the session
858863 $token = self::fnPayflowGenerateToken();
859 - $_SESSION[ 'payflowEditToken' ] = $token;
 864+ $_SESSION['payflowEditToken'] = $token;
860865 } else {
861 - $token = $_SESSION[ 'payflowEditToken' ];
 866+ $token = $_SESSION['payflowEditToken'];
862867 }
863868
864869 if ( is_array( $salt ) ) {
@@ -897,7 +902,7 @@
898903 * Unset the payflow edit token from a user's session
899904 */
900905 function fnPayflowUnsetEditToken() {
901 - unset( $_SESSION[ 'payflowEditToken' ] );
 906+ unset( $_SESSION['payflowEditToken'] );
902907 }
903908
904909 /**
@@ -908,7 +913,8 @@
909914 */
910915 public static function fnPayflowEnsureSession() {
911916 // if the session is already started, do nothing
912 - if ( session_id() ) return;
 917+ if ( session_id() )
 918+ return;
913919
914920 // otherwise, fire it up using global mw function wfSetupSession
915921 wfSetupSession();
@@ -925,7 +931,7 @@
926932
927933 // fetch ID for the url reference for OWA tracking
928934 $owa_ref = $wgRequest->getText( 'owa_ref', null );
929 - if( $owa_ref != null && !is_numeric( $owa_ref )){
 935+ if ( $owa_ref != null && !is_numeric( $owa_ref ) ) {
930936 $owa_ref = $this->get_owa_ref_id( $owa_ref );
931937 }
932938
@@ -943,7 +949,7 @@
944950 $card_index = array_rand( $cards );
945951
946952 // randomly select a credit card #
947 - $card_num_index = array_rand( $card_nums[ $cards[ $card_index ]] );
 953+ $card_num_index = array_rand( $card_nums[$cards[$card_index]] );
948954
949955 $data = array(
950956 'amount' => ( $amount != "0.00" ) ? $amount : "35",
@@ -966,8 +972,8 @@
967973 'country2' => 'US',
968974 'size' => 'small',
969975 'premium_language' => 'es',
970 - 'card_num' => $card_nums[ $cards[ $card_index ]][ $card_num_index ],
971 - 'card_type' => $cards[ $card_index ],
 976+ 'card_num' => $card_nums[$cards[$card_index]][$card_num_index],
 977+ 'card_type' => $cards[$card_index],
972978 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ),
973979 'cvv' => '001',
974980 'currency' => 'USD',
@@ -1016,7 +1022,7 @@
10171023 * to be 'country' for downstream processing (until we fully support passing in two separate addresses). I thought about completely
10181024 * disabling country2 support in the forms, etc but realized there's a chance it'll be resurrected shortly. Hence this silly hack.
10191025 */
1020 - 'country2' => ( strlen( $wgRequest->getText( 'country2' ))) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ),
 1026+ 'country2' => ( strlen( $wgRequest->getText( 'country2' ) )) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ),
10211027 'size' => $wgRequest->getText( 'size' ),
10221028 'premium_language' => $wgRequest->getText( 'premium_language', "en" ),
10231029 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ),
@@ -1047,7 +1053,7 @@
10481054 'owa_ref' => $owa_ref,
10491055 );
10501056 }
1051 -
 1057+
10521058 // sanitize user input
10531059 array_walk( $data, array( $this, 'sanitizeInput' ) );
10541060
@@ -1067,7 +1073,7 @@
10681074 public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) {
10691075 $value = htmlspecialchars( $value, $flags, 'UTF-8', $double_encode );
10701076 }
1071 -
 1077+
10721078 public function getPossibleErrors() {
10731079 return array(
10741080 'general' => '',
@@ -1139,7 +1145,8 @@
11401146
11411147 // if there are no sourceparts element, then the banner portion of the string needs to be set.
11421148 // since we don't know what it is, set it to an empty string
1143 - if ( !count( $source_parts ) ) $source_parts[0] = '';
 1149+ if ( !count( $source_parts ) )
 1150+ $source_parts[0] = '';
11441151
11451152 // if the utm_source_id is set, set the landing page portion of the string to cc#
11461153 $source_parts[1] = ( $utm_source_id ) ? 'cc' . $utm_source_id : ( isset( $source_parts[1] ) ? $source_parts[1] : '' );
@@ -1161,8 +1168,8 @@
11621169 // ony update contrib tracking if we're coming from a single-step landing page
11631170 // which we know with cc# in utm_source or if force=true or if contribution_tracking_id is not set
11641171 if ( !$force &&
1165 - !preg_match( "/cc[0-9]/", $data[ 'utm_source' ] ) &&
1166 - is_numeric( $data[ 'contribution_tracking_id' ] ) ) {
 1172+ !preg_match( "/cc[0-9]/", $data['utm_source'] ) &&
 1173+ is_numeric( $data['contribution_tracking_id'] ) ) {
11671174 return;
11681175 }
11691176
@@ -1172,18 +1179,20 @@
11731180
11741181 $db = payflowGatewayConnection();
11751182
1176 - if ( !$db ) { return true ; }
 1183+ if ( !$db ) {
 1184+ return true;
 1185+ }
11771186
11781187 $tracked_contribution = array(
11791188 'note' => $data['comment'],
11801189 'referrer' => $data['referrer'],
1181 - 'anonymous' => $optout[ 'anonymous' ],
 1190+ 'anonymous' => $optout['anonymous'],
11821191 'utm_source' => $data['utm_source'],
11831192 'utm_medium' => $data['utm_medium'],
11841193 'utm_campaign' => $data['utm_campaign'],
11851194 'owa_session' => $data['owa_session'],
11861195 'owa_ref' => $data['owa_ref'],
1187 - 'optout' => $optout[ 'optout' ],
 1196+ 'optout' => $optout['optout'],
11881197 'language' => $data['language'],
11891198 );
11901199
@@ -1195,10 +1204,10 @@
11961205 }
11971206
11981207 // if contrib tracking id is not already set, we need to insert the data, otherwise update
1199 - if ( !$data[ 'contribution_tracking_id' ] ) {
1200 - $data[ 'contribution_tracking_id' ] = $this->insertContributionTracking( $tracked_contribution );
 1208+ if ( !$data['contribution_tracking_id'] ) {
 1209+ $data['contribution_tracking_id'] = $this->insertContributionTracking( $tracked_contribution );
12011210 } else {
1202 - $db->update( 'contribution_tracking', $tracked_contribution, array( 'id' => $data[ 'contribution_tracking_id' ] ) );
 1211+ $db->update( 'contribution_tracking', $tracked_contribution, array( 'id' => $data['contribution_tracking_id'] ) );
12031212 }
12041213 }
12051214
@@ -1215,42 +1224,42 @@
12161225
12171226 // if we don't have a URL enabled throw a graceful error to the user
12181227 if ( !strlen( $wgPayflowProGatewayPaypalURL ) ) {
1219 - $this->errors['general'][ 'nopaypal' ] = wfMsg( 'payflow_gateway-error-msg-nopaypal' );
 1228+ $this->errors['general']['nopaypal'] = wfMsg( 'payflow_gateway-error-msg-nopaypal' );
12201229 return;
12211230 }
12221231
12231232 // update the utm source to set the payment instrument to pp rather than cc
1224 - $utm_source_parts = explode( ".", $data[ 'utm_source' ] );
 1233+ $utm_source_parts = explode( ".", $data['utm_source'] );
12251234 $utm_source_parts[2] = 'pp';
1226 - $data[ 'utm_source' ] = implode( ".", $utm_source_parts );
1227 - $data[ 'gateway' ] = 'paypal';
1228 - $data[ 'currency_code' ] = $data[ 'currency' ];
 1235+ $data['utm_source'] = implode( ".", $utm_source_parts );
 1236+ $data['gateway'] = 'paypal';
 1237+ $data['currency_code'] = $data['currency'];
12291238 /**
12301239 * update contribution tracking
12311240 */
12321241 $this->updateContributionTracking( $data, true );
12331242
1234 - $wgPayflowProGatewayPaypalURL .= "/" . $data[ 'language' ] . "?gateway=paypal";
1235 -
 1243+ $wgPayflowProGatewayPaypalURL .= "/" . $data['language'] . "?gateway=paypal";
 1244+
12361245 // submit the data to the paypal redirect URL
12371246 $wgOut->redirect( $wgPayflowProGatewayPaypalURL . '&' . http_build_query( $data ) );
12381247 }
1239 -
 1248+
12401249 public static function log( $msg, $identifier='payflowpro_gateway', $log_level=LOG_INFO ) {
12411250 global $wgPayflowGatewayUseSyslog;
1242 -
 1251+
12431252 // if we're not using the syslog facility, use wfDebugLog
12441253 if ( !$wgPayflowGatewayUseSyslog ) {
12451254 wfDebugLog( $identifier, $msg );
12461255 return;
12471256 }
1248 -
 1257+
12491258 // otherwise, use syslogging
12501259 openlog( $identifier, LOG_ODELAY, LOG_SYSLOG );
12511260 syslog( $log_level, $msg );
1252 - closelog();
 1261+ closelog();
12531262 }
1254 -
 1263+
12551264 /**
12561265 * Convert an amount for a particular currency to an amount in USD
12571266 *
@@ -1325,7 +1334,10 @@
13261335 $usd_amount = $amount;
13271336 break;
13281337 }
1329 -
 1338+
13301339 return $usd_amount;
13311340 }
1332 -} // end class
 1341+
 1342+}
 1343+
 1344+// end class
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php
@@ -1,44 +1,31 @@
22 <?php
33
4 -$dir = dirname( __FILE__ ) . '/';
5 -require_once( $dir . '../gateway_common/gateway.adapter.php' );
6 -
74 class PayflowProAdapter extends GatewayAdapter {
85 //Contains the map of THEIR var names, to OURS.
96 //I'd have gone the other way, but we'd run into 1:many pretty quick.
107
11 - const gatewayname = 'Payflow Pro';
12 - const logidentifier = 'payflowpro_gateway';
13 - const communicationtype = 'namevalue';
14 - const globalprefix = 'wgPayflowProGateway';
 8+ const GATEWAY_NAME = 'Payflow Pro';
 9+ const IDENTIFIER = 'payflowpro_gateway';
 10+ const COMMUNICATION_TYPE = 'namevalue';
 11+ const GLOBAL_PREFIX = 'wgPayflowProGateway';
1512
16 - function __construct( $data ) {
 13+ /**
 14+ * stageData should alter the postdata array in all ways necessary in preparation for
 15+ * communication with the gateway.
 16+ */
 17+ function stageData() {
 18+
 19+ }
1720
18 - $this->postdata = $data;
19 -
20 - //TODO: Make a Thing in which we do things like this.
21 - $this->postdata['amount'] = $this->postdata['amount'] * 100;
22 -
23 -
24 - $returnTitle = Title::newFromText( 'Donate-thanks/en' );
25 - $returnto = $returnTitle->getFullURL();
26 -
27 - //this DEFINITELY needs to be defined in the parent class, and contain everything anybody might want to know.
28 - $this->postdatadefaults = array(
29 - 'order_id' => '112358' . rand(),
30 - 'amount' => '11.38',
31 - 'currency' => 'USD',
32 - 'language' => 'en',
33 - 'country' => 'US',
34 - 'returnto' => $returnto,
35 - 'user_ip' => ( self::getGlobal('Test') ) ? '12.12.12.12' : wfGetIP(), // current user's IP address
36 - 'order_id' => $this->getOrderId(),
37 - 'i_order_id' => $this->getInternalOrderId(),
 21+ function defineAccountInfo() {
 22+ $this->accountInfo = array(
 23+ 'MERCHANTID' => self::getGlobal( 'MerchantID' ),
 24+ //'IPADDRESS' => '', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm.
 25+ 'VERSION' => "1.0",
3826 );
 27+ }
3928
40 -
41 - ///ehh. Most of this should be broken up into functions for the sake of readibility.
42 -
 29+ function defineVarMap() {
4330 $this->var_map = array(
4431 'ORDERID' => 'order_id',
4532 'AMOUNT' => 'amount',
@@ -49,121 +36,70 @@
5037 'RETURNURL' => 'returnto', //I think. It might not even BE here yet. Boo-urns.
5138 'IPADDRESS' => 'user_ip', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm.
5239 );
 40+ }
5341
 42+ function defineReturnValueMap() {
5443 $this->return_value_map = array(
5544 'OK' => true,
5645 'NOK' => false,
5746 );
 47+ }
5848
59 - global $wgDonationInterfaceTest; //this is so the forms can see it.
60 - if ( !self::getGlobal('Test') ) {
61 - $this->url = self::getGlobal('URL');
62 - $wgDonationInterfaceTest = false;
63 - } else {
64 - $this->url = self::getGlobal('TestingURL');
65 - $wgDonationInterfaceTest = true;
66 - }
 49+ function defineTransactions() {
 50+ $this->transactions = array( );
6751
68 - $this->accountInfo = array(
69 - 'MERCHANTID' => self::getGlobal('MerchantID'),
70 - //'IPADDRESS' => '', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm.
71 - 'VERSION' => "1.0",
72 - );
73 -
74 - //oof. This is getting a little long and unwieldy. Maybe we should build it. Or maybe that sucks. I can't tell yet.
75 - /* General idea here:
76 - * This bad boy will (probably) contain the structure of all possible transactions as defined by the gateway.
77 - * First array key: Some way for us to id the transaction. Doesn't actually have to be the gateway's name for it, but
78 - * I'm starting with that.
79 - * Second array key:
80 - * 'structure' contains the layout of that transaction.
81 - * 'defaults' contains default values for the leaf 'values'
82 - * I could put a 'type' in here, but I think we can assume that if 'structure' is multi-layer, we're XML.
83 - * Array "leaves" in 'structure' will be assigned a value according to the var_map, and the posted data.
84 - * There should also be a mechanism for assigning defaults, but I'm not entirely sure what that would look like quite yet...
85 - *
86 - */
87 - $this->transactions = array(
88 - 'INSERT_ORDERWITHPAYMENT' => array(
89 - 'request' => array(
90 - 'REQUEST' => array(
91 - 'ACTION',
92 - 'META' => array(
93 - 'MERCHANTID',
94 -// 'IPADDRESS',
95 - 'VERSION'
 52+ $this->transactions['INSERT_ORDERWITHPAYMENT'] = array(
 53+ 'request' => array(
 54+ 'REQUEST' => array(
 55+ 'ACTION',
 56+ 'META' => array(
 57+ 'MERCHANTID',
 58+ // 'IPADDRESS',
 59+ 'VERSION'
 60+ ),
 61+ 'PARAMS' => array(
 62+ 'ORDER' => array(
 63+ 'ORDERID',
 64+ 'AMOUNT',
 65+ 'CURRENCYCODE',
 66+ 'LANGUAGECODE',
 67+ 'COUNTRYCODE',
 68+ 'MERCHANTREFERENCE'
9669 ),
97 - 'PARAMS' => array(
98 - 'ORDER' => array(
99 - 'ORDERID',
100 - 'AMOUNT',
101 - 'CURRENCYCODE',
102 - 'LANGUAGECODE',
103 - 'COUNTRYCODE',
104 - 'MERCHANTREFERENCE'
105 - ),
106 - 'PAYMENT' => array(
107 - 'PAYMENTPRODUCTID',
108 - 'AMOUNT',
109 - 'CURRENCYCODE',
110 - 'LANGUAGECODE',
111 - 'COUNTRYCODE',
112 - 'HOSTEDINDICATOR',
113 - 'RETURNURL',
114 - )
 70+ 'PAYMENT' => array(
 71+ 'PAYMENTPRODUCTID',
 72+ 'AMOUNT',
 73+ 'CURRENCYCODE',
 74+ 'LANGUAGECODE',
 75+ 'COUNTRYCODE',
 76+ 'HOSTEDINDICATOR',
 77+ 'RETURNURL',
11578 )
11679 )
117 - ),
118 - 'values' => array(
119 - 'ACTION' => 'INSERT_ORDERWITHPAYMENT',
120 - 'HOSTEDINDICATOR' => '1',
121 - 'PAYMENTPRODUCTID' => '3',
122 - ),
123 - 'result' => array( //just like the rest: This is still in flux. But the idea here is that this is the sctucture you'd scan for.
124 - 'RESULT' => 'value'
125 - ),
126 - 'result_errors' => array(
127 - 'ERROR' => array(
128 - 'CODE' => 'value', //as opposed to "attribute", which would imply that it belongs to the parent...
129 - 'MESSAGE' => 'value',
130 - )
131 - ),
132 - 'result_data' => array(
133 - 'ROW' => array(
134 - //uhh... presumably we'd look for some Stuff in here.
135 - )
13680 )
13781 ),
138 - 'TEST_CONNECTION' => array(
139 - 'request' => array(
140 - 'REQUEST' => array(
141 - 'ACTION',
142 - 'META' => array(
143 - 'MERCHANTID',
 82+ 'values' => array(
 83+ 'ACTION' => 'INSERT_ORDERWITHPAYMENT',
 84+ 'HOSTEDINDICATOR' => '1',
 85+ 'PAYMENTPRODUCTID' => '3',
 86+ ),
 87+ );
 88+
 89+ $this->transactions['TEST_CONNECTION'] = array(
 90+ 'request' => array(
 91+ 'REQUEST' => array(
 92+ 'ACTION',
 93+ 'META' => array(
 94+ 'MERCHANTID',
14495 // 'IPADDRESS',
145 - 'VERSION'
146 - ),
147 - 'PARAMS' => array( )
148 - )
149 - ),
150 - 'values' => array(
151 - 'ACTION' => 'TEST_CONNECTION'
152 - ),
153 - 'result' => array( //just like the rest: This is still in flux. But the idea here is that this is the sctucture you'd scan for.
154 - 'RESULT' => 'value'
155 - ),
156 - 'result_errors' => array(
157 - 'ERROR' => array(
158 - 'CODE' => 'value', //as opposed to "attribute", which would imply that it belongs to the parent...
159 - 'MESSAGE' => 'value',
160 - )
161 - ),
162 - 'result_data' => array(
163 - 'ROW' => array(
164 - //uhh... presumably we'd look for some Stuff in here.
165 - )
 96+ 'VERSION'
 97+ ),
 98+ 'PARAMS' => array( )
16699 )
167100 ),
 101+ 'values' => array(
 102+ 'ACTION' => 'TEST_CONNECTION'
 103+ )
168104 );
169105 }
170106
@@ -176,10 +112,10 @@
177113 }
178114
179115 //TODO: Actually pull these status messages from somewhere legit.
180 - if ( $response['result'] !== false ){
 116+ if ( $response['result'] !== false ) {
181117 //now, parse the thing.
182 -
183 -
 118+
 119+
184120 if ( $response['status'] === true ) {
185121 $response['message'] = "$transaction Transaction Successful!";
186122 } elseif ( $response['status'] === false ) {
@@ -204,27 +140,51 @@
205141 * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off.
206142 * return a string.
207143 */
208 - function getTrimmedResponse( $rawResponse ){}
209 -
 144+ function getTrimmedResponse( $rawResponse ) {
 145+
 146+ }
 147+
210148 /**
211149 * Parse the response to get the status. Not sure if this should return a bool, or something more... telling.
212150 */
213 - function getResponseStatus( $response ){}
214 -
 151+ function getResponseStatus( $response ) {
 152+
 153+ }
 154+
215155 /**
216156 * Parse the response to get the errors in a format we can log and otherwise deal with.
217157 * return a key/value array of codes (if they exist) and messages.
218158 */
219 - function getResponseErrors( $response ){}
220 -
 159+ function getResponseErrors( $response ) {
 160+
 161+ }
 162+
221163 /**
222164 * Harvest the data we need back from the gateway.
223165 * return a key/value array
224166 */
225 - function getResponseData( $response ){}
226 -
227 -
228 -
 167+ function getResponseData( $response ) {
 168+
 169+ }
 170+
 171+ /**
 172+ * Take the entire response string, and strip everything we don't care about.
 173+ * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off.
 174+ * return a string.
 175+ */
 176+ function getFormattedResponse( $rawResponse ) {
 177+
 178+ }
 179+
 180+ /**
 181+ * Actually do... stuff. Here.
 182+ * TODO: Better comment.
 183+ * Process the entire response gott'd by the last four functions.
 184+ */
 185+ function processResponse( $response ) {
 186+
 187+ }
 188+
229189 function parseXMLResponse( $rawResponse ) {
230190 //TODO: Something.
231191 $rawXML = $this->stripResponseHeaders( $rawResponse );
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -21,26 +21,7 @@
2222 // Set up the new special page
2323 $dir = dirname( __FILE__ ) . '/';
2424 $wgAutoloadClasses['PayflowProGateway'] = $dir . 'payflowpro_gateway.body.php';
25 -//
26 -//$wgAutoloadClasses['PayflowProGateway_Form'] = $dir . 'forms/Form.php';
27 -//$wgAutoloadClasses['PayflowProGateway_Form_OneStepTwoColumn'] = $dir . 'forms/OneStepTwoColumn.php';
28 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumn'] = $dir . 'forms/TwoStepTwoColumn.php';
29 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnPayPal'] = $dir . 'forms/TwoColumnPayPal.php';
30 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter'] = $dir . 'forms/TwoColumnLetter.php';
31 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter2'] = $dir . 'forms/TwoColumnLetter2.php';
32 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter3'] = $dir . 'forms/TwoColumnLetter3.php';
33 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter4'] = $dir . 'forms/TwoColumnLetter4.php';
34 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter5'] = $dir . 'forms/TwoColumnLetter5.php';
35 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter6'] = $dir . 'forms/TwoColumnLetter6.php';
36 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoColumnLetter7'] = $dir . 'forms/TwoColumnLetter7.php';
37 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumnLetter'] = $dir . 'forms/TwoStepTwoColumnLetter.php';
38 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumnLetterCA'] = $dir . 'forms/TwoStepTwoColumnLetterCA.php';
39 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumnLetter2'] = $dir . 'forms/TwoStepTwoColumnLetter2.php';
40 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumnLetter3'] = $dir . 'forms/TwoStepTwoColumnLetter3.php';
41 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumnPremium'] = $dir . 'forms/TwoStepTwoColumnPremium.php';
42 -//$wgAutoloadClasses['PayflowProGateway_Form_TwoStepTwoColumnPremiumUS'] = $dir . 'forms/TwoStepTwoColumnPremiumUS.php';
43 -//$wgAutoloadClasses['PayflowProGateway_Form_RapidHtml'] = $dir . 'forms/RapidHtml.php';
44 -//$wgAutoloadClasses['PayflowProGateway_Form_SingleColumn'] = $dir . 'forms/SingleColumn.php';
 25+$wgAutoloadClasses['PayflowProAdapter'] = $dir . 'payflowpro.adapter.php';
4526
4627 $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php';
4728 $wgExtensionMessagesFiles['PayflowProGatewayCountries'] = $dir . 'payflowpro_gateway.countries.i18n.php';
@@ -139,7 +120,7 @@
140121 * /never/ be loaded by the rapid html form loader!
141122 * @var string
142123 */
143 -$wgPayflowProGatewayAllowedHtmlForms = array( $wgPayflowProGatewayHtmlFormDir . "/demo.html" );
 124+$wgPayflowProGatewayAllowedHtmlForms = $wgDonationInterfaceAllowedHtmlForms;
144125
145126 /**
146127 * Configure PayflowproGateway to use syslog for log messages rather than wfDebugLog
@@ -168,7 +149,6 @@
169150 $wgAPIModules['pfp'] = 'ApiPayflowProGateway';
170151 $wgAutoloadClasses['ApiPayflowProGateway'] = $dir . 'api_payflowpro_gateway.php';
171152
172 -
173153 /**
174154 * Hook to register form value and display name of this gateway
175155 * also supplies currencies supported by this gateway
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php
@@ -3,7 +3,7 @@
44 class Gateway_Form_TwoColumnLetter2 extends Gateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php
@@ -3,7 +3,7 @@
44 class Gateway_Form_TwoColumnLetter3 extends Gateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php
@@ -3,7 +3,7 @@
44 class Gateway_Form_TwoColumnLetter4 extends Gateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter4.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php
@@ -2,7 +2,7 @@
33
44 class Gateway_Form_TwoColumnLetter5 extends Gateway_Form_OneStepTwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter5.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php
@@ -2,7 +2,7 @@
33
44 class Gateway_Form_TwoColumnLetter6 extends Gateway_Form_OneStepTwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter6.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class Gateway_Form_TwoStepTwoColumnLetter extends Gateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php
@@ -2,7 +2,7 @@
33
44 class Gateway_Form_TwoColumnLetter7 extends Gateway_Form_OneStepTwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter7.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function loadPlaceholders() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnPayPal.php
@@ -1,8 +1,8 @@
22 <?php
33
44 class Gateway_Form_TwoColumnPayPal extends Gateway_Form_OneStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
6 - parent::__construct( $form_data, $form_errors );
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
 6+ parent::__construct( $form_data, $form_errors, $gateway );
77 }
88
99 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/SingleColumn.php
@@ -2,7 +2,7 @@
33
44 class Gateway_Form_SingleColumn extends Gateway_Form_TwoColumnLetter {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgScriptPath;
88
99 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -10,7 +10,7 @@
1111 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/SingleColumn.css' );
1212 }
1313
14 - parent::__construct( $form_data, $form_errors );
 14+ parent::__construct( $form_data, $form_errors, $gateway );
1515 }
1616
1717 public function generateFormEnd() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class Gateway_Form_TwoStepTwoColumnLetterCA extends Gateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php
@@ -49,12 +49,13 @@
5050 */
5151 abstract function getForm();
5252
53 - public function __construct( &$data, &$error ) {
 53+ public function __construct( &$data, &$error, &$gateway ) {
5454 global $wgDonationInterfaceTest, $wgOut;
5555
5656 $this->test = $wgDonationInterfaceTest;
57 - $this->form_data =& $data;
58 - $this->form_errors =& $error;
 57+ $this->form_data = & $data;
 58+ $this->form_errors = & $error;
 59+ $this->gateway = & $gateway;
5960
6061 /**
6162 * add form-specific css - the path can be set in child classes
@@ -71,7 +72,7 @@
7273 * We do this here (rather than in individual forms) because if OWA is
7374 * enabled, we ALWAYS want to make sure it gets included.
7475 */
75 - if(defined('OWA')){
 76+ if ( defined( 'OWA' ) ) {
7677 $this->loadOwaJs();
7778 }
7879 }
@@ -141,7 +142,7 @@
142143
143144 // create a new array of countries with potentially translated country names for alphabetizing later
144145 foreach ( $this->getCountries() as $iso_value => $full_name ) {
145 - $countries[ $iso_value ] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value );
 146+ $countries[$iso_value] = wfMsg( 'payflowpro_gateway-country-dropdown-' . $iso_value );
146147 }
147148
148149 // alphabetically sort the country names
@@ -149,8 +150,8 @@
150151
151152 // generate a dropdown option for each country
152153 foreach ( $countries as $iso_value => $full_name ) {
153 - if ( $this->form_data[ 'country' ] ) {
154 - $selected = ( $iso_value == $this->form_data[ 'country' ] ) ? true : false;
 154+ if ( $this->form_data['country'] ) {
 155+ $selected = ( $iso_value == $this->form_data['country'] ) ? true : false;
155156 } else {
156157 $selected = ( $iso_value == $defaultCountry ) ? true : false; // Select default
157158 }
@@ -159,8 +160,7 @@
160161
161162 // build the actual select
162163 $country_menu = Xml::openElement(
163 - 'select',
164 - array(
 164+ 'select', array(
165165 'name' => 'country',
166166 'id' => 'country'
167167 ) );
@@ -190,14 +190,13 @@
191191 // generate a dropdown opt for each card
192192 foreach ( $available_cards as $value => $card_name ) {
193193 // only load the card value if we're in testing mode
194 - $selected = ( $value == $this->form_data[ 'card_type' ] && $this->test ) ? true : false;
 194+ $selected = ( $value == $this->form_data['card_type'] && $this->test ) ? true : false;
195195 $card_options .= Xml::option( $card_name, $value, $selected );
196196 }
197197
198198 // build the actual select
199199 $card_menu = Xml::openElement(
200 - 'select',
201 - array(
 200+ 'select', array(
202201 'name' => 'card_type',
203202 'id' => 'card_type'
204203 ) );
@@ -212,8 +211,8 @@
213212
214213 // derive the previously set expiry month, if set
215214 $month = NULL;
216 - if ( $this->form_data[ 'expiration' ] ) {
217 - $month = substr( $this->form_data[ 'expiration' ], 0, 2 );
 215+ if ( $this->form_data['expiration'] ) {
 216+ $month = substr( $this->form_data['expiration'], 0, 2 );
218217 }
219218
220219 $expiry_months = '';
@@ -222,14 +221,11 @@
223222 for ( $i = 1; $i < 13; $i++ ) {
224223 $selected = ( $i == $month && $this->test ) ? true : false;
225224 $expiry_months .= Xml::option(
226 - wfMsg( 'payflowpro_gateway-month', $i, $wgLang->getMonthName( $i ) ),
227 - str_pad( $i, 2, '0', STR_PAD_LEFT ),
228 - $selected );
 225+ wfMsg( 'payflowpro_gateway-month', $i, $wgLang->getMonthName( $i ) ), str_pad( $i, 2, '0', STR_PAD_LEFT ), $selected );
229226 }
230227
231228 $expiry_month_menu = Xml::openElement(
232 - 'select',
233 - array(
 229+ 'select', array(
234230 'name' => 'mos',
235231 'id' => 'expiration'
236232 ) );
@@ -241,8 +237,8 @@
242238 public function generateExpiryYearDropdown() {
243239 // derive the previously set expiry year, if set
244240 $year = NULL;
245 - if ( $this->form_data[ 'expiration' ] ) {
246 - $year = substr( $this->form_data[ 'expiration' ], 2, 2 );
 241+ if ( $this->form_data['expiration'] ) {
 242+ $year = substr( $this->form_data['expiration'], 2, 2 );
247243 }
248244
249245 $expiry_years = '';
@@ -255,8 +251,7 @@
256252 }
257253
258254 $expiry_year_menu = Xml::openElement(
259 - 'select',
260 - array(
 255+ 'select', array(
261256 'name' => 'year',
262257 'id' => 'year',
263258 ) );
@@ -280,13 +275,12 @@
281276
282277 // generate dropdown of state opts
283278 foreach ( $states as $value => $state_name ) {
284 - $selected = ( $this->form_data[ 'state' ] == $value ) ? true : false;
 279+ $selected = ( $this->form_data['state'] == $value ) ? true : false;
285280 $state_opts .= Xml::option( wfMsg( 'payflowpro_gateway-state-dropdown-' . $value ), $value, $selected );
286281 }
287282
288283 $state_menu = Xml::openElement(
289 - 'select',
290 - array(
 284+ 'select', array(
291285 'name' => 'state',
292286 'id' => 'state'
293287 ) );
@@ -318,13 +312,12 @@
319313
320314 // generate dropdown of currency opts
321315 foreach ( $available_currencies as $value => $currency_name ) {
322 - $selected = ( $this->form_data[ 'currency' ] == $value ) ? true : false;
 316+ $selected = ( $this->form_data['currency'] == $value ) ? true : false;
323317 $currency_opts .= Xml::option( wfMsg( 'donate_interface-' . $value ), $value, $selected );
324318 }
325319
326320 $currency_menu = Xml::openElement(
327 - 'select',
328 - array(
 321+ 'select', array(
329322 'name' => 'currency_code',
330323 'id' => 'input_currency_code',
331324 'onchange' => 'showCards()'
@@ -343,28 +336,28 @@
344337 */
345338 public function setHiddenFields( $hidden_fields = NULL ) {
346339 if ( !$hidden_fields ) {
347 - $hidden_fields = array(
348 - 'utm_source' => $this->form_data[ 'utm_source' ],
349 - 'utm_medium' => $this->form_data[ 'utm_medium' ],
350 - 'utm_campaign' => $this->form_data[ 'utm_campaign' ],
351 - 'language' => $this->form_data[ 'language' ],
352 - 'referrer' => $this->form_data[ 'referrer' ],
353 - 'comment' => $this->form_data[ 'comment' ],
354 - 'comment-option' => $this->form_data[ 'comment-option' ],
355 - 'email-opt' => $this->form_data[ 'email-opt' ],
356 - 'size' => $this->form_data[ 'size' ],
357 - 'premium_language' => $this->form_data[ 'premium_language' ],
 340+ $hidden_fields = array(
 341+ 'utm_source' => $this->form_data['utm_source'],
 342+ 'utm_medium' => $this->form_data['utm_medium'],
 343+ 'utm_campaign' => $this->form_data['utm_campaign'],
 344+ 'language' => $this->form_data['language'],
 345+ 'referrer' => $this->form_data['referrer'],
 346+ 'comment' => $this->form_data['comment'],
 347+ 'comment-option' => $this->form_data['comment-option'],
 348+ 'email-opt' => $this->form_data['email-opt'],
 349+ 'size' => $this->form_data['size'],
 350+ 'premium_language' => $this->form_data['premium_language'],
358351 'process' => 'CreditCard',
359352 'payment_method' => 'processed',
360 - 'token' => $this->form_data[ 'token' ],
361 - 'order_id' => $this->form_data[ 'order_id' ],
362 - 'i_order_id' => $this->form_data[ 'i_order_id' ],
363 - 'numAttempt' => $this->form_data[ 'numAttempt' ],
364 - 'contribution_tracking_id' => $this->form_data[ 'contribution_tracking_id' ],
365 - 'data_hash' => $this->form_data[ 'data_hash' ],
366 - 'action' => $this->form_data[ 'action' ],
367 - 'owa_session' => $this->form_data[ 'owa_session' ],
368 - 'owa_ref' => $this->form_data[ 'owa_ref' ],
 353+ 'token' => $this->form_data['token'],
 354+ 'order_id' => $this->form_data['order_id'],
 355+ 'i_order_id' => $this->form_data['i_order_id'],
 356+ 'numAttempt' => $this->form_data['numAttempt'],
 357+ 'contribution_tracking_id' => $this->form_data['contribution_tracking_id'],
 358+ 'data_hash' => $this->form_data['data_hash'],
 359+ 'action' => $this->form_data['action'],
 360+ 'owa_session' => $this->form_data['owa_session'],
 361+ 'owa_ref' => $this->form_data['owa_ref'],
369362 );
370363 }
371364
@@ -410,15 +403,17 @@
411404 }
412405
413406 protected function generateBannerHeader() {
414 - global $wgPayflowProGatewayHeader, $wgOut, $wgRequest;
 407+ global $wgOut, $wgRequest;
 408+ $g = $this->gateway;
 409+ $header = $g::getGlobal( 'Header' );
415410
416411 $template = '';
417412
418413 // intro text
419414 if ( $wgRequest->getText( 'masthead', false ) ) {
420 - $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' );
421 - } elseif ( $wgPayflowProGatewayHeader ) {
422 - $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowProGatewayHeader );
 415+ $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data['language'] . '}}' );
 416+ } elseif ( $header ) {
 417+ $header = str_replace( '@language', $this->form_data['language'], $header );
423418 $template = $wgOut->parse( $header );
424419 }
425420
@@ -455,13 +450,13 @@
456451 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount' ) . '</td>';
457452 $form .= '<td>' . Xml::radio( 'amount', 100, $this->form_data['amount'] == 100 ) . '100 ' .
458453 Xml::radio( 'amount', 50, $this->form_data['amount'] == 50 ) . '50 ' .
459 - Xml::radio( 'amount', 35, $this->form_data['amount'] == 35 ) . '35 ' .
 454+ Xml::radio( 'amount', 35, $this->form_data['amount'] == 35 ) . '35 ' .
460455 Xml::radio( 'amount', 20, $this->form_data['amount'] == 20 ) . '20 ' .
461456 '</td>';
462457 $form .= '</tr>';
463458 $form .= '<tr>';
464459 $form .= '<td class="label"></td>';
465 - $form .= '<td>' . Xml::radio( 'amount', $amount, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \''.wfMsg( 'payflowpro_gateway-other' ).'\' )', 'onblur' => 'document.getElementById("otherRadio").value = this.value;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther' ) ) .
 460+ $form .= '<td>' . Xml::radio( 'amount', $amount, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg( 'payflowpro_gateway-other' ) . '\' )', 'onblur' => 'document.getElementById("otherRadio").value = this.value;if (this.value > 0) document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'id' => 'amountOther' ) ) .
466461 ' ' . $this->generateCurrencyDropdown() . '</td>';
467462 $form .= '</tr>';
468463 return $form;
@@ -469,7 +464,7 @@
470465
471466 protected function getCardnumberField() {
472467 global $wgDonationInterfaceTest;
473 - $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data[ 'card_num' ] : '';
 468+ $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data['card_num'] : '';
474469 $form = '';
475470 if ( $this->form_errors['card_num'] ) {
476471 $form .= '<tr>';
@@ -491,7 +486,7 @@
492487
493488 protected function getCvvField() {
494489 global $wgDonationInterfaceTest;
495 - $cvv = ( $wgDonationInterfaceTest ) ? $this->form_data[ 'cvv' ] : '';
 490+ $cvv = ( $wgDonationInterfaceTest ) ? $this->form_data['cvv'] : '';
496491
497492 $form = '<tr>';
498493 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['cvv'] . '</span></td>';
@@ -549,8 +544,8 @@
550545 $form .= '</tr>';
551546 $form .= '<tr>';
552547 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-name' ), 'fname' ) . '</td>';
553 - $form .= '<td>' . Xml::input( 'fname', '30', $this->form_data['fname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \''.wfMsg( 'payflowpro_gateway-donor-fname' ).'\' )', 'maxlength' => '25', 'class' => 'required', 'id' => 'fname' ) ) .
554 - Xml::input( 'lname', '30', $this->form_data['lname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \''.wfMsg( 'payflowpro_gateway-donor-lname' ).'\' )', 'maxlength' => '25', 'id' => 'lname' ) ) . '</td>';
 548+ $form .= '<td>' . Xml::input( 'fname', '30', $this->form_data['fname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg( 'payflowpro_gateway-donor-fname' ) . '\' )', 'maxlength' => '25', 'class' => 'required', 'id' => 'fname' ) ) .
 549+ Xml::input( 'lname', '30', $this->form_data['lname'], array( 'type' => 'text', 'onfocus' => 'clearField( this, \'' . wfMsg( 'payflowpro_gateway-donor-lname' ) . '\' )', 'maxlength' => '25', 'id' => 'lname' ) ) . '</td>';
555550 $form .= "</tr>";
556551 return $form;
557552 }
@@ -558,7 +553,7 @@
559554 protected function getCommentMessageField() {
560555 $form = '<tr>';
561556 $form .= '<td colspan="2">';
562 - $form .= Xml::tags( 'p', array(), wfMsg( 'donate_interface-comment-message' ) );
 557+ $form .= Xml::tags( 'p', array( ), wfMsg( 'donate_interface-comment-message' ) );
563558 $form .= '</td>';
564559 $form .= '</tr>';
565560 return $form;
@@ -567,14 +562,14 @@
568563 protected function getCommentField() {
569564 $form = '<tr>';
570565 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-comment' ), 'comment' ) . '</td>';
571 - $form .= '<td>' . Xml::input( 'comment', '30', $this->form_data[ 'comment' ], array( 'type' => 'text', 'maxlength' => '200', 'class' => 'fullwidth' ) ) . '</td>';
 566+ $form .= '<td>' . Xml::input( 'comment', '30', $this->form_data['comment'], array( 'type' => 'text', 'maxlength' => '200', 'class' => 'fullwidth' ) ) . '</td>';
572567 $form .= '</tr>';
573568 return $form;
574569 }
575570
576571 protected function getCommentOptionField() {
577572 global $wgRequest;
578 - $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true;
 573+ $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data['comment-option'] : true;
579574 $form = '<tr>';
580575 $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
581576 $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>';
@@ -584,7 +579,7 @@
585580
586581 protected function getEmailOptField() {
587582 global $wgRequest;
588 - $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'email-opt' ] : true;
 583+ $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data['email-opt'] : true;
589584 $form = '<tr>';
590585 $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value );
591586 $form .= ' ';
@@ -604,10 +599,8 @@
605600 $form = '<tr>';
606601 $form .= '<td class="paypal-button" colspan="2">';
607602 $form .= Html::hidden( 'PaypalRedirect', false );
608 - $form .= Xml::tags( 'div',
609 - array(),
610 - '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="' . $scriptPath . '/donate_with_paypal.gif"/></a>'
611 - );
 603+ $form .= Xml::tags( 'div', array( ), '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="' . $scriptPath . '/donate_with_paypal.gif"/></a>'
 604+ );
612605 $form .= '</td>';
613606 $form .= '</tr>';
614607 return $form;
@@ -631,8 +624,8 @@
632625 $form .= '<tr>';
633626 $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-country' ), 'country' ) . '</td>';
634627 $form .= '<td>' . $this->generateCountryDropdown( $defaultCountry ) . '</td>';
635 - $form .= '</tr>';
636 - return $form;
 628+ $form .= '</tr>';
 629+ return $form;
637630 }
638631
639632 protected function getCreditCardTypeField() {
@@ -654,45 +647,44 @@
655648 protected function loadValidateJs() {
656649 global $wgOut, $wgScriptPath;
657650 $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" src="' .
658 - $wgScriptPath .
659 - '/extensions/DonationInterface/payflowpro_gateway/validate_input.js?284"></script>' );
 651+ $wgScriptPath .
 652+ '/extensions/DonationInterface/payflowpro_gateway/validate_input.js?284"></script>' );
660653 }
661654
662655 protected function loadApiJs() {
663656 global $wgOut, $wgScriptPath;
664657 $wgOut->addHeadItem( 'pfp_api_call', '<script type="text/javascript" src="' .
665 - $wgScriptPath .
666 - '/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js?284"></script>' );
 658+ $wgScriptPath .
 659+ '/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js?284"></script>' );
667660 }
668661
669662 protected function loadOwaJs() {
670663 global $wgOut, $wgScriptPath;
671 - $wgOut->addHeadItem('owa_tracker', '<script type="text/javascript" src="https://owa.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>');
672 -
 664+ $wgOut->addHeadItem( 'owa_tracker', '<script type="text/javascript" src="https://owa.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>' );
 665+
673666 $wgOut->addHeadItem( 'owa_get_info', '<script type="text/javascript" src="' .
674 - $wgScriptPath .
675 - '/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js?284"></script>' );
 667+ $wgScriptPath .
 668+ '/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js?284"></script>' );
676669 $wgOut->addHeadItem( 'owa_tracker_init', '<script type="text/javascript" src="' .
677 - $wgScriptPath .
678 - '/extensions/DonationInterface/payflowpro_gateway/owa.tracker-combined-min.js?284"></script>' );
679 -
 670+ $wgScriptPath .
 671+ '/extensions/DonationInterface/payflowpro_gateway/owa.tracker-combined-min.js?284"></script>' );
680672 }
681673
682 -
683674 /**
684675 * Generate HTML for <noscript> tags
685676 *
686677 * For displaying when a user does not have Javascript enabled in their browser.
687678 */
688679 protected function getNoScript() {
689 - global $wgPayflowProGatewayNoScriptRedirect;
 680+ $g = $this->gateway;
 681+ $noScriptRedirect = $g::getGlobal( 'NoScriptRedirect' );
690682
691683 $form = '<noscript>';
692684 $form .= '<div id="noscript">';
693685 $form .= '<p id="noscript-msg">' . wfMsg( 'payflowpro_gateway-noscript-msg' ) . '</p>';
694 - if ( $wgPayflowProGatewayNoScriptRedirect ) {
 686+ if ( $noScriptRedirect ) {
695687 $form .= '<p id="noscript-redirect-msg">' . wfMsg( 'payflowpro_gateway-noscript-redirect-msg' ) . '</p>';
696 - $form .= '<p id="noscript-redirect-link"><a href="' . $wgPayflowProGatewayNoScriptRedirect . '">' . $wgPayflowProGatewayNoScriptRedirect . '</a></p>';
 688+ $form .= '<p id="noscript-redirect-link"><a href="' . $noScriptRedirect . '">' . $noScriptRedirect . '</a></p>';
697689 }
698690 $form .= '</div>';
699691 $form .= '</noscript>';
@@ -712,21 +704,22 @@
713705
714706 $url = $wgRequest->getFullRequestURL();
715707 $url_parts = wfParseUrl( $url );
716 - if ( isset( $url_parts[ 'query' ] ) ) {
717 - $query_array = wfCgiToArray( $url_parts[ 'query' ] );
 708+ if ( isset( $url_parts['query'] ) ) {
 709+ $query_array = wfCgiToArray( $url_parts['query'] );
718710 } else {
719 - $query_array = array();
 711+ $query_array = array( );
720712 }
721713
722714 // ensure that _cache_ does not get set in the URL
723 - unset( $query_array[ '_cache_' ] );
 715+ unset( $query_array['_cache_'] );
724716
725717 // make sure no other data that might overwrite posted data makes it into the URL
726718 foreach ( $this->form_data as $key => $value ) {
727 - unset( $query_array[ $key ] );
 719+ unset( $query_array[$key] );
728720 }
729721
730722 // construct the submission url
731723 return wfAppendQuery( $wgTitle->getLocalURL(), $query_array );
732724 }
 725+
733726 }
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter.php
@@ -3,7 +3,7 @@
44 class Gateway_Form_TwoColumnLetter extends Gateway_Form_OneStepTwoColumn {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgScriptPath;
99
1010 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -11,7 +11,7 @@
1212 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' );
1313 }
1414
15 - parent::__construct( $form_data, $form_errors );
 15+ parent::__construct( $form_data, $form_errors, $gateway );
1616 }
1717
1818 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class Gateway_Form_TwoStepTwoColumnPremium extends Gateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnPremium.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function generateFormStart() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php
@@ -2,10 +2,10 @@
33
44 class Gateway_Form_TwoStepTwoColumn extends Gateway_Form {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
77 global $wgOut;
88
9 - parent::__construct( $form_data, $form_errors );
 9+ parent::__construct( $form_data, $form_errors, $gateway );
1010
1111 // we only want to load this JS if the form is being rendered
1212 $this->loadValidateJs(); // validation JS
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter2.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class Gateway_Form_TwoStepTwoColumnLetter2 extends Gateway_Form_TwoStepTwoColumnLetter {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,6 +9,6 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter2.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515 }
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class Gateway_Form_TwoStepTwoColumnLetter3 extends Gateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgExtensionAssetsPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/TwoStepTwoColumnLetter3.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function loadPlaceholders() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/RapidHtml.php
@@ -1,13 +1,13 @@
22 <?php
33
44 class Gateway_Form_RapidHtml extends Gateway_Form {
5 -
 5+
66 /**
77 * Full path of HTML form to load
88 * @var string
99 */
1010 protected $html_file_path = '';
11 -
 11+
1212 /**
1313 * Tokens used in HTML form for data replacement
1414 *
@@ -57,7 +57,7 @@
5858 // @script_path -> maps to $wgScriptPath
5959 // @action -> generate correct form action for this form
6060 );
61 -
 61+
6262 /**
6363 * Error field names used as tokens
6464 * @var array
@@ -78,26 +78,26 @@
7979 '#zip',
8080 '#emailAdd',
8181 );
82 -
83 - public function __construct( &$form_data, &$form_errors ) {
 82+
 83+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
8484 global $wgRequest;
85 - parent::__construct( $form_data, $form_errors );
 85+ parent::__construct( $form_data, $form_errors, $gateway );
8686
8787 $this->loadValidateJs();
88 -
 88+
8989 // set html-escaped filename.
90 - $this->set_html_file_path( htmlspecialchars( $wgRequest->getText( 'ffname', 'default' )));
91 -
 90+ $this->set_html_file_path( htmlspecialchars( $wgRequest->getText( 'ffname', 'default' ) ) );
 91+
9292 // fix general form error messages so it's not an array of msgs
93 - if ( is_array( $form_errors[ 'general' ] ) && count( $form_errors[ 'general' ] )) {
 93+ if ( is_array( $form_errors['general'] ) && count( $form_errors['general'] ) ) {
9494 $general_errors = "";
95 - foreach ( $form_errors[ 'general' ] as $general_error ) {
 95+ foreach ( $form_errors['general'] as $general_error ) {
9696 $general_errors .= "<p class='creditcard'>$general_error</p>";
9797 }
98 - $form_errors[ 'general' ] = $general_errors;
 98+ $form_errors['general'] = $general_errors;
9999 }
100100 }
101 -
 101+
102102 /**
103103 * Return the HTML form with data added
104104 */
@@ -105,7 +105,7 @@
106106 $html = $this->load_html();
107107 return $this->add_data( $html );
108108 }
109 -
 109+
110110 /**
111111 * Load the HTML form from a file into a string
112112 * @return string
@@ -113,7 +113,7 @@
114114 public function load_html() {
115115 return file_get_contents( $this->html_file_path );
116116 }
117 -
 117+
118118 /**
119119 * Add data into the HTML form
120120 *
@@ -127,34 +127,36 @@
128128 * This is a hack and should be replaced with something more performant.
129129 */
130130 $form = $html;
131 -
 131+
132132 // handle form action
133133 $form = str_replace( "@action", $this->getNoCacheAction(), $form );
134134
135135 // replace data
136136 foreach ( $this->data_tokens as $token ) {
137 - $key = substr( $token, 1, strlen( $token )); //get the token string w/o the '@'
138 - if ( $key == 'emailAdd' ) $key = 'email';
139 - if ( $key == 'currency_code' ) $key = 'currency';
140 - if ( array_key_exists( $key, $this->form_data )) {
141 - $replace = $this->form_data[ $key ];
 137+ $key = substr( $token, 1, strlen( $token ) ); //get the token string w/o the '@'
 138+ if ( $key == 'emailAdd' )
 139+ $key = 'email';
 140+ if ( $key == 'currency_code' )
 141+ $key = 'currency';
 142+ if ( array_key_exists( $key, $this->form_data ) ) {
 143+ $replace = $this->form_data[$key];
142144 } else {
143145 $replace = '';
144146 }
145147 $form = str_replace( $token, $replace, $form );
146148 }
147 -
 149+
148150 // replace errors
149151 $form = str_replace( $this->error_tokens, $this->form_errors, $form );
150152
151153 // handle captcha
152154 $form = str_replace( "@captcha", $this->getCaptchaHtml(), $form );
153 -
 155+
154156 // handle script path
155157 $form = str_replace( "@script_path", $wgScriptPath, $form );
156 -
 158+
157159 $form = $this->fix_dropdowns( $form );
158 -
 160+
159161 return $form;
160162 }
161163
@@ -170,83 +172,77 @@
171173 // currency code
172174 $start = strpos( $html, 'name="currency_code"' );
173175 if ( $start ) {
174 - $currency_code = $this->form_data[ 'currency' ];
 176+ $currency_code = $this->form_data['currency'];
175177 $end = strpos( $html, '</select>', $start );
176 - $str = substr( $html, $start, ( $end - $start ));
 178+ $str = substr( $html, $start, ( $end - $start ) );
177179 $str = str_replace( 'value="' . $currency_code . '"', 'value="' . $currency_code . '" selected="selected"', $str );
178 - $html = substr_replace( $html, $str, $start, $end-$start );
 180+ $html = substr_replace( $html, $str, $start, $end - $start );
179181 }
180 -
 182+
181183 // mos
182 - $month = substr( $this->form_data[ 'expiration' ], 0, 2 );
 184+ $month = substr( $this->form_data['expiration'], 0, 2 );
183185 $start = strpos( $html, 'name="mos"' );
184186 if ( $start ) {
185187 $end = strpos( $html, '</select>', $start );
186 - $str = substr( $html, $start, ( $end - $start ));
 188+ $str = substr( $html, $start, ( $end - $start ) );
187189 $str = str_replace( 'value="' . $month . '"', 'value="' . $month . '" selected="selected"', $str );
188 - $html = substr_replace( $html, $str, $start, $end-$start );
 190+ $html = substr_replace( $html, $str, $start, $end - $start );
189191 }
190 -
 192+
191193 // year
192 - $year = substr( $this->form_data[ 'expiration' ], 2, 2 );
 194+ $year = substr( $this->form_data['expiration'], 2, 2 );
193195 $start = strpos( $html, 'name="year"' );
194 - if ( $start ) {
 196+ if ( $start ) {
195197 $end = strpos( $html, '</select>', $start );
196 - $str = substr( $html, $start, ( $end - $start ));
 198+ $str = substr( $html, $start, ( $end - $start ) );
197199 // dbl extra huge hack alert! note the '20' prefix...
198200 $str = str_replace( 'value="20' . $year . '"', 'value="20' . $year . '" selected="selected"', $str );
199 - $html = substr_replace( $html, $str, $start, $end-$start );
 201+ $html = substr_replace( $html, $str, $start, $end - $start );
200202 }
201 -
 203+
202204 // state
203 - $state = $this->form_data[ 'state' ];
 205+ $state = $this->form_data['state'];
204206 $start = strpos( $html, 'name="state"' );
205207 if ( $start ) {
206208 $end = strpos( $html, '</select>', $start );
207 - $str = substr( $html, $start, ( $end - $start ));
 209+ $str = substr( $html, $start, ( $end - $start ) );
208210 $str = str_replace( 'value="' . $state . '"', 'value="' . $state . '" selected="selected"', $str );
209 - $html = substr_replace( $html, $str, $start, $end-$start );
 211+ $html = substr_replace( $html, $str, $start, $end - $start );
210212 }
211 -
 213+
212214 //country
213 - $country = $this->form_data[ 'country' ];
 215+ $country = $this->form_data['country'];
214216 $start = strpos( $html, 'name="country"' );
215217 if ( $start ) {
216218 $end = strpos( $html, '</select>', $start );
217 - $str = substr( $html, $start, ( $end - $start ));
 219+ $str = substr( $html, $start, ( $end - $start ) );
218220 $str = str_replace( 'value="' . $country . '"', 'value="' . $country . '" selected="selected"', $str );
219 - $html = substr_replace( $html, $str, $start, $end-$start );
 221+ $html = substr_replace( $html, $str, $start, $end - $start );
220222 }
221 -
 223+
222224 return $html;
223225 }
224 -
 226+
225227 /**
226228 * Validate and set the path to the HTML file
227229 *
228230 * @param string $file_name
229231 */
230232 public function set_html_file_path( $file_name ) {
231 - global $wgGlobalCollectGatewayHtmlFormDir, $wgGlobalCollectGatewayAllowedHtmlForms;
232 -
233 - // Get the dirname - the "/." helps ensure we get a consistent path name with no trailing slash
234 - $html_dir = dirname( $wgGlobalCollectGatewayHtmlFormDir . "/." );
235 -
236 - if ( !is_dir( $html_dir )) {
237 - throw new MWException( 'Requested form directory does not exist.' );
238 - }
239 -
240 - // make sure our file name is clean - strip extension and any other cruft like relpaths, dirs, etc
241 - $file_info = pathinfo( $file_name );
242 - $file_name = $file_info[ 'filename' ];
243 -
244 - $full_path = $html_dir . '/' . $file_name . '.html';
245 -
246 - // ensure that the full file path is actually whitelisted and exists
247 - if ( !in_array( $full_path, $wgGlobalCollectGatewayAllowedHtmlForms ) || !file_exists( $full_path ) ) {
 233+ global $wgDonationInterfaceHtmlFormDir;
 234+
 235+ $g = $this->gateway;
 236+ $gatewayFormDir = $g::getGlobal( 'HtmlFormDir' );
 237+ $allowedForms = $g::getGlobal( 'AllowedHtmlForms' );
 238+
 239+ if ( !array_key_exists( $file_name, $allowedForms ) ||
 240+ ((strpos( $allowedForms[$file_name], $gatewayFormDir ) === false) && (strpos( $allowedForms[$file_name], $wgDonationInterfaceHtmlFormDir ) === false)) ||
 241+ (!file_exists( $allowedForms[$file_name] )) ) {
 242+
248243 throw new MWException( 'Requested an unavailable or non-existent form.' );
249244 }
250 -
251 - $this->html_file_path = $full_path;
 245+
 246+ $this->html_file_path = $allowedForms[$file_name];
252247 }
 248+
253249 }
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class Gateway_Form_TwoStepTwoColumnPremiumUS extends Gateway_Form_TwoStepTwoColumn {
5 - public function __construct( &$form_data, &$form_errors ) {
 5+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
66 global $wgScriptPath;
77
88 // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this
@@ -9,7 +9,7 @@
1010 $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnPremiumUS.css' );
1111 }
1212
13 - parent::__construct( $form_data, $form_errors );
 13+ parent::__construct( $form_data, $form_errors, $gateway );
1414 }
1515
1616 public function loadPlaceholders() {
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php
@@ -3,10 +3,10 @@
44 class Gateway_Form_OneStepTwoColumn extends Gateway_Form {
55 public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
 7+ public function __construct( &$form_data, &$form_errors, &$gateway ) {
88 global $wgOut;
99
10 - parent::__construct( $form_data, $form_errors );
 10+ parent::__construct( $form_data, $form_errors, $gateway );
1111
1212 // update the list of hidden fields we need to use in this form.
1313 $this->updateHiddenFields();
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/forms/html/demo.html
@@ -0,0 +1,162 @@
 2+<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td id="appeal" valign="top"><h2 id="appeal-head"> <span class="mw-headline" id="An_appeal_from_Wikipedia_founder_Jimmy_Wales">An appeal from Wikipedia founder Jimmy Wales</span></h2>
 3+<div class="plainlinks" id="appeal-body">I got a lot of funny looks ten years ago when I started talking to people about Wikipedia.
 4+<p>Let’s just say some people were skeptical of the notion that volunteers from all across the world could come together to create a remarkable pool of human knowledge – all for the simple purpose of sharing.</p>
 5+<p>No ads. No agenda. No strings attached.</p>
 6+<p>A decade after its founding, nearly 400 million people use Wikipedia and its sister sites every month - almost a third of the Internet-connected world.</p>
 7+<p>It is the 5th most popular website in the world but Wikipedia isn’t anything like a commercial website. It is a community creation, written by volunteers making one entry at a time. You are part of our community. And I’m writing today to ask you to protect and sustain Wikipedia.</p>
 8+<p>Together, we can keep it free of charge and free of advertising. We can keep it open – you can use the information in Wikipedia any way you want. We can keep it growing – spreading knowledge everywhere, and inviting participation from everyone.</p>
 9+
 10+<p>Each year at this time, we reach out to ask you and others all across the Wikimedia community to help sustain our joint enterprise with a modest donation of $20, $35, $50 or more.</p>
 11+<p>If you value Wikipedia as a source of information – and a source of inspiration – I hope you’ll choose to act right now.</p>
 12+<p>All the best,</p>
 13+<p><b>Jimmy Wales</b></p>
 14+<p>Founder, Wikipedia</p>
 15+<p>P.S. Wikipedia is about the power of people like us to do extraordinary things. People like us write Wikipedia, one word at a time. People like us fund it, one donation at a time. It's proof of our collective potential to change the world.</p>
 16+<p><br />
 17+</p>
 18+</div>
 19+</td><td id="donate" valign="top">
 20+<noscript><div id="noscript"><p id="noscript-msg">It appears that you do not have JavaScript enabled, or your browser does not support it.
 21+In order to provide a safe, secure and pleasant experience, our donation form requires JavaScript.</p><p id="noscript-redirect-msg">If you cannot or do not wish to enable JavaScript, you may still contribute by visiting:</p><p id="noscript-redirect-link"><a href="http://wikimediafoundation.org/wiki/DonateNonJS/en">http://wikimediafoundation.org/wiki/DonateNonJS/en</a></p></div></noscript>
 22+
 23+<h2 id="donate-head">Make your donation now</h2>
 24+<p class='creditcard-error-msg'>#general</p>
 25+<p class='creditcard-error-msg'>#retryMsg</p>
 26+<form name="payment" method="post" action="/index.php/Special:PayflowProGateway?form_name=RapidHtml&amp;ffname=demo" autocomplete="off">
 27+ <div id="payflowpro_gateway-personal-info"><table id="payflow-table-donor">
 28+ <tr>
 29+ <td colspan=2><span class="creditcard-error-msg">#fname</span></td>
 30+ </tr>
 31+ <tr>
 32+ <td colspan=2><span class="creditcard-error-msg">#lname</span></td>
 33+ </tr>
 34+ <tr>
 35+ <td class="label"><label for="fname">Name</label></td>
 36+ <td>
 37+ <input name="fname" size="30" value="@fname" type="text" onfocus="clearField( this, &#039;First&#039; )" maxlength="25" class="required" id="fname" />
 38+ <input name="lname" size="30" value="@lname" type="text" onfocus="clearField( this, &#039;Last&#039; )" maxlength="25" id="lname" />
 39+ </td>
 40+ </tr>
 41+ <tr>
 42+ <td colspan=2><span class="creditcard-error-msg">#emailAdd</span></td>
 43+ </tr>
 44+ <tr>
 45+ <td class="label"><label for="emailAdd">Email address</label></td>
 46+ <td><input name="emailAdd" size="30" value="@emailAdd" type="text" maxlength="64" id="emailAdd" class="fullwidth" /></td>
 47+ </tr>
 48+ <tr>
 49+ <td colspan="2"><span class="creditcard-error-msg">#amount</span></td>
 50+ </tr>
 51+ <tr>
 52+ <td class="label"><label for="amount">Amount</label></td>
 53+ <td>
 54+ <input name="amount" size="7" value="@amount" type="text" maxlength="10" id="amount" />
 55+ <select name="currency_code" id="input_currency_code">
 56+ <option value="USD">USD: U.S. Dollar</option><option value="GBP">GBP: British Pound</option><option value="EUR">EUR: Euro</option><option value="AUD">AUD: Australian Dollar</option><option value="CAD">CAD: Canadian Dollar</option><option value="JPY">JPY: Japanese Yen</option>
 57+ </select>
 58+ </td>
 59+ </tr>
 60+ <tr>
 61+ <td />
 62+ <td><img src="/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" /></td>
 63+ </tr>
 64+ <tr>
 65+ <td class="label"><label for="card_num">Card number</label></td>
 66+ <td><input name="card_num" size="30" value="@card_num" type="text" maxlength="100" id="card_num" class="fullwidth" autocomplete="off" /></td>
 67+ </tr>
 68+ <tr>
 69+ <td colspan=2><span class="creditcard-error-msg">#cvv</span></td>
 70+ <tr>
 71+ <td class="label"><label for="cvv">Security code</label></td>
 72+ <td><input name="cvv" size="5" value="@cvv" type="text" maxlength="10" id="cvv" autocomplete="off" /> <a href="javascript:PopupCVV();">Where is this?</a></td>
 73+ </tr>
 74+ <tr>
 75+ <td class="label"><label for="expiration">Expiration date</label></td>
 76+ <td>
 77+ <select name="mos" id="expiration">
 78+ <option value="01">1 (January)</option><option value="02">2 (February)</option><option value="03">3 (March)</option><option value="04">4 (April)</option><option value="05">5 (May)</option><option value="06">6 (June)</option><option value="07">7 (July)</option><option value="08">8 (August)</option><option value="09">9 (September)</option><option value="10">10 (October)</option><option value="11">11 (November)</option><option value="12">12 (December)</option>
 79+ </select>
 80+ <select name="year" id="year">
 81+ <option value="2010">2010</option><option value="2011">2011</option><option value="2012">2012</option><option value="2013">2013</option><option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option><option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option><option value="2020">2020</option>
 82+ </select>
 83+ </td>
 84+ </tr>
 85+ <tr>
 86+ <td colspan=2><span class="creditcard-error-msg">#street</span></td>
 87+ </tr>
 88+ <tr>
 89+ <td class="label"><label for="street">Street</label></td>
 90+ <td><input name="street" size="30" value="@street" type="text" maxlength="100" id="street" class="fullwidth" /></td>
 91+ </tr>
 92+ <tr>
 93+ <td colspan=2><span class="creditcard-error-msg">#city</span></td>
 94+ </tr>
 95+ <tr>
 96+ <td class="label"><label for="city">City</label></td>
 97+ <td><input name="city" size="30" value="@city" type="text" maxlength="40" id="city" class="fullwidth" /></td>
 98+ </tr>
 99+ <tr>
 100+ <td colspan=2><span class="creditcard-error-msg">#state</span></td>
 101+ </tr>
 102+ <tr>
 103+ <td class="label"><label for="state">State</label></td>
 104+ <td>
 105+ <select name="state" id="state">
 106+ <option value="YY">Select a State</option><option value="XX">Outside the U.S.</option><option value="AK">Alaska</option><option value="AL">Alabama</option><option value="AR">Arkansas</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DC">Washington D.C.</option><option value="DE">Delaware</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="HI">Hawaii</option><option value="IA">Iowa</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="MA">Massachusetts</option><option value="MD">Maryland</option><option value="ME">Maine</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MO">Missouri</option><option value="MS">Mississippi</option><option value="MT">Montana</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="NE">Nebraska</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NV">Nevada</option><option value="NY">New York</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="PR">Puerto Rico</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VA">Virginia</option><option value="VT">Vermont</option><option value="WA">Washington</option><option value="WI">Wisconsin</option><option value="WV">West Virginia</option><option value="WY">Wyoming</option><option value="AA">AA</option><option value="AE">AE</option><option value="AP">AP</option>
 107+ </select>
 108+ </td>
 109+ </tr>
 110+ <tr>
 111+ <td colspan=2><span class="creditcard-error-msg">#zip</span></td>
 112+ </tr>
 113+ <tr>
 114+ <td class="label"><label for="zip">Postal code</label></td>
 115+ <td><input name="zip" size="30" value="@zip" type="text" maxlength="9" id="zip" class="fullwidth" /></td>
 116+ </tr>
 117+ <tr>
 118+ <td colspan=2><span class="creditcard-error-msg">#country</span></td>
 119+ </tr>
 120+ <tr>
 121+ <td class="label"><label for="country">Country/Region</label></td>
 122+ <td>
 123+ <select name="country" id="country" onchange="return disableStates( this )">
 124+ <option value="004">Afghanistan</option><option value="008">Albania</option><option value="012">Algeria</option><option value="016">American Samoa</option><option value="020">Andorra</option><option value="024">Angola</option><option value="660">Anguilla</option><option value="010">Antarctica</option><option value="028">Antigua and Barbuda</option><option value="032">Argentina</option><option value="051">Armenia</option><option value="533">Aruba</option><option value="036">Australia</option><option value="040">Austria</option><option value="031">Azerbaijan</option><option value="044">Bahamas</option><option value="048">Bahrain</option><option value="050">Bangladesh</option><option value="052">Barbados</option><option value="112">Belarus</option><option value="056">Belgium</option><option value="084">Belize</option><option value="204">Benin</option><option value="060">Bermuda</option><option value="064">Bhutan</option><option value="068">Bolivia, Plurinational State of</option><option value="070">Bosnia and Herzegovina</option><option value="072">Botswana</option><option value="074">Bouvet Island</option><option value="076">Brazil</option><option value="086">British Indian Ocean Territory</option><option value="096">Brunei Darussalam</option><option value="100">Bulgaria</option><option value="854">Burkina Faso</option><option value="108">Burundi</option><option value="116">Cambodia</option><option value="120">Cameroon</option><option value="124">Canada</option><option value="132">Cape Verde</option><option value="136">Cayman Islands</option><option value="140">Central African Republic</option><option value="148">Chad</option><option value="152">Chile</option><option value="156">China</option><option value="162">Christmas Island</option><option value="166">Cocos (Keeling) Islands</option><option value="017">Colombia</option><option value="174">Comoros</option><option value="178">Congo</option><option value="180">Congo, the Democratic Republic of the</option><option value="184">Cook Islands</option><option value="188">Costa Rica</option><option value="384">Cote D'Ivoire</option><option value="191">Croatia</option><option value="192">Cuba</option><option value="196">Cyprus</option><option value="203">Czech Republic</option><option value="208">Denmark</option><option value="262">Djibouti</option><option value="212">Dominica</option><option value="214">Dominican Republic</option><option value="626">East Timor</option><option value="218">Ecuador</option><option value="818">Egypt</option><option value="222">El Salvador</option><option value="226">Equatorial Guinea</option><option value="232">Eritrea</option><option value="233">Estonia</option><option value="231">Ethiopia</option><option value="238">Falkland Islands (Malvinas)</option><option value="234">Faroe Islands</option><option value="242">Fiji</option><option value="246">Finland</option><option value="250">France</option><option value="254">French Guiana</option><option value="258">French Polynesia</option><option value="260">French Southern Territories</option><option value="266">Gabon</option><option value="270">Gambia</option><option value="268">Georgia</option><option value="276">Germany</option><option value="288">Ghana</option><option value="292">Gibraltar</option><option value="300">Greece</option><option value="304">Greenland</option><option value="308">Grenada</option><option value="312">Guadeloupe</option><option value="316">Guam</option><option value="320">Guatemala</option><option value="324">Guinea</option><option value="624">Guinea-Bissau</option><option value="328">Guyana</option><option value="332">Haiti</option><option value="334">Heard Island and McDonald Islands</option><option value="340">Honduras</option><option value="344">Hong Kong</option><option value="348">Hungary</option><option value="352">Iceland</option><option value="356">India</option><option value="360">Indonesia</option><option value="364">Iran, Islamic Republic of</option><option value="368">Iraq</option><option value="372">Ireland</option><option value="376">Israel</option><option value="380">Italy</option><option value="388">Jamaica</option><option value="392">Japan</option><option value="400">Jordan</option><option value="398">Kazakhstan</option><option value="404">Kenya</option><option value="296">Kiribati</option><option value="408">Korea, Democratic People's Republic of</option><option value="410">Korea, Republic of</option><option value="414">Kuwait</option><option value="417">Kyrgyzstan</option><option value="418">Laos</option><option value="428">Latvia</option><option value="422">Lebanon</option><option value="426">Lesotho</option><option value="430">Liberia</option><option value="434">Libyan Arab Jamahiriya</option><option value="438">Liechtenstein</option><option value="440">Lithuania</option><option value="442">Luxembourg</option><option value="446">Macao</option><option value="807">Macedonia</option><option value="450">Madagascar</option><option value="454">Malawi</option><option value="458">Malaysia</option><option value="462">Maldives</option><option value="466">Mali</option><option value="470">Malta</option><option value="584">Marshall Islands</option><option value="474">Martinique</option><option value="478">Mauritania</option><option value="480">Mauritius</option><option value="175">Mayotte</option><option value="484">Mexico</option><option value="583">Micronesia, Federated States of</option><option value="498">Moldova, Republic of</option><option value="492">Monaco</option><option value="496">Mongolia</option><option value="499">Montenegro</option><option value="500">Montserrat</option><option value="504">Morocco</option><option value="508">Mozambique</option><option value="104">Myanmar</option><option value="516">Namibia</option><option value="520">Nauru</option><option value="524">Nepal</option><option value="528">Netherlands</option><option value="530">Netherlands Antilles</option><option value="540">New Caledonia</option><option value="554">New Zealand</option><option value="558">Nicaragua</option><option value="562">Niger</option><option value="566">Nigeria</option><option value="570">Niue</option><option value="574">Norfolk Island</option><option value="580">Northern Mariana Islands</option><option value="578">Norway</option><option value="512">Oman</option><option value="586">Pakistan</option><option value="585">Palau</option><option value="591">Panama</option><option value="598">Papua New Guinea</option><option value="600">Paraguay</option><option value="604">Peru</option><option value="608">Philippines</option><option value="612">Pitcairn</option><option value="616">Poland</option><option value="620">Portugal</option><option value="630">Puerto Rico</option><option value="634">Qatar</option><option value="642">Romania</option><option value="643">Russian Federation</option><option value="646">Rwanda</option><option value="654">Saint Helena</option><option value="659">Saint Kitts and Nevis</option><option value="662">Saint Lucia</option><option value="666">Saint Pierre and Miquelon</option><option value="670">Saint Vincent and the Grenadines</option><option value="674">San Marino</option><option value="678">Sao Tome and Principe</option><option value="682">Saudi Arabia</option><option value="686">Senegal</option><option value="688">Serbia</option><option value="690">Seychelles</option><option value="694">Sierra Leone</option><option value="702">Singapore</option><option value="703">Slovakia</option><option value="705">Slovenia</option><option value="090">Solomon Islands</option><option value="706">Somalia</option><option value="710">South Africa</option><option value="724">Spain</option><option value="144">Sri Lanka</option><option value="736">Sudan</option><option value="740">Suriname</option><option value="744">Svalbard and Jan Mayen</option><option value="748">Swaziland</option><option value="752">Sweden</option><option value="756">Switzerland</option><option value="760">Syrian Arab Republic</option><option value="158">Taiwan</option><option value="762">Tajikistan</option><option value="834">Tanzania, United Republic of</option><option value="764">Thailand</option><option value="768">Togo</option><option value="772">Tokelau</option><option value="776">Tonga</option><option value="780">Trinidad and Tobago</option><option value="788">Tunisia</option><option value="792">Turkey</option><option value="795">Turkmenistan</option><option value="796">Turks and Caicos Islands</option><option value="798">Tuvalu</option><option value="800">Uganda</option><option value="804">Ukraine</option><option value="784">United Arab Emirates</option><option value="826">United Kingdom</option><option value="840">United States</option><option value="581">United States Minor Outlying Islands</option><option value="858">Uruguay</option><option value="860">Uzbekistan</option><option value="548">Vanuatu</option><option value="336">Vatican City State</option><option value="862">Venezuela, Bolivarian Republic of</option><option value="704">Viet Nam</option><option value="092">Virgin Islands, British</option><option value="850">Virgin Islands, U.S.</option><option value="876">Wallis and Futuna</option><option value="732">Western Sahara</option><option value="882">Western Samoa</option><option value="887">Yemen</option><option value="894">Zambia</option><option value="716">Zimbabwe</option>
 125+ </select>
 126+ </td>
 127+ </tr>
 128+ </table>
 129+ </div>
 130+ <!-- captcha -->
 131+ @captcha
 132+ <!-- end captcha -->
 133+ <div id="payflowpro_gateway-form-submit">
 134+ <div id="mw-donate-submit-button">
 135+ <input class="button-plain" value="Donate by Credit Card" type="submit" />
 136+ </div>
 137+ <div class="mw-donate-submessage" id="payflowpro_gateway-donate-submessage">
 138+ Your credit card will be securely processed.
 139+ </div>
 140+ </div>
 141+ <input type="hidden" value="@utm_source" name="utm_source" />
 142+ <input type="hidden" value="@utm_medium" name="utm_medium" />
 143+ <input type="hidden" value="@utm_campaign" name="utm_campaign" />
 144+ <input type="hidden" value="@language" name="language" />
 145+ <input type="hidden" value="@referrer" name="referrer" />
 146+ <input type="hidden" value="@comment" name="comment" />
 147+ <input type="hidden" value="@comment-option" name="comment-option" />
 148+ <input type="hidden" value="@email-opt" name="email-opt" />
 149+ <input type="hidden" value="CreditCard" name="process" />
 150+ <input type="hidden" value="processed" name="payment_method" />
 151+ <input type="hidden" value="@token" name="token" />
 152+ <input type="hidden" value="@order_id" name="order_id" />
 153+ <input type="hidden" value="@numAttempt" name="numAttempt" />
 154+ <input type="hidden" value="@contribution_tracking_id" name="contribution_tracking_id" />
 155+ <input type="hidden" value="@data_hash" name="data_hash" />
 156+ <input type="hidden" value="@action" name="action" />
 157+ <input type="hidden" value="@owa_session" name="owa_session" />
 158+ <input type="hidden" value="@owa_ref" name="owa_ref" />
 159+</form>
 160+<div class="payflow-cc-form-section" id="payflowpro_gateway-donate-addl-info"><div id="payflowpro_gateway-donate-addl-info-secure-logos"><p class=""><img src="/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate-nonanimated.png"></p></div><div id="payflowpro_gateway-donate-addl-info-text"><p class=""><a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">Other ways to give</a></p><p class="">We do not store your credit card information, and your personal data is subject to our <a href="http://wikimediafoundation.org/wiki/Donor_Privacy_Policy">privacy policy</a>.</p><p class="">Questions or comments? Contact: <a href="mailto:donate@wikimedia.org">donate@wikimedia.org</a></p></div></div></td></tr></table><div class="printfooter">
 161+
 162+Retrieved from "<a href="https://payments.wikimedia.org/index.php/Special:PayflowProGateway">https://payments.wikimedia.org/index.php/Special:PayflowProGateway</a>"</div>
 163+
\ No newline at end of file
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
@@ -20,7 +20,7 @@
2121 * Holds the GlobalCollect response from a transaction
2222 * @var array
2323 */
24 - public $payflow_response = array();
 24+ public $payflow_response = array( );
2525
2626 /**
2727 * A container for the form class
@@ -34,7 +34,7 @@
3535 * An array of form errors
3636 * @var array
3737 */
38 - public $errors = array();
 38+ public $errors = array( );
3939
4040 /**
4141 * Constructor - set up the new special page
@@ -42,9 +42,7 @@
4343 public function __construct() {
4444 parent::__construct( 'GlobalCollectGateway' );
4545 $this->errors = $this->getPossibleErrors();
46 -
47 - $dir = dirname( __FILE__ ) . '/';
48 - require_once($dir . 'globalcollect.adapter.php');
 46+
4947 $this->adapter = new GlobalCollectAdapter();
5048 }
5149
@@ -55,7 +53,7 @@
5654 */
5755 public function execute( $par ) {
5856 global $wgRequest, $wgOut, $wgExtensionAssetsPath,
59 - $wgPayFlowProGatewayCSSVersion;
 57+ $wgPayFlowProGatewayCSSVersion;
6058
6159 $wgOut->addExtensionStyle(
6260 $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/gateway.css?284' .
@@ -83,29 +81,28 @@
8482 $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
8583
8684 // @fixme can this be moved into the form generators?
87 - $js = <<<EOT
 85+ $js = <<<EOT
8886 <script type="text/javascript">
8987 jQuery(document).ready(function() {
9088 jQuery("div#p-logo a").attr("href","#");
9189 });
9290 </script>
9391 EOT;
94 - $wgOut->addHeadItem( 'logolinkoverride', $js );
 92+ $wgOut->addHeadItem( 'logolinkoverride', $js );
9593
96 - $this->setHeaders();
97 -
 94+ $this->setHeaders();
 95+
9896 //TODO: This is short-circuiting what I really want to do here.
9997 //so stop it.
10098 $data = $this->adapter->getDisplayData();
101 -
 99+
102100 // dispatch forms/handling
103101 if ( $this->adapter->checkTokens() ) {
104102 if ( $this->adapter->posted && $data['payment_method'] == 'processed' ) {
105 - $this->adapter->log("Posted and processed.");
106 -
 103+ $this->adapter->log( "Posted and processed." );
 104+
107105 // increase the count of attempts
108106 //++$data['numAttempt'];
109 -
110107 // Check form for errors and redisplay with messages
111108 $form_errors = $this->fnPayflowValidateForm( $data, $this->errors );
112109
@@ -113,32 +110,28 @@
114111 $this->fnPayflowDisplayForm( $data, $this->errors );
115112 } else { // The submitted form data is valid, so process it
116113 // allow any external validators to have their way with the data
117 -
118 -
119 -
120 -
121114 $result = $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' );
122115 //$result = $this->adapter->do_transaction( 'TEST_CONNECTION' );
123 -
124 - $wgOut->addHTML($result['message']);
125 - if (!empty($result['errors'])){
126 - $wgOut->addHTML("<ul>");
127 - foreach ($result['errors'] as $code => $value){
128 - $wgOut->addHTML("<li>Error $code: $value");
 116+
 117+ $wgOut->addHTML( $result['message'] );
 118+ if ( !empty( $result['errors'] ) ) {
 119+ $wgOut->addHTML( "<ul>" );
 120+ foreach ( $result['errors'] as $code => $value ) {
 121+ $wgOut->addHTML( "<li>Error $code: $value" );
129122 }
130 - $wgOut->addHTML("</ul>");
 123+ $wgOut->addHTML( "</ul>" );
131124 }
132 -
133 - if (!empty($result['data'])){
134 - $wgOut->addHTML("<ul>");
135 - foreach ($result['data'] as $key => $value){
136 - $wgOut->addHTML("<li>$key: $value");
 125+
 126+ if ( !empty( $result['data'] ) ) {
 127+ $wgOut->addHTML( "<ul>" );
 128+ foreach ( $result['data'] as $key => $value ) {
 129+ $wgOut->addHTML( "<li>$key: $value" );
137130 }
138 - $wgOut->addHTML("</ul>");
 131+ $wgOut->addHTML( "</ul>" );
139132 }
140 -
141 -
142 -
 133+
 134+
 135+
143136 // self::log( $data[ 'order_id' ] . " Preparing to query MaxMind" );
144137 // wfRunHooks( 'PayflowGatewayValidate', array( &$this, &$data ) );
145138 // self::log( $data[ 'order_id' ] . ' Finished querying Maxmind' );
@@ -176,9 +169,9 @@
177170 }
178171 } else {
179172 // Display form for the first time
180 - $this->adapter->log("Not posted, or not processed. Showing the form for the first time.");
 173+ $this->adapter->log( "Not posted, or not processed. Showing the form for the first time." );
181174 $this->fnPayflowDisplayForm( $data, $this->errors );
182 - }
 175+ }
183176 } else {
184177 if ( !$this->adapter->isCache() ) {
185178 // if we're not caching, there's a token mismatch
@@ -187,7 +180,6 @@
188181 $this->fnPayflowDisplayForm( $data, $this->errors );
189182 }
190183 }
191 -
192184
193185 /**
194186 * Build and display form to user
@@ -210,7 +202,7 @@
211203 // }
212204
213205 $form_class = $this->getFormClass();
214 - $form_obj = new $form_class( $data, $error );
 206+ $form_obj = new $form_class( $data, $error, $this->adapter );
215207 $form = $form_obj->getForm();
216208 $wgOut->addHTML( $form );
217209 }
@@ -245,7 +237,7 @@
246238 * Using logic in setFormClass()
247239 * @return string
248240 */
249 - public function getFormClass( ) {
 241+ public function getFormClass() {
250242 if ( !isset( $this->form_class ) ) {
251243 $this->setFormClass();
252244 }
@@ -257,7 +249,7 @@
258250 */
259251 private function fnPayflowValidateForm( &$data, &$error ) {
260252 global $wgPayflowProGatewayPriceFloor, $wgPayflowProGatewayPriceCeiling;
261 -
 253+
262254 // begin with no errors
263255 $error_result = '0';
264256
@@ -279,7 +271,7 @@
280272
281273 // find all empty fields and create message
282274 foreach ( $data as $key => $value ) {
283 - if ( $value == '' || ($key == 'state' && $value == 'YY' )) {
 275+ if ( $value == '' || ($key == 'state' && $value == 'YY' ) ) {
284276 // ignore fields that are not required
285277 if ( isset( $msg[$key] ) ) {
286278 $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />";
@@ -289,9 +281,9 @@
290282 }
291283
292284 // check amount
293 - if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data[ 'amount' ] ) ||
294 - ( (float) $this->convert_to_usd( $data[ 'currency' ], $data[ 'amount' ] ) < (float) $wgPayflowProGatewayPriceFloor ||
295 - (float) $this->convert_to_usd( $data[ 'currency' ], $data[ 'amount' ] ) > (float) $wgPayflowProGatewayPriceCeiling ) ) {
 285+ if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data['amount'] ) ||
 286+ ( ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) < ( float ) $wgPayflowProGatewayPriceFloor ||
 287+ ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) > ( float ) $wgPayflowProGatewayPriceCeiling ) ) {
296288 $error['invalidamount'] = wfMsg( 'payflowpro_gateway-error-msg-invalid-amount' );
297289 $error_result = '1';
298290 }
@@ -306,20 +298,20 @@
307299 }
308300
309301 // validate that credit card number entered is correct and set the card type
310 - if ( preg_match( '/^3[47][0-9]{13}$/', $data[ 'card_num' ] ) ) { // american express
311 - $data[ 'card' ] = 'american';
312 - } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data[ 'card_num' ] ) ) { // mastercard
313 - $data[ 'card' ] = 'mastercard';
314 - } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data[ 'card_num' ] ) ) {// visa
315 - $data[ 'card' ] = 'visa';
316 - } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data[ 'card_num' ] ) ) { // discover
317 - $data[ 'card' ] = 'discover';
 302+ if ( preg_match( '/^3[47][0-9]{13}$/', $data['card_num'] ) ) { // american express
 303+ $data['card'] = 'american';
 304+ } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data['card_num'] ) ) { // mastercard
 305+ $data['card'] = 'mastercard';
 306+ } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data['card_num'] ) ) {// visa
 307+ $data['card'] = 'visa';
 308+ } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data['card_num'] ) ) { // discover
 309+ $data['card'] = 'discover';
318310 } else { // an invalid credit card number was entered
319 - //TODO: Make sure this is uncommented when you commit for reals!
 311+ //TODO: Make sure this is uncommented when you commit for reals!
320312 //$error_result = '1';
321313 //$error[ 'card_num' ] = wfMsg( 'payflowpro_gateway-error-msg-card-num' );
322314 }
323 -
 315+
324316 return $error_result;
325317 }
326318
@@ -333,18 +325,18 @@
334326 */
335327 private function fnPayflowGetResults( $data, $result ) {
336328 // prepare NVP response for sorting and outputting
337 - $responseArray = array();
 329+ $responseArray = array( );
338330
339331 /**
340332 * The result response string looks like:
341 - * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1
 333+ * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1
342334 * We want to turn this into an array of key value pairs, so explode on '&' and then
343335 * split up the resulting strings into $key => $value
344336 */
345337 $result_arr = explode( "&", $result );
346338 foreach ( $result_arr as $result_pair ) {
347339 list( $key, $value ) = preg_split( "/=/", $result_pair );
348 - $responseArray[ $key ] = $value;
 340+ $responseArray[$key] = $value;
349341 }
350342
351343 // store the response array as an object property for easy retrival/manipulation elsewhere
@@ -360,33 +352,34 @@
361353 // interpret result code, return
362354 // approved (1), denied (2), try again (3), general error (4)
363355 $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg );
364 -
 356+
365357 // log that the transaction is essentially complete
366 - self::log( $data[ 'order_id' ] . " Transaction complete." );
367 -
 358+ self::log( $data['order_id'] . " Transaction complete." );
 359+
368360 // if approved, display results and send transaction to the queue
369361 if ( $errorCode == '1' ) {
370 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction approved.", 'globalcollect_gateway', LOG_DEBUG );
 362+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction approved.", 'globalcollect_gateway', LOG_DEBUG );
371363 $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg );
372364 // give user a second chance to enter incorrect data
373365 } elseif ( ( $errorCode == '3' ) && ( $data['numAttempt'] < '5' ) ) {
374 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction unsuccessful (invalid info).", 'globalcollect_gateway', LOG_DEBUG );
 366+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction unsuccessful (invalid info).", 'globalcollect_gateway', LOG_DEBUG );
375367 // pass responseMsg as an array key as required by displayForm
376368 $this->errors['retryMsg'] = $responseMsg;
377369 $this->fnPayflowDisplayForm( $data, $this->errors );
378370 // if declined or if user has already made two attempts, decline
379371 } elseif ( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '3' ) ) {
380 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction declined.", 'globalcollect_gateway', LOG_DEBUG );
 372+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction declined.", 'globalcollect_gateway', LOG_DEBUG );
381373 $this->fnPayflowDisplayDeclinedResults( $responseMsg );
382374 } elseif ( ( $errorCode == '4' ) ) {
383 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction unsuccessful.", 'globalcollect_gateway', LOG_DEBUG );
 375+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction unsuccessful.", 'globalcollect_gateway', LOG_DEBUG );
384376 $this->fnPayflowDisplayOtherResults( $responseMsg );
385377 } elseif ( ( $errorCode == '5' ) ) {
386 - self::log( $data[ 'order_id' ] . " " . $data[ 'i_order_id' ] . " Transaction pending.", 'globalcollect_gateway', LOG_DEBUG );
 378+ self::log( $data['order_id'] . " " . $data['i_order_id'] . " Transaction pending.", 'globalcollect_gateway', LOG_DEBUG );
387379 $this->fnPayflowDisplayPending( $data, $responseArray, $responseMsg );
388380 }
 381+ }
389382
390 - }// end display results
 383+// end display results
391384
392385 /**
393386 * Interpret response code, return
@@ -398,7 +391,7 @@
399392 function fnPayflowGetResponseMsg( $resultCode, &$responseMsg ) {
400393 $responseMsg = wfMsg( 'globalcollect_gateway-response-default' );
401394
402 - switch( $resultCode ) {
 395+ switch ( $resultCode ) {
403396 case '0':
404397 $responseMsg = wfMsg( 'globalcollect_gateway-response-0' );
405398 $errorCode = '1';
@@ -457,25 +450,25 @@
458451 */
459452 public function prepareStompTransaction( $data, $responseArray, $responseMsg ) {
460453 $countries = $this->getCountries();
461 -
462 - $transaction = array();
463454
 455+ $transaction = array( );
 456+
464457 // include response message
465458 $transaction['response'] = $responseMsg;
466 -
 459+
467460 // include date
468461 $transaction['date'] = time();
469 -
 462+
470463 // put all data into one array
471464 $optout = $this->determineOptOut( $data );
472 - $data[ 'anonymous' ] = $optout[ 'anonymous' ];
473 - $data[ 'optout' ] = $optout[ 'optout' ];
474 -
 465+ $data['anonymous'] = $optout['anonymous'];
 466+ $data['optout'] = $optout['optout'];
 467+
475468 $transaction += array_merge( $data, $responseArray );
476 -
 469+
477470 return $transaction;
478471 }
479 -
 472+
480473 /**
481474 * Fetch an array of country abbrevs => country names
482475 */
@@ -483,7 +476,7 @@
484477 require_once( 'includes/countryCodes.inc' );
485478 return countryCodes();
486479 }
487 -
 480+
488481 /**
489482 * Display response message to user with submitted user-supplied data
490483 *
@@ -600,7 +593,6 @@
601594 );
602595 }
603596
604 -
605597 /**
606598 * Handle redirection of form content to PayPal
607599 *
@@ -614,42 +606,42 @@
615607
616608 // if we don't have a URL enabled throw a graceful error to the user
617609 if ( !strlen( $wgPayflowProGatewayPaypalURL ) ) {
618 - $this->errors['general'][ 'nopaypal' ] = wfMsg( 'payflow_gateway-error-msg-nopaypal' );
 610+ $this->errors['general']['nopaypal'] = wfMsg( 'payflow_gateway-error-msg-nopaypal' );
619611 return;
620612 }
621613
622614 // update the utm source to set the payment instrument to pp rather than cc
623 - $utm_source_parts = explode( ".", $data[ 'utm_source' ] );
 615+ $utm_source_parts = explode( ".", $data['utm_source'] );
624616 $utm_source_parts[2] = 'pp';
625 - $data[ 'utm_source' ] = implode( ".", $utm_source_parts );
626 - $data[ 'gateway' ] = 'paypal';
627 - $data[ 'currency_code' ] = $data[ 'currency' ];
 617+ $data['utm_source'] = implode( ".", $utm_source_parts );
 618+ $data['gateway'] = 'paypal';
 619+ $data['currency_code'] = $data['currency'];
628620 /**
629621 * update contribution tracking
630622 */
631623 $this->updateContributionTracking( $data, true );
632624
633 - $wgPayflowProGatewayPaypalURL .= "/" . $data[ 'language' ] . "?gateway=paypal";
634 -
 625+ $wgPayflowProGatewayPaypalURL .= "/" . $data['language'] . "?gateway=paypal";
 626+
635627 // submit the data to the paypal redirect URL
636628 $wgOut->redirect( $wgPayflowProGatewayPaypalURL . '&' . http_build_query( $data ) );
637629 }
638 -
 630+
639631 public static function log( $msg, $identifier='globalcollect_gateway', $log_level=LOG_INFO ) {
640632 global $wgGlobalCollectGatewayUseSyslog;
641 -
 633+
642634 // if we're not using the syslog facility, use wfDebugLog
643635 if ( !$wgGlobalCollectGatewayUseSyslog ) {
644636 wfDebugLog( $identifier, $msg );
645637 return;
646638 }
647 -
 639+
648640 // otherwise, use syslogging
649641 openlog( $identifier, LOG_ODELAY, LOG_SYSLOG );
650642 syslog( $log_level, $msg );
651 - closelog();
 643+ closelog();
652644 }
653 -
 645+
654646 /**
655647 * Convert an amount for a particular currency to an amount in USD
656648 *
@@ -724,7 +716,10 @@
725717 $usd_amount = $amount;
726718 break;
727719 }
728 -
 720+
729721 return $usd_amount;
730722 }
731 -} // end class
 723+
 724+}
 725+
 726+// end class
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -1,37 +1,28 @@
22 <?php
33
4 -$dir = dirname( __FILE__ ) . '/';
5 -require_once( $dir . '../gateway_common/gateway.adapter.php' );
6 -
74 class GlobalCollectAdapter extends GatewayAdapter {
8 - const gatewayname = 'Global Collect';
9 - const identifier = 'globalcollect';
10 - const communicationtype = 'xml';
11 - const globalprefix = 'wgGlobalCollectGateway';
 5+ const GATEWAY_NAME = 'Global Collect';
 6+ const IDENTIFIER = 'globalcollect';
 7+ const COMMUNICATION_TYPE = 'xml';
 8+ const GLOBAL_PREFIX = 'wgGlobalCollectGateway';
129
1310 /**
1411 * stageData should alter the postdata array in all ways necessary in preparation for
1512 * communication with the gateway.
1613 */
17 - function stageData(){
 14+ function stageData() {
1815 $this->postdata['amount'] = $this->postdata['amount'] * 100;
1916 }
20 -
2117
22 - function __construct( ) {
23 - $this->classlocation = __FILE__;
24 - parent::__construct();
25 - }
26 -
27 - function defineAccountInfo(){
 18+ function defineAccountInfo() {
2819 $this->accountInfo = array(
29 - 'MERCHANTID' => self::getGlobal('MerchantID'),
 20+ 'MERCHANTID' => self::getGlobal( 'MerchantID' ),
3021 //'IPADDRESS' => '', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm.
3122 'VERSION' => "1.0",
3223 );
3324 }
34 -
35 - function defineVarMap(){
 25+
 26+ function defineVarMap() {
3627 $this->var_map = array(
3728 'ORDERID' => 'order_id',
3829 'AMOUNT' => 'amount',
@@ -43,17 +34,17 @@
4435 'IPADDRESS' => 'user_ip', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm.
4536 );
4637 }
47 -
48 - function defineReturnValueMap(){
 38+
 39+ function defineReturnValueMap() {
4940 $this->return_value_map = array(
5041 'OK' => true,
5142 'NOK' => false,
5243 );
5344 }
54 -
55 - function defineTransactions(){
56 - $this->transactions = array();
57 -
 45+
 46+ function defineTransactions() {
 47+ $this->transactions = array( );
 48+
5849 $this->transactions['INSERT_ORDERWITHPAYMENT'] = array(
5950 'request' => array(
6051 'REQUEST' => array(
@@ -90,7 +81,7 @@
9182 'PAYMENTPRODUCTID' => '3',
9283 ),
9384 );
94 -
 85+
9586 $this->transactions['TEST_CONNECTION'] = array(
9687 'request' => array(
9788 'REQUEST' => array(
@@ -114,19 +105,19 @@
115106 * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off.
116107 * return a string.
117108 */
118 - function getFormattedResponse( $rawResponse ){
119 - $xmlString = $this->stripXMLResponseHeaders($rawResponse);
 109+ function getFormattedResponse( $rawResponse ) {
 110+ $xmlString = $this->stripXMLResponseHeaders( $rawResponse );
120111 $displayXML = $this->formatXmlString( $xmlString );
121112 $realXML = new DomDocument( '1.0' );
122113 self::log( "Here is the Raw XML: " . $displayXML ); //I am apparently a huge fibber.
123114 $realXML->loadXML( trim( $xmlString ) );
124115 return $realXML;
125116 }
126 -
 117+
127118 /**
128119 * Parse the response to get the status. Not sure if this should return a bool, or something more... telling.
129120 */
130 - function getResponseStatus( $response ){
 121+ function getResponseStatus( $response ) {
131122
132123 $aok = true;
133124
@@ -135,24 +126,24 @@
136127 $aok = false;
137128 }
138129 }
139 -
140 - return $aok;
 130+
 131+ return $aok;
141132 }
142 -
 133+
143134 /**
144135 * Parse the response to get the errors in a format we can log and otherwise deal with.
145136 * return a key/value array of codes (if they exist) and messages.
146137 */
147 - function getResponseErrors( $response ){
148 - $errors = array();
 138+ function getResponseErrors( $response ) {
 139+ $errors = array( );
149140 foreach ( $response->getElementsByTagName( 'ERROR' ) as $node ) {
150141 $code = '';
151142 $message = '';
152143 foreach ( $node->childNodes as $childnode ) {
153 - if ($childnode->nodeName === "CODE"){
 144+ if ( $childnode->nodeName === "CODE" ) {
154145 $code = $childnode->nodeValue;
155146 }
156 - if ($childnode->nodeName === "MESSAGE"){
 147+ if ( $childnode->nodeName === "MESSAGE" ) {
157148 $message = $childnode->nodeValue;
158149 }
159150 }
@@ -160,24 +151,24 @@
161152 }
162153 return $errors;
163154 }
164 -
 155+
165156 /**
166157 * Harvest the data we need back from the gateway.
167158 * return a key/value array
168159 */
169 - function getResponseData( $response ){
170 - $data = array();
 160+ function getResponseData( $response ) {
 161+ $data = array( );
171162 foreach ( $response->getElementsByTagName( 'ROW' ) as $node ) {
172163 foreach ( $node->childNodes as $childnode ) {
173 - if (trim($childnode->nodeValue) != ''){
 164+ if ( trim( $childnode->nodeValue ) != '' ) {
174165 $data[$childnode->nodeName] = $childnode->nodeValue;
175166 }
176167 }
177168 }
178 - self::log( "Returned Data: " . print_r($data, true));
 169+ self::log( "Returned Data: " . print_r( $data, true ) );
179170 return $data;
180171 }
181 -
 172+
182173 function processResponse( $response ) {
183174 //TODO: Stuff.
184175 }
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php
@@ -23,6 +23,7 @@
2424 // Set up the new special page
2525 $dir = dirname( __FILE__ ) . '/';
2626 $wgAutoloadClasses['GlobalCollectGateway'] = $dir . 'globalcollect_gateway.body.php';
 27+$wgAutoloadClasses['GlobalCollectAdapter'] = $dir . 'globalcollect.adapter.php';
2728 $wgExtensionMessagesFiles['GlobalCollectGateway'] = $dir . '../payflowpro_gateway/payflowpro_gateway.i18n.php';
2829 $wgExtensionMessagesFiles['GlobalCollectGatewayCountries'] = $dir . '../payflowpro_gateway/payflowpro_gateway.countries.i18n.php';
2930 $wgExtensionMessagesFiles['GlobalCollectGatewayUSStates'] = $dir . '../payflowpro_gateway/payflowpro_gateway.us-states.i18n.php';
@@ -54,10 +55,6 @@
5556 */
5657 $wgGlobalCollectGatewaySalt = $wgSecretKey;
5758
58 -$wgGlobalCollectGatewayDBserver = $wgDBserver;
59 -$wgGlobalCollectGatewayDBname = $wgDBname;
60 -$wgGlobalCollectGatewayDBuser = $wgDBuser;
61 -$wgGlobalCollectGatewayDBpassword = $wgDBpassword;
6259
6360 /**
6461 * A string that can contain wikitext to display at the head of the credit card form
@@ -99,7 +96,7 @@
10097 * Directory for HTML forms (used by RapidHtml form class)
10198 * @var string
10299 */
103 -$wgGlobalCollectGatewayHtmlFormDir = dirname( __FILE__ ) . "/../gateway_forms/html";
 100+$wgGlobalCollectGatewayHtmlFormDir = dirname( __FILE__ ) . "/forms/html";
104101
105102 /**
106103 * An array of allowed HTML forms.
@@ -108,7 +105,7 @@
109106 * /never/ be loaded by the rapid html form loader!
110107 * @var string
111108 */
112 -$wgGlobalCollectGatewayAllowedHtmlForms = array( $wgGlobalCollectGatewayHtmlFormDir . "/demo.html" );
 109+$wgGlobalCollectGatewayAllowedHtmlForms = $wgDonationInterfaceAllowedHtmlForms;
113110
114111 /**
115112 * Configure price cieling and floor for valid contribution amount. Values
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -9,36 +9,36 @@
1010 * return a string.
1111 */
1212 function getFormattedResponse( $rawResponse );
13 -
 13+
1414 /**
1515 * Parse the response to get the status. Not sure if this should return a bool, or something more... telling.
1616 */
1717 function getResponseStatus( $response );
18 -
 18+
1919 /**
2020 * Parse the response to get the errors in a format we can log and otherwise deal with.
2121 * return a key/value array of codes (if they exist) and messages.
2222 */
2323 function getResponseErrors( $response );
24 -
 24+
2525 /**
2626 * Harvest the data we need back from the gateway.
2727 * return a key/value array
2828 */
2929 function getResponseData( $response );
30 -
 30+
3131 /**
3232 * Actually do... stuff. Here.
3333 * TODO: Better comment.
3434 * Process the entire response gott'd by the last four functions.
3535 */
3636 function processResponse( $response );
37 -
 37+
3838 /**
3939 * Anything we need to do to the data coming in, before we send it off.
4040 */
4141 function stageData();
42 -
 42+
4343 /**
4444 * defineTransactions will define the $transactions array.
4545 * The array will contain everything we need to know about the request structure for all the transactions we care about,
@@ -46,25 +46,25 @@
4747 * First array key: Some way for us to id the transaction. Doesn't actually have to be the gateway's name for it, but I'm going with that until I have a reason not to.
4848 * Second array key:
4949 * 'request' contains the structure of that request. Leaves in the array tree will eventually be mapped to actual values of ours,
50 - * according to the precidence established in the getValue function.
 50+ * according to the precidence established in the getValue function.
5151 * 'values' contains default values for the transaction. Things that are typically not overridden should go here.
5252 */
5353 function defineTransactions();
54 -
 54+
5555 /**
5656 * defineVarMap needs to set up the $var_map array.
5757 * Keys = the name (or node name) value in the gateway transaction
5858 * Values = the mediawiki field name for the corresponding piece of data.
5959 */
6060 function defineVarMap();
61 -
 61+
6262 /**
6363 * defineAccountInfo needs to set up the $accountInfo array.
6464 * Keys = the name (or node name) value in the gateway transaction
6565 * Values = The actual values for those keys. Probably have to access a global or two. (use getGlobal()!)
6666 */
6767 function defineAccountInfo();
68 -
 68+
6969 /**
7070 * defineReturnValueMap sets up the $return_value_map array.
7171 * Keys = The different constants that may be contained as values in the gateway's response.
@@ -88,47 +88,45 @@
8989 protected $dataObj;
9090
9191 //ALL OF THESE need to be redefined in the children. Much voodoo depends on the accuracy of these constants.
92 - const gatewayname = 'Donation Gateway';
93 - const identifier = 'donation';
94 - const communicationtype = 'xml'; //this needs to be either 'xml' or 'namevalue'
95 - const globalprefix = 'wgDonationGateway'; //...for example.
96 -
97 - function __construct(){
 92+ const GATEWAY_NAME = 'Donation Gateway';
 93+ const IDENTIFIER = 'donation';
 94+ const COMMUNICATION_TYPE = 'xml'; //this needs to be either 'xml' or 'namevalue'
 95+ const GLOBAL_PREFIX = 'wgDonationGateway'; //...for example.
 96+
 97+ function __construct() {
9898 global $wgDonationInterfaceTest; //this is so the forms can see it.
9999 //TODO: Alter the forms so they don't need the global?
100 - if ( !self::getGlobal('Test') ) {
101 - $this->url = self::getGlobal('URL');
 100+ if ( !self::getGlobal( 'Test' ) ) {
 101+ $this->url = self::getGlobal( 'URL' );
102102 $wgDonationInterfaceTest = false;
103103 } else {
104 - $this->url = self::getGlobal('TestingURL');
 104+ $this->url = self::getGlobal( 'TestingURL' );
105105 $wgDonationInterfaceTest = true;
106106 }
107107
108 - $dir = dirname( __FILE__ ) . '/';
109 - require_once( $dir . '../gateway_common/DonationData.php' );
110 - $this->dataObj = new DonationData(get_called_class(), $wgDonationInterfaceTest);
111 -
 108+ $this->dataObj = new DonationData( get_called_class(), $wgDonationInterfaceTest );
 109+
112110 $this->postdata = $this->dataObj->getData();
113111 //TODO: Fix this a bit.
114112 $this->posted = $this->dataObj->wasPosted();
115 -
 113+
116114 $this->setPostDefaults();
117115 $this->defineTransactions();
118116 $this->defineVarMap();
119117 $this->defineAccountInfo();
120118 $this->defineReturnValueMap();
121 -
 119+
122120 $this->displaydata = $this->postdata;
123121 $this->stageData();
124122 }
125 -
 123+
126124 /**
127125 * Override this in children if you want different defaults.
128126 */
129 - function setPostDefaults(){
 127+ function setPostDefaults() {
130128 $returnTitle = Title::newFromText( 'Donate-thanks/en' );
131129 $returnto = $returnTitle->getFullURL();
132 -
 130+
133131 $this->postdatadefaults = array(
134132 'order_id' => '112358' . rand(),
135133 'amount' => '11.38',
@@ -136,29 +134,30 @@
137135 'language' => 'en',
138136 'country' => 'US',
139137 'returnto' => $returnto,
140 - 'user_ip' => ( self::getGlobal('Test') ) ? '12.12.12.12' : wfGetIP(), // current user's IP address
 138+ 'user_ip' => ( self::getGlobal( 'Test' ) ) ? '12.12.12.12' : wfGetIP(), // current user's IP address
141139 );
142140 }
143 -
144 - function checkTokens(){
 141+
 142+ function checkTokens() {
145143 return $this->dataObj->checkTokens();
146144 }
147 -
148 - function getData(){
 145+
 146+ function getData() {
149147 return $this->postdata;
150148 }
151 - function getDisplayData(){
 149+
 150+ function getDisplayData() {
152151 return $this->displaydata;
153152 }
154 -
155 - function isCache(){
 153+
 154+ function isCache() {
156155 return $this->dataObj->isCache();
157156 }
158 -
159 - static function getGlobal($varname){
160 - static $gotten = array(); //cache.
 157+
 158+ static function getGlobal( $varname ) {
 159+ static $gotten = array( ); //cache.
161160 $globalname = self::getGlobalPrefix() . $varname;
162 - if (!array_key_exists($globalname, $gotten)){
 161+ if ( !array_key_exists( $globalname, $gotten ) ) {
163162 global $$globalname;
164163 $gotten[$globalname] = $$globalname;
165164 }
@@ -174,7 +173,7 @@
175174 $transaction = $this->currentTransaction();
176175
177176 //If there's a hard-coded value in the transaction definition, use that.
178 - if (!empty($transaction)){
 177+ if ( !empty( $transaction ) ) {
179178 if ( array_key_exists( $transaction, $this->transactions ) && is_array( $this->transactions[$transaction] ) &&
180179 array_key_exists( 'values', $this->transactions[$transaction] ) &&
181180 array_key_exists( $gateway_field_name, $this->transactions[$transaction]['values'] ) ) {
@@ -249,36 +248,36 @@
250249 function do_transaction( $transaction ) {
251250 $this->currentTransaction( $transaction );
252251 //update the contribution tracking data
253 - $this->dataObj->updateContributionTracking(defined( 'OWA' ));
 252+ $this->dataObj->updateContributionTracking( defined( 'OWA' ) );
254253 if ( $this->getCommunicationType() === 'xml' ) {
255254 $xml = $this->buildRequestXML();
256255 $returned = $this->curl_transaction( $xml );
257256 //put the response in a universal form, and return it.
258257 }
259 -
 258+
260259 if ( $this->getCommunicationType() === 'namevalue' ) {
261260 $namevalue = $this->postdata;
262261 $returned = $this->curl_transaction( $namevalue );
263262 //put the response in a universal form, and return it.
264263 }
265 -
266 - self::log("RETURNED FROM CURL:" . print_r($returned, true));
267 - if ($returned['result'] === false){ //couldn't make contact. Bail.
 264+
 265+ self::log( "RETURNED FROM CURL:" . print_r( $returned, true ) );
 266+ if ( $returned['result'] === false ) { //couldn't make contact. Bail.
268267 return $returned;
269268 }
270 -
 269+
271270 //get the status of the response
272 - $formatted = $this->getFormattedResponse($returned['result']);
273 - $returned['status'] = $this->getResponseStatus($formatted);
274 -
 271+ $formatted = $this->getFormattedResponse( $returned['result'] );
 272+ $returned['status'] = $this->getResponseStatus( $formatted );
 273+
275274 //get errors
276 - $returned['errors'] = $this->getResponseErrors($formatted);
277 -
 275+ $returned['errors'] = $this->getResponseErrors( $formatted );
 276+
278277 //if we're still okay (hey, even if we're not), get relevent dataz.
279 - $returned['data'] = $this->getResponseData($formatted);
280 -
281 - $this->processResponse($returned);
282 -
 278+ $returned['data'] = $this->getResponseData( $formatted );
 279+
 280+ $this->processResponse( $returned );
 281+
283282 //TODO: Actually pull these from somewhere legit.
284283 if ( $returned['status'] === true ) {
285284 $returned['message'] = "$transaction Transaction Successful!";
@@ -306,7 +305,7 @@
307306 CURLOPT_USERAGENT => Http::userAgent(),
308307 CURLOPT_HEADER => 1,
309308 CURLOPT_RETURNTRANSFER => 1,
310 - CURLOPT_TIMEOUT => self::getGlobal('Timeout'),
 309+ CURLOPT_TIMEOUT => self::getGlobal( 'Timeout' ),
311310 CURLOPT_FOLLOWLOCATION => 0,
312311 CURLOPT_SSL_VERIFYPEER => 0,
313312 CURLOPT_SSL_VERIFYHOST => 2,
@@ -315,9 +314,9 @@
316315 );
317316
318317 // set proxy settings if necessary
319 - if ( self::getGlobal('UseHTTPProxy') ) {
 318+ if ( self::getGlobal( 'UseHTTPProxy' ) ) {
320319 $opts[CURLOPT_HTTPPROXYTUNNEL] = 1;
321 - $opts[CURLOPT_PROXY] = self::getGlobal('UseHTTPProxy');
 320+ $opts[CURLOPT_PROXY] = self::getGlobal( 'UseHTTPProxy' );
322321 }
323322 return $opts;
324323 }
@@ -372,7 +371,7 @@
373372 $return = array( );
374373
375374 while ( $i++ <= 3 ) {
376 - self::log( $this->postdatadefaults['order_id'] . ' Preparing to send transaction to ' . self::getGatewayName());
 375+ self::log( $this->postdatadefaults['order_id'] . ' Preparing to send transaction to ' . self::getGatewayName() );
377376 $return['result'] = curl_exec( $ch );
378377 $return['headers'] = curl_getinfo( $ch );
379378
@@ -380,7 +379,7 @@
381380 self::log( $this->postdatadefaults['order_id'] . ' Failed sending transaction to ' . self::getGatewayName() . ', retrying' );
382381 sleep( 1 );
383382 } elseif ( $return['headers']['http_code'] == 200 || $return['headers']['http_code'] == 403 ) {
384 - self::log( $this->postdatadefaults['order_id'] . ' Finished sending transaction to ' . self::getGatewayName());
 383+ self::log( $this->postdatadefaults['order_id'] . ' Finished sending transaction to ' . self::getGatewayName() );
385384 break;
386385 }
387386 }
@@ -399,7 +398,6 @@
400399 curl_close( $ch );
401400
402401 return $return;
403 -
404402 }
405403
406404 function stripXMLResponseHeaders( $rawResponse ) {
@@ -467,25 +465,25 @@
468466
469467 return $result;
470468 }
471 -
 469+
472470 static function getCommunicationType() {
473471 $c = get_called_class();
474 - return $c::communicationtype;
 472+ return $c::COMMUNICATION_TYPE;
475473 }
476 -
 474+
477475 static function getGatewayName() {
478476 $c = get_called_class();
479 - return $c::gatewayname;
 477+ return $c::GATEWAY_NAME;
480478 }
481 -
 479+
482480 static function getGlobalPrefix() {
483481 $c = get_called_class();
484 - return $c::globalprefix;
 482+ return $c::GLOBAL_PREFIX;
485483 }
486 -
 484+
487485 static function getIdentifier() {
488486 $c = get_called_class();
489 - return $c::identifier;
 487+ return $c::IDENTIFIER;
490488 }
491489
492490 }
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
@@ -6,54 +6,52 @@
77 * @author khorn
88 */
99 class DonationData {
10 -
11 - protected $normalized = array();
12 -
 10+
 11+ protected $normalized = array( );
1312 public $boss;
14 -
15 - function __construct($owning_class, $test = false, $testdata = false){
 13+
 14+ function __construct( $owning_class, $test = false, $testdata = false ) {
1615 //TODO: Actually think about this bit.
1716 // ...and keep in mind we can re-populate if it's a test or whatever. (But that may not be a good idea either)
1817 //maybe we should just explicitly pass in where we get the data from. (Test, post, API...)
1918 $this->boss = $owning_class;
20 - $this->populateData($test, $testdata);
 19+ $this->populateData( $test, $testdata );
2120 }
22 -
23 - function populateData($test = false, $testdata = false){
24 - $this->normalized = array();
 21+
 22+ function populateData( $test = false, $testdata = false ) {
 23+ $this->normalized = array( );
2524 //TODO: Uh, the API should probably be able to get in this far, too... and have its own populate function.
2625 //Maybe check for the boss class...
27 - if ($test){
28 - $this->populateData_Test($testdata);
 26+ if ( $test ) {
 27+ $this->populateData_Test( $testdata );
2928 } else {
3029 $this->populateData_Form();
3130 }
3231 $this->doCacheStuff();
33 -
34 -
35 - if (!empty($this->normalized)){
 32+
 33+
 34+ if ( !empty( $this->normalized ) ) {
3635 $this->setNormalizedAmount();
3736 $this->setNormalizedOrderIDs();
3837 $this->setGateway();
3938 array_walk( $this->normalized, array( $this, 'sanitizeInput' ) );
4039 }
4140 //TODO: determine if _nocache_ is still a thing anywhere.
42 - if ( !empty($this->normalized) && ( $this->getVal('numAttempt') == '0' && (( !$this->getVal('utm_source_id') == false ) || $this->getVal('_nocache_') == 'true' ) )) {
 41+ if ( !empty( $this->normalized ) && ( $this->getVal( 'numAttempt' ) == '0' && ((!$this->getVal( 'utm_source_id' ) == false ) || $this->getVal( '_nocache_' ) == 'true' ) ) ) {
4342 $this->saveContributionTracking();
4443 }
45 -
4644 }
47 -
48 - function getData(){
 45+
 46+ function getData() {
4947 return $this->normalized;
5048 }
51 -
52 - function isCache(){
 49+
 50+ function isCache() {
5351 return $this->cache;
5452 }
55 -
56 - function populateData_Test($testdata = false){
57 - if (is_array($testdata)){
 53+
 54+ function populateData_Test( $testdata = false ) {
 55+ if ( is_array( $testdata ) ) {
5856 $this->normalized = $testdata;
5957 } else {
6058 // define arrays of cc's and cc #s for random selection
@@ -68,8 +66,8 @@
6967 $card_index = array_rand( $cards );
7068
7169 // randomly select a credit card #
72 - $card_num_index = array_rand( $card_nums[ $cards[ $card_index ]] );
73 -
 70+ $card_num_index = array_rand( $card_nums[$cards[$card_index]] );
 71+
7472 global $wgRequest; //TODO: ARRRGHARGHARGH. That is all.
7573
7674 $this->normalized = array(
@@ -93,8 +91,8 @@
9492 'country2' => 'US',
9593 'size' => 'small',
9694 'premium_language' => 'es',
97 - 'card_num' => $card_nums[ $cards[ $card_index ]][ $card_num_index ],
98 - 'card' => $cards[ $card_index ],
 95+ 'card_num' => $card_nums[$cards[$card_index]][$card_num_index],
 96+ 'card_type' => $cards[$card_index],
9997 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ),
10098 'cvv' => '001',
10199 'currency' => 'USD',
@@ -121,8 +119,8 @@
122120 );
123121 }
124122 }
125 -
126 - function populateData_Form(){
 123+
 124+ function populateData_Form() {
127125 global $wgRequest; //I'll let you have this one, because it makes sense.
128126 $this->normalized = array(
129127 'posted' => 'true', //moderately sneaky.
@@ -149,11 +147,11 @@
150148 * to be 'country' for downstream processing (until we fully support passing in two separate addresses). I thought about completely
151149 * disabling country2 support in the forms, etc but realized there's a chance it'll be resurrected shortly. Hence this silly hack.
152150 */
153 - 'country2' => ( strlen( $wgRequest->getText( 'country2' ))) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ),
 151+ 'country2' => ( strlen( $wgRequest->getText( 'country2' ) )) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ),
154152 'size' => $wgRequest->getText( 'size' ),
155153 'premium_language' => $wgRequest->getText( 'premium_language', "en" ),
156154 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ),
157 - 'card' => $wgRequest->getText( 'card' ),
 155+ 'card_type' => $wgRequest->getText( 'card' ),
158156 'expiration' => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ),
159157 'cvv' => $wgRequest->getText( 'cvv' ),
160158 'currency' => $wgRequest->getText( 'currency_code' ),
@@ -180,82 +178,81 @@
181179 'owa_session' => $wgRequest->getText( 'owa_session', null ),
182180 'owa_ref' => $wgRequest->getText( 'owa_ref', null ),
183181 );
184 - if (!$wgRequest->wasPosted()){
185 - $this->setVal('posted', false);
186 - }
 182+ if ( !$wgRequest->wasPosted() ) {
 183+ $this->setVal( 'posted', false );
 184+ }
187185 }
188 -
189 - function isSomething($key){
190 - if (array_key_exists($key, $this->normalized) && !empty($this->normalized[$key])){
 186+
 187+ function isSomething( $key ) {
 188+ if ( array_key_exists( $key, $this->normalized ) && !empty( $this->normalized[$key] ) ) {
191189 return true;
192190 } else {
193191 return false;
194192 }
195193 }
196 -
197 - function getVal($key){
198 - if ($this->isSomething($key)){
 194+
 195+ function getVal( $key ) {
 196+ if ( $this->isSomething( $key ) ) {
199197 return $this->normalized[$key];
200198 } else {
201199 return null;
202200 }
203201 }
204 -
205 - function setVal($key, $val){
 202+
 203+ function setVal( $key, $val ) {
206204 $this->normalized[$key] = $val;
207205 }
208 -
209 - function expunge($key){
210 - if (array_key_exists($key, $this->normalized)){
211 - unset($this->normalized[$key]);
 206+
 207+ function expunge( $key ) {
 208+ if ( array_key_exists( $key, $this->normalized ) ) {
 209+ unset( $this->normalized[$key] );
212210 }
213211 }
214 -
215 - function setNormalizedAmount(){
216 -
217 - if (!($this->isSomething('amount')) || !(preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal('amount') ) )){
218 - if ($this->isSomething('amountGiven') && preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal('amountGiven') ) ){
219 - $this->setVal('amount', number_format( $this->getVal('amountGiven'), 2, '.', '' ));
220 - } elseif ($this->isSomething('amount') && $this->getVal('amount') == '-1'){
221 - $this->setVal('amount', $this->getVal('amountOther'));
 212+
 213+ function setNormalizedAmount() {
 214+
 215+ if ( !($this->isSomething( 'amount' )) || !(preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal( 'amount' ) ) ) ) {
 216+ if ( $this->isSomething( 'amountGiven' ) && preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal( 'amountGiven' ) ) ) {
 217+ $this->setVal( 'amount', number_format( $this->getVal( 'amountGiven' ), 2, '.', '' ) );
 218+ } elseif ( $this->isSomething( 'amount' ) && $this->getVal( 'amount' ) == '-1' ) {
 219+ $this->setVal( 'amount', $this->getVal( 'amountOther' ) );
222220 } else {
223 - $this->setVal('amount', '0.00');
 221+ $this->setVal( 'amount', '0.00' );
224222 }
225223 }
226 -
227 - $this->expunge('amountGiven');
228 - $this->expunge('amountOther');
 224+
 225+ $this->expunge( 'amountGiven' );
 226+ $this->expunge( 'amountOther' );
229227 }
230 -
231 - function setOwaRefId(){
 228+
 229+ function setOwaRefId() {
232230 //Our data should already be pulled and whatever.
233 - if( $this->isSomething( 'owa_ref' ) && !is_numeric( $this->normalized['owa_ref'] )){
 231+ if ( $this->isSomething( 'owa_ref' ) && !is_numeric( $this->normalized['owa_ref'] ) ) {
234232 $owa_ref = $this->get_owa_ref_id( $owa_ref );
235233 }
236234 }
237 -
238 - function setNormalizedOrderIDs(){
 235+
 236+ function setNormalizedOrderIDs() {
239237 //basically, we need a new order_id every time we come through here, but if there's an internal already there,
240238 //we want to use that one internally. So.
241 - $this->setVal('order_id', $this->generateOrderId());
242 -
243 - if (!$this->isSomething('i_order_id')){
244 - $this->setVal('i_order_id', $this->generateOrderId());
245 - }
 239+ $this->setVal( 'order_id', $this->generateOrderId() );
 240+
 241+ if ( !$this->isSomething( 'i_order_id' ) ) {
 242+ $this->setVal( 'i_order_id', $this->generateOrderId() );
 243+ }
246244 }
247 -
 245+
248246 /**
249247 * Generate an order id exactly once for this go-round.
250248 */
251249 function generateOrderId() {
252250 static $order_id = null;
253 - if ($order_id === null){
 251+ if ( $order_id === null ) {
254252 $order_id = ( double ) microtime() * 1000000 . mt_rand( 1000, 9999 );
255253 }
256254 return $order_id;
257255 }
258 -
259 -
 256+
260257 /**
261258 * Sanitize user input
262259 *
@@ -269,27 +266,27 @@
270267 public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) {
271268 $value = htmlspecialchars( $value, $flags, 'UTF-8', $double_encode );
272269 }
273 -
274 - function log($message, $log_level=LOG_INFO){
275 - if (class_exists($this->boss)){
 270+
 271+ function log( $message, $log_level=LOG_INFO ) {
 272+ if ( class_exists( $this->boss ) ) {
276273 $c = $this->boss;
277 - $c::log($message, $log_level);
 274+ $c::log( $message, $log_level );
278275 }
279276 }
280 -
281 - function setGateway(){
 277+
 278+ function setGateway() {
282279 //TODO: Hum. If we have some other gateway in the form data, should we go crazy here? (Probably)
283 - if (class_exists($this->boss)){
 280+ if ( class_exists( $this->boss ) ) {
284281 $c = $this->boss;
285282 $gateway = $c::getIdentifier();
286 - $this->setVal('gateway', $gateway);
287 - }
 283+ $this->setVal( 'gateway', $gateway );
 284+ }
288285 }
289 -
290 - function doCacheStuff(){
 286+
 287+ function doCacheStuff() {
291288 //TODO: Wow, name.
292289 global $wgRequest;
293 -
 290+
294291 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
295292 if ( $this->isSomething( '_cache_' ) ) {
296293 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Cache requested', LOG_DEBUG );
@@ -298,26 +295,25 @@
299296
300297 // if we have squid caching enabled, set the maxage
301298 global $wgUseSquid, $wgOut;
302 - if (class_exists($this->boss)){
 299+ if ( class_exists( $this->boss ) ) {
303300 $g = $this->boss; //the 'g' is for "Gateway"!
304 - $maxAge = $g::getGlobal('SMaxAge');
 301+ $maxAge = $g::getGlobal( 'SMaxAge' );
305302
306303 if ( $wgUseSquid ) {
307304 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG );
308 - $wgOut->setSquidMaxage( $maxAge );
 305+ $wgOut->setSquidMaxage( $maxAge );
309306 }
310307 }
311308 } else {
312309 $this->cache = false; //TODO: Kill this one in the face, too. (see above)
313310 }
314311 }
315 -
316 - function getAnnoyingOrderIDLogLinePrefix(){
 312+
 313+ function getAnnoyingOrderIDLogLinePrefix() {
317314 //TODO: ...aww. But it's so descriptive.
318 - return $this->getVal( 'order_id' ) . ' ' . $this->getVal( 'i_order_id' ) . ': ';
 315+ return $this->getVal( 'order_id' ) . ' ' . $this->getVal( 'i_order_id' ) . ': ';
319316 }
320 -
321 -
 317+
322318 /**
323319 * Establish an 'edit' token to help prevent CSRF, etc
324320 *
@@ -335,20 +331,20 @@
336332
337333 // make sure we have a session open for tracking a CSRF-prevention token
338334 self::ensureSession();
339 -
340 - if (class_exists($this->boss)){
 335+
 336+ if ( class_exists( $this->boss ) ) {
341337 $g = $this->boss;
342338 $gateway_ident = $g::getIdentifier();
343339 } else {
344340 $gateway_ident = 'DonationData';
345341 }
346342
347 - if ( !isset( $_SESSION[ $gateway_ident . 'EditToken' ] ) ) {
 343+ if ( !isset( $_SESSION[$gateway_ident . 'EditToken'] ) ) {
348344 // generate unsalted token to place in the session
349345 $token = self::generateToken();
350 - $_SESSION[ $gateway_ident . 'EditToken' ] = $token;
 346+ $_SESSION[$gateway_ident . 'EditToken'] = $token;
351347 } else {
352 - $token = $_SESSION[ $gateway_ident . 'EditToken' ];
 348+ $token = $_SESSION[$gateway_ident . 'EditToken'];
353349 }
354350
355351 if ( is_array( $salt ) ) {
@@ -381,8 +377,8 @@
382378 if ( $val != $sessionToken ) {
383379 wfDebug( "DonationData::matchEditToken: broken session data\n" );
384380 }
385 - $this->log("Val = $val");
386 - $this->log("Session Token = $sessionToken");
 381+ $this->log( "Val = $val" );
 382+ $this->log( "Session Token = $sessionToken" );
387383 return $val == $sessionToken;
388384 }
389385
@@ -390,13 +386,13 @@
391387 * Unset the payflow edit token from a user's session
392388 */
393389 function unsetEditToken() {
394 - if (class_exists($this->boss)){
 390+ if ( class_exists( $this->boss ) ) {
395391 $g = $this->boss;
396392 $gateway_ident = $g::getIdentifier();
397393 } else {
398394 $gateway_ident = "DonationData";
399395 }
400 - unset( $_SESSION[ $gateway_ident . 'EditToken' ] );
 396+ unset( $_SESSION[$gateway_ident . 'EditToken'] );
401397 }
402398
403399 /**
@@ -407,52 +403,49 @@
408404 */
409405 public static function ensureSession() {
410406 // if the session is already started, do nothing
411 - if ( session_id() ) return;
 407+ if ( session_id() )
 408+ return;
412409
413410 // otherwise, fire it up using global mw function wfSetupSession
414411 wfSetupSession();
415412 }
416 -
 413+
417414 public function checkTokens() {
418415 static $match = null;
419 -
420 - if ($match === null) {
421 - if (class_exists($this->boss)){
 416+
 417+ if ( $match === null ) {
 418+ if ( class_exists( $this->boss ) ) {
422419 $g = $this->boss;
423 - $salt = $g::getGlobal('Salt');
 420+ $salt = $g::getGlobal( 'Salt' );
424421 } else {
425422 $salt = 'gotToBeInAUnitTest';
426423 }
427 -
 424+
428425 // establish the edit token to prevent csrf
429426 $token = $this->getEditToken( $salt );
430 -
 427+
431428 $this->log( $this->getAnnoyingOrderIDLogLinePrefix() . ' editToken: ' . $token, LOG_DEBUG );
432 -
 429+
433430 // match token
434431 $token_check = ( $this->isSomething( 'token' ) ) ? $this->getVal( 'token' ) : $token; //TODO: does this suck as much as it looks like it does?
435432 $match = $this->matchEditToken( $token_check, $salt );
436433 if ( $this->wasPosted() ) {
437 - $this->log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Submitted edit token: ' . $this->getVal( 'token' ), LOG_DEBUG);
 434+ $this->log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Submitted edit token: ' . $this->getVal( 'token' ), LOG_DEBUG );
438435 $this->log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Token match: ' . ($match ? 'true' : 'false' ), LOG_DEBUG );
439436 }
440 -
441437 }
442 -
 438+
443439 return $match;
444440 }
445 -
446 - function wasPosted(){
 441+
 442+ function wasPosted() {
447443 //TODO: Get rid of these log statements.
448 - if ( $this->isSomething('posted') ){
 444+ if ( $this->isSomething( 'posted' ) ) {
449445 return true;
450446 }
451447 return false;
452448 }
453449
454 -
455 -
456 -
457450 /**
458451 * Get the utm_source string
459452 *
@@ -505,7 +498,8 @@
506499
507500 // if there are no sourceparts element, then the banner portion of the string needs to be set.
508501 // since we don't know what it is, set it to an empty string
509 - if ( !count( $source_parts ) ) $source_parts[0] = '';
 502+ if ( !count( $source_parts ) )
 503+ $source_parts[0] = '';
510504
511505 // if the utm_source_id is set, set the landing page portion of the string to cc#
512506 $source_parts[1] = ( $utm_source_id ) ? 'cc' . $utm_source_id : ( isset( $source_parts[1] ) ? $source_parts[1] : '' );
@@ -516,8 +510,7 @@
517511 // return a reconstructed string
518512 return implode( ".", $source_parts );
519513 }
520 -
521 -
 514+
522515 /**
523516 * Determine proper opt-out settings for contribution tracking
524517 *
@@ -526,11 +519,10 @@
527520 * (which is opt-out), we need to reverse the values
528521 */
529522 public function getOptOuts() {
530 - $optout[ 'optout' ] = ( $this->isSomething('email-opt') && $this->getVal('email-opt') == "1" ) ? '0' : '1';
531 - $optout[ 'anonymous' ] = ( $this->isSomething('comment-option') && $this->getVal('comment-option') == "1" ) ? '0' : '1';
 523+ $optout['optout'] = ( $this->isSomething( 'email-opt' ) && $this->getVal( 'email-opt' ) == "1" ) ? '0' : '1';
 524+ $optout['anonymous'] = ( $this->isSomething( 'comment-option' ) && $this->getVal( 'comment-option' ) == "1" ) ? '0' : '1';
532525 return $optout;
533526 }
534 -
535527
536528 /**
537529 * Clean array of tracking data to contain valid fields
@@ -555,35 +547,35 @@
556548 'ts'
557549 );
558550
559 - foreach ($tracking_fields as $value){
560 - if ($this->isSomething($value)){
561 - $tracking_data[$value] = $this->getVal($value);
 551+ foreach ( $tracking_fields as $value ) {
 552+ if ( $this->isSomething( $value ) ) {
 553+ $tracking_data[$value] = $this->getVal( $value );
562554 } else {
563555 $tracking_data[$value] = null;
564556 }
565557 }
566 -
 558+
567559 // clean up the optout values if necessary
568560 if ( $clean_optouts ) {
569561 $optouts = $this->getOptOuts();
570 - $tracking_data[ 'optout' ] = $optouts[ 'optout' ];
571 - $tracking_data[ 'anonymous' ] = $optouts[ 'anonymous' ];
 562+ $tracking_data['optout'] = $optouts['optout'];
 563+ $tracking_data['anonymous'] = $optouts['anonymous'];
572564 }
573565
574566 return $tracking_data;
575567 }
576 -
 568+
577569 //if ( !empty($data) && ( $data[ 'numAttempt' ] == '0' && ( !$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) ) {
578570 //so, basically, if this is the first attempt. This seems to get called nowhere else.
579571 function saveContributionTracking() {
580572
581 - $tracked_contribution = $this->getCleanTrackingData(true);
 573+ $tracked_contribution = $this->getCleanTrackingData( true );
582574
583575 // insert tracking data and get the tracking id
584576 $result = self::insertContributionTracking( $tracked_contribution );
585 -
586 - $this->setVal('contribution_tracking_id', $result);
587577
 578+ $this->setVal( 'contribution_tracking_id', $result );
 579+
588580 if ( !$result ) {
589581 return false;
590582 }
@@ -599,22 +591,23 @@
600592 public static function insertContributionTracking( $tracking_data ) {
601593 $db = ContributionTrackingProcessor::contributionTrackingConnection();
602594
603 - if ( !$db ) { return false; }
 595+ if ( !$db ) {
 596+ return false;
 597+ }
604598
605599 // set the time stamp if it's not already set
606 - if ( !isset( $tracking_data[ 'ts' ] ) || !strlen( $tracking_data[ 'ts' ] ) ) {
607 - $tracking_data[ 'ts' ] = $db->timestamp();
 600+ if ( !isset( $tracking_data['ts'] ) || !strlen( $tracking_data['ts'] ) ) {
 601+ $tracking_data['ts'] = $db->timestamp();
608602 }
609603
610604 // Store the contribution data
611605 if ( $db->insert( 'contribution_tracking', $tracking_data ) ) {
612 - return $db->insertId();
 606+ return $db->insertId();
613607 } else {
614608 return false;
615609 }
616610 }
617 -
618 -
 611+
619612 /**
620613 * Update contribution_tracking table
621614 *
@@ -629,25 +622,27 @@
630623 // ony update contrib tracking if we're coming from a single-step landing page
631624 // which we know with cc# in utm_source or if force=true or if contribution_tracking_id is not set
632625 if ( !$force &&
633 - !preg_match( "/cc[0-9]/", $this->getVal('utm_source') ) &&
634 - is_numeric( $this->getVal('contribution_tracking_id') ) ) {
 626+ !preg_match( "/cc[0-9]/", $this->getVal( 'utm_source' ) ) &&
 627+ is_numeric( $this->getVal( 'contribution_tracking_id' ) ) ) {
635628 return;
636629 }
637630
638631 $db = ContributionTrackingProcessor::contributionTrackingConnection();
639632
640 - if ( !$db ) { return true ; } ///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.
 633+ if ( !$db ) {
 634+ return true;
 635+ } ///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.
641636
642 - $tracked_contribution = $this->getCleanTrackingData(true);
 637+ $tracked_contribution = $this->getCleanTrackingData( true );
643638
644639 // if contrib tracking id is not already set, we need to insert the data, otherwise update
645 - if ( !$this->getVal('contribution_tracking_id') ) {
646 - $this->setVal('contribution_tracking_id', $this->insertContributionTracking( $tracked_contribution ));
 640+ if ( !$this->getVal( 'contribution_tracking_id' ) ) {
 641+ $this->setVal( 'contribution_tracking_id', $this->insertContributionTracking( $tracked_contribution ) );
647642 } else {
648 - $db->update( 'contribution_tracking', $tracked_contribution, array( 'id' => $this->getVal('contribution_tracking_id') ) );
 643+ $db->update( 'contribution_tracking', $tracked_contribution, array( 'id' => $this->getVal( 'contribution_tracking_id' ) ) );
649644 }
650645 }
651 -
 646+
652647 }
653648
654649 ?>

Follow-up revisions

RevisionCommit summaryAuthorDate
r99281Killed the wasPosted function in DonationData, in favor of using the real one....khorn23:30, 7 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95723Preliminary work refactoring the DonationInterface extension....khorn23:04, 29 August 2011

Comments

#Comment by Khorn (WMF) (talk | contribs)   18:40, 23 September 2011

Please note that this branch is in the middle of a serious refactoring, and is by no means ready to be merged back into trunk. (Latest DonationInterface branch rev at the time of this comment is r97833.)

#Comment by Jpostlethwaite (talk | contribs)   19:29, 23 September 2011

This code is in development. Please see latest revision.

#Comment by Awjrichards (talk | contribs)   19:50, 29 September 2011

From donationinterface.php: $wgDonationInterfaceHtmlFormDir = dirname( __FILE__ ) . "/gateway_forms/html"; //ffname is the $key from now on. $wgDonationInterfaceAllowedHtmlForms = array( 'demo' => $wgDonationInterfaceHtmlFormDir . "/demo.html", 'globalcollect_test' => $wgDonationInterfaceHtmlFormDir . "/globalcollect_test.html", ); This needs to be updated to reflect the new rapidhtml directory layout in trunk. Merging fun!

#Comment by Khorn (WMF) (talk | contribs)   23:32, 7 October 2011

I almost think we should start tagging things as DonationInterfaceMergingFun.

|
#Comment by Awjrichards (talk | contribs)   20:02, 29 September 2011

From donationinterface.php:

//This is going to be a little funky. 
//Override this in LocalSettings.php BEFORE you include this file, if you want 
//to disable gateways.
//TODO: Unfunktify, if you have a better idea here for auto-loading the classes after LocalSettings.php runs all the way. 
if ( !isset( $wgDonationInterfaceEnabledGateways ) ) {
	$wgDonationInterfaceEnabledGateways = array(
		'paypal',
		'payflowpro',
		'globalcollect'
	);
}

foreach ( $wgDonationInterfaceEnabledGateways as $gateway ) {
	//include 'em
	require_once( $donationinterface_dir . $gateway . '_gateway/' . $gateway . '_gateway.php' );
}

You can just get rid of:

if( !isset( $wgDonationInterfaceEnabledGateways ))

Typically with Mediawiki, if a user wanted to override default enabled gateways, they would do so by re-declaring the $wgDonationInterfaceEnabledGateways variable after the inclusion of the install file. You can then move the foreach() portion into a deferred setup function (see http://www.mediawiki.org/wiki/Manual:Developing_extensions#Deferring_setup). Also, it's nicer to use $wgAutoloadClasses rather than the require_once for each of the gateway files.

#Comment by Khorn (WMF) (talk | contribs)   23:31, 7 October 2011

This particular block of code no longer exists. Also, we've talked a bit about how this piece is a little backwards, but doing it any other way would be a kind of Deep Hurting. It will be well documented.

#Comment by Awjrichards (talk | contribs)   22:34, 29 September 2011

In DonationData.php:

	function wasPosted() {
		//TODO: Get rid of these log statements. 
		if ( $this->isSomething( 'posted' ) ) {
			return true;
		}
		return false;
	}

MW actually gives you this for free - $wgRequest->wasPosted() (see http://svn.wikimedia.org/doc/classWebRequest.html#ac071f0bf11ae22c677678688e4818392). Probably best to stick with that unless you have other dark magic to do.

#Comment by Khorn (WMF) (talk | contribs)   23:31, 7 October 2011

Fixed in r99281. :)

#Comment by Khorn (WMF) (talk | contribs)   16:13, 10 October 2011

Though, the thought occurs, that the reason I did this was probably for unit testing. ...I wouldn't be surprised if this gets summarily un-fixed soon.

Status & tagging log