Index: branches/fundraising/extensions/DonationInterface/donationinterface.php |
— | — | @@ -18,27 +18,21 @@ |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:DonationInterface', |
20 | 20 | ); |
21 | 21 | |
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 | | - |
34 | 22 | $donationinterface_dir = dirname( __FILE__ ) . '/'; |
35 | 23 | |
36 | 24 | require_once( $donationinterface_dir . 'donate_interface/donate_interface.php' ); |
37 | 25 | |
38 | | -foreach ( $wgDonationInterfaceEnabledGateways as $gateway ) { |
39 | | - //include 'em |
40 | | - require_once( $donationinterface_dir . $gateway . '_gateway/' . $gateway . '_gateway.php' ); |
41 | | -} |
42 | 26 | |
| 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 | + |
43 | 37 | //load all possible form classes |
44 | 38 | $wgAutoloadClasses['Gateway_Form'] = $donationinterface_dir . 'gateway_forms/Form.php'; |
45 | 39 | $wgAutoloadClasses['Gateway_Form_OneStepTwoColumn'] = $donationinterface_dir . 'gateway_forms/OneStepTwoColumn.php'; |
— | — | @@ -60,9 +54,30 @@ |
61 | 55 | $wgAutoloadClasses['Gateway_Form_RapidHtml'] = $donationinterface_dir . 'gateway_forms/RapidHtml.php'; |
62 | 56 | $wgAutoloadClasses['Gateway_Form_SingleColumn'] = $donationinterface_dir . 'gateway_forms/SingleColumn.php'; |
63 | 57 | |
| 58 | + |
| 59 | +$wgAutoloadClasses['DonationData'] = $donationinterface_dir . 'gateway_common/DonationData.php'; |
| 60 | +$wgAutoloadClasses['GatewayAdapter'] = $donationinterface_dir . 'gateway_common/gateway.adapter.php'; |
| 61 | + |
64 | 62 | //THE GATEWAYS WILL RESET THIS when they are instantiated. You can override it, but it won't stick around that way. |
65 | 63 | $wgDonationInterfaceTest = false; |
66 | 64 | |
| 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 | + |
67 | 82 | /** |
68 | 83 | * Hooks required to interface with the donation extension (include <donate> on page) |
69 | 84 | * |
— | — | @@ -71,7 +86,6 @@ |
72 | 87 | */ |
73 | 88 | //$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue'; |
74 | 89 | //$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage'; |
75 | | - |
76 | 90 | # Unit tests |
77 | 91 | $wgHooks['UnitTestsList'][] = 'efDonationInterfaceUnitTests'; |
78 | 92 | |
Index: branches/fundraising/extensions/DonationInterface/tests/GatewayAdapterTest.php |
— | — | @@ -81,10 +81,10 @@ |
82 | 82 | |
83 | 83 | class TestAdapter extends GatewayAdapter { |
84 | 84 | |
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'; |
89 | 89 | |
90 | 90 | function stageData(){ |
91 | 91 | $this->postdata['amount'] = $this->postdata['amount'] * 1000; |
— | — | @@ -96,7 +96,6 @@ |
97 | 97 | $wgTestAdapterGatewayTest = true; |
98 | 98 | $wgTestAdapterGatewayTestVar = "Hi there!"; |
99 | 99 | $wgTestAdapterGatewayUseSyslog = true; |
100 | | - $this->classlocation = __FILE__; |
101 | 100 | parent::__construct(); |
102 | 101 | |
103 | 102 | } |
Index: branches/fundraising/extensions/DonationInterface/tests/DonationDataTest.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | 'size' => 'Big mcLargeHuge', |
35 | 35 | 'premium_language' => 'fr', |
36 | 36 | 'card_num' => '42', |
37 | | - 'card' => 'visa', |
| 37 | + 'card_type' => 'visa', |
38 | 38 | 'expiration' => '1138', |
39 | 39 | 'cvv' => '665', |
40 | 40 | 'currency' => 'USD', |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | 'size' => '', |
86 | 86 | 'premium_language' => 'en', |
87 | 87 | 'card_num' => '', |
88 | | - 'card' => '', |
| 88 | + 'card_type' => '', |
89 | 89 | 'expiration' => '', |
90 | 90 | 'cvv' => '', |
91 | 91 | 'currency' => '', |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | 'size' => 'small', |
139 | 139 | 'premium_language' => 'es', |
140 | 140 | 'card_num' => '378282246310005', |
141 | | - 'card' => 'american', |
| 141 | + 'card_type' => 'american', |
142 | 142 | 'expiration' => '1012', |
143 | 143 | 'cvv' => '001', |
144 | 144 | 'currency' => 'USD', |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | * Holds the PayflowPro response from a transaction |
22 | 22 | * @var array |
23 | 23 | */ |
24 | | - public $payflow_response = array(); |
| 24 | + public $payflow_response = array( ); |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * A container for the form class |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | * An array of form errors |
36 | 36 | * @var array |
37 | 37 | */ |
38 | | - public $errors = array(); |
| 38 | + public $errors = array( ); |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Constructor - set up the new special page |
— | — | @@ -42,6 +42,8 @@ |
43 | 43 | public function __construct() { |
44 | 44 | parent::__construct( 'PayflowProGateway' ); |
45 | 45 | $this->errors = $this->getPossibleErrors(); |
| 46 | + |
| 47 | + $this->adapter = new PayflowProAdapter(); |
46 | 48 | } |
47 | 49 | |
48 | 50 | /** |
— | — | @@ -51,8 +53,8 @@ |
52 | 54 | */ |
53 | 55 | public function execute( $par ) { |
54 | 56 | global $wgRequest, $wgOut, $wgScriptPath, |
55 | | - $wgPayFlowProGatewayCSSVersion, |
56 | | - $wgPayflowProGatewaySalt; |
| 57 | + $wgPayFlowProGatewayCSSVersion, |
| 58 | + $wgPayflowProGatewaySalt; |
57 | 59 | |
58 | 60 | $wgOut->addExtensionStyle( |
59 | 61 | "{$wgScriptPath}/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css?284" . |
— | — | @@ -80,14 +82,14 @@ |
81 | 83 | $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
82 | 84 | |
83 | 85 | // @fixme can this be moved into the form generators? |
84 | | - $js = <<<EOT |
| 86 | + $js = <<<EOT |
85 | 87 | <script type="text/javascript"> |
86 | 88 | jQuery(document).ready(function() { |
87 | 89 | jQuery("div#p-logo a").attr("href","#"); |
88 | 90 | }); |
89 | 91 | </script> |
90 | 92 | EOT; |
91 | | - $wgOut->addHeadItem( 'logolinkoverride', $js ); |
| 93 | + $wgOut->addHeadItem( 'logolinkoverride', $js ); |
92 | 94 | |
93 | 95 | // find out if amount was a radio button or textbox, set amount |
94 | 96 | if ( isset( $_REQUEST['amount'] ) && preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount' ) ) ) { |
— | — | @@ -101,7 +103,7 @@ |
102 | 104 | } else { |
103 | 105 | $amount = '0.00'; |
104 | 106 | } |
105 | | - |
| 107 | + |
106 | 108 | // Get array of default account values necessary for Payflow |
107 | 109 | require_once( 'includes/payflowUser.inc' ); |
108 | 110 | |
— | — | @@ -111,15 +113,15 @@ |
112 | 114 | $numAttempt = $wgRequest->getVal( 'numAttempt', 0 ); |
113 | 115 | |
114 | 116 | // 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." ); |
117 | 119 | } 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 ); |
119 | 121 | } |
120 | 122 | |
121 | 123 | // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax |
122 | 124 | 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 ); |
124 | 126 | $cache = true; |
125 | 127 | $token = ''; |
126 | 128 | $token_match = false; |
— | — | @@ -127,23 +129,23 @@ |
128 | 130 | // if we have squid caching enabled, set the maxage |
129 | 131 | global $wgUseSquid, $wgPayflowProSMaxAge; |
130 | 132 | 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 ); |
133 | 135 | } |
134 | 136 | } else { |
135 | 137 | $cache = false; |
136 | 138 | |
137 | 139 | // establish the edit token to prevent csrf |
138 | 140 | $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 | + |
142 | 144 | // match token |
143 | 145 | $token_check = ( $wgRequest->getText( 'token' ) ) ? $wgRequest->getText( 'token' ) : $token; |
144 | 146 | $token_match = $this->fnPayflowMatchEditToken( $token_check, $wgPayflowProGatewaySalt ); |
145 | 147 | 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 ); |
148 | 150 | } |
149 | 151 | } |
150 | 152 | |
— | — | @@ -166,7 +168,7 @@ |
167 | 169 | // dispatch forms/handling |
168 | 170 | if ( $token_match ) { |
169 | 171 | if ( $data['payment_method'] == 'processed' ) { |
170 | | - |
| 172 | + |
171 | 173 | // increase the count of attempts |
172 | 174 | ++$data['numAttempt']; |
173 | 175 | |
— | — | @@ -177,14 +179,14 @@ |
178 | 180 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
179 | 181 | } else { // The submitted form data is valid, so process it |
180 | 182 | // 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" ); |
182 | 184 | wfRunHooks( 'PayflowGatewayValidate', array( &$this, &$data ) ); |
183 | | - self::log( $data[ 'order_id' ] . ' Finished querying Maxmind' ); |
| 185 | + self::log( $data['order_id'] . ' Finished querying Maxmind' ); |
184 | 186 | |
185 | 187 | // if the transaction was flagged for review |
186 | 188 | if ( $this->action == 'review' ) { |
187 | 189 | // expose a hook for external handling of trxns flagged for review |
188 | | - wfRunHooks( 'PayflowGatewayReview', array( &$this, &$data )); |
| 190 | + wfRunHooks( 'PayflowGatewayReview', array( &$this, &$data ) ); |
189 | 191 | } |
190 | 192 | |
191 | 193 | // if the transaction was flagged to be 'challenged' |
— | — | @@ -237,16 +239,16 @@ |
238 | 240 | global $wgOut, $wgRequest; |
239 | 241 | |
240 | 242 | // 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' ) ) { |
242 | 244 | $tracked = $this->fnPayflowSaveContributionTracking( $data ); |
243 | 245 | if ( !$tracked ) { |
244 | 246 | $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 ); |
246 | 248 | } |
247 | 249 | } |
248 | 250 | |
249 | 251 | $form_class = $this->getFormClass(); |
250 | | - $form_obj = new $form_class( $data, $error ); |
| 252 | + $form_obj = new $form_class( $data, $error, $this->adapter ); |
251 | 253 | $form = $form_obj->getForm(); |
252 | 254 | $wgOut->addHTML( $form ); |
253 | 255 | } |
— | — | @@ -281,7 +283,7 @@ |
282 | 284 | * Using logic in setFormClass() |
283 | 285 | * @return string |
284 | 286 | */ |
285 | | - public function getFormClass( ) { |
| 287 | + public function getFormClass() { |
286 | 288 | if ( !isset( $this->form_class ) ) { |
287 | 289 | $this->setFormClass(); |
288 | 290 | } |
— | — | @@ -293,7 +295,7 @@ |
294 | 296 | */ |
295 | 297 | private function fnPayflowValidateForm( &$data, &$error ) { |
296 | 298 | global $wgPayflowProGatewayPriceFloor, $wgPayflowProGatewayPriceCeiling; |
297 | | - |
| 299 | + |
298 | 300 | // begin with no errors |
299 | 301 | $error_result = '0'; |
300 | 302 | |
— | — | @@ -315,7 +317,7 @@ |
316 | 318 | |
317 | 319 | // find all empty fields and create message |
318 | 320 | foreach ( $data as $key => $value ) { |
319 | | - if ( $value == '' || ($key == 'state' && $value == 'YY' )) { |
| 321 | + if ( $value == '' || ($key == 'state' && $value == 'YY' ) ) { |
320 | 322 | // ignore fields that are not required |
321 | 323 | if ( isset( $msg[$key] ) ) { |
322 | 324 | $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />"; |
— | — | @@ -325,9 +327,9 @@ |
326 | 328 | } |
327 | 329 | |
328 | 330 | // 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 ) ) { |
332 | 334 | $error['invalidamount'] = wfMsg( 'payflowpro_gateway-error-msg-invalid-amount' ); |
333 | 335 | $error_result = '1'; |
334 | 336 | } |
— | — | @@ -342,19 +344,19 @@ |
343 | 345 | } |
344 | 346 | |
345 | 347 | // 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'; |
354 | 356 | } else { // an invalid credit card number was entered |
355 | 357 | $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' ); |
357 | 359 | } |
358 | | - |
| 360 | + |
359 | 361 | return $error_result; |
360 | 362 | } |
361 | 363 | |
— | — | @@ -374,12 +376,12 @@ |
375 | 377 | // create payflow query string, include string lengths |
376 | 378 | $queryArray = array( |
377 | 379 | 'TRXTYPE' => $payflow_data['trxtype'], |
378 | | - 'TENDER' => $payflow_data['tender'], |
379 | | - 'USER' => $payflow_data['user'], |
| 380 | + 'TENDER' => $payflow_data['tender'], |
| 381 | + 'USER' => $payflow_data['user'], |
380 | 382 | 'VENDOR' => $payflow_data['vendor'], |
381 | 383 | 'PARTNER' => $payflow_data['partner'], |
382 | 384 | 'PWD' => $payflow_data['password'], |
383 | | - 'ACCT' => $data['card_num'], |
| 385 | + 'ACCT' => $data['card_num'], |
384 | 386 | 'EXPDATE' => $data['expiration'], |
385 | 387 | 'AMT' => $data['amount'], |
386 | 388 | 'FIRSTNAME' => $data['fname'], |
— | — | @@ -411,8 +413,8 @@ |
412 | 414 | $headers[] = 'X-VPS-Client-Timeout: 45'; |
413 | 415 | $headers[] = 'X-VPS-Request-ID:' . $data['order_id']; |
414 | 416 | $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] ); |
417 | 419 | curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); |
418 | 420 | curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent ); |
419 | 421 | curl_setopt( $ch, CURLOPT_HEADER, 1 ); |
— | — | @@ -421,7 +423,7 @@ |
422 | 424 | curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 ); |
423 | 425 | curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
424 | 426 | curl_setopt( $ch, CURLOPT_POSTFIELDS, $payflow_query ); |
425 | | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 ); |
| 427 | + curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 ); |
426 | 428 | curl_setopt( $ch, CURLOPT_FORBID_REUSE, true ); |
427 | 429 | curl_setopt( $ch, CURLOPT_POST, 1 ); |
428 | 430 | |
— | — | @@ -436,15 +438,15 @@ |
437 | 439 | $i = 1; |
438 | 440 | |
439 | 441 | 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' ); |
441 | 443 | $result = curl_exec( $ch ); |
442 | 444 | $headers = curl_getinfo( $ch ); |
443 | 445 | |
444 | 446 | 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' ); |
446 | 448 | sleep( 1 ); |
447 | 449 | } 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' ); |
449 | 451 | break; |
450 | 452 | } |
451 | 453 | } |
— | — | @@ -452,7 +454,7 @@ |
453 | 455 | if ( $headers['http_code'] != 200 ) { |
454 | 456 | $wgOut->addHTML( '<h3>No response from credit card processor. Please try again later!</h3><p>' ); |
455 | 457 | $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 ) ); |
457 | 459 | curl_close( $ch ); |
458 | 460 | return; |
459 | 461 | } |
— | — | @@ -476,18 +478,18 @@ |
477 | 479 | */ |
478 | 480 | private function fnPayflowGetResults( $data, $result ) { |
479 | 481 | // prepare NVP response for sorting and outputting |
480 | | - $responseArray = array(); |
| 482 | + $responseArray = array( ); |
481 | 483 | |
482 | 484 | /** |
483 | 485 | * 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 |
485 | 487 | * We want to turn this into an array of key value pairs, so explode on '&' and then |
486 | 488 | * split up the resulting strings into $key => $value |
487 | 489 | */ |
488 | 490 | $result_arr = explode( "&", $result ); |
489 | 491 | foreach ( $result_arr as $result_pair ) { |
490 | 492 | list( $key, $value ) = preg_split( "/=/", $result_pair ); |
491 | | - $responseArray[ $key ] = $value; |
| 493 | + $responseArray[$key] = $value; |
492 | 494 | } |
493 | 495 | |
494 | 496 | // store the response array as an object property for easy retrival/manipulation elsewhere |
— | — | @@ -503,33 +505,34 @@ |
504 | 506 | // interpret result code, return |
505 | 507 | // approved (1), denied (2), try again (3), general error (4) |
506 | 508 | $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg ); |
507 | | - |
| 509 | + |
508 | 510 | // 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 | + |
511 | 513 | // if approved, display results and send transaction to the queue |
512 | 514 | 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 ); |
514 | 516 | $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ); |
515 | 517 | // give user a second chance to enter incorrect data |
516 | 518 | } 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 ); |
518 | 520 | // pass responseMsg as an array key as required by displayForm |
519 | 521 | $this->errors['retryMsg'] = $responseMsg; |
520 | 522 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
521 | 523 | // if declined or if user has already made two attempts, decline |
522 | 524 | } 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 ); |
524 | 526 | $this->fnPayflowDisplayDeclinedResults( $responseMsg ); |
525 | 527 | } 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 ); |
527 | 529 | $this->fnPayflowDisplayOtherResults( $responseMsg ); |
528 | 530 | } 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 ); |
530 | 532 | $this->fnPayflowDisplayPending( $data, $responseArray, $responseMsg ); |
531 | 533 | } |
| 534 | + } |
532 | 535 | |
533 | | - }// end display results |
| 536 | +// end display results |
534 | 537 | |
535 | 538 | /** |
536 | 539 | * Interpret response code, return |
— | — | @@ -541,7 +544,7 @@ |
542 | 545 | function fnPayflowGetResponseMsg( $resultCode, &$responseMsg ) { |
543 | 546 | $responseMsg = wfMsg( 'payflowpro_gateway-response-default' ); |
544 | 547 | |
545 | | - switch( $resultCode ) { |
| 548 | + switch ( $resultCode ) { |
546 | 549 | case '0': |
547 | 550 | $responseMsg = wfMsg( 'payflowpro_gateway-response-0' ); |
548 | 551 | $errorCode = '1'; |
— | — | @@ -600,25 +603,25 @@ |
601 | 604 | */ |
602 | 605 | public function prepareStompTransaction( $data, $responseArray, $responseMsg ) { |
603 | 606 | $countries = $this->getCountries(); |
604 | | - |
605 | | - $transaction = array(); |
606 | 607 | |
| 608 | + $transaction = array( ); |
| 609 | + |
607 | 610 | // include response message |
608 | 611 | $transaction['response'] = $responseMsg; |
609 | | - |
| 612 | + |
610 | 613 | // include date |
611 | 614 | $transaction['date'] = time(); |
612 | | - |
| 615 | + |
613 | 616 | // put all data into one array |
614 | 617 | $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 | + |
618 | 621 | $transaction += array_merge( $data, $responseArray ); |
619 | | - |
| 622 | + |
620 | 623 | return $transaction; |
621 | 624 | } |
622 | | - |
| 625 | + |
623 | 626 | /** |
624 | 627 | * Fetch an array of country abbrevs => country names |
625 | 628 | */ |
— | — | @@ -626,7 +629,7 @@ |
627 | 630 | require_once( 'includes/countryCodes.inc' ); |
628 | 631 | return countryCodes(); |
629 | 632 | } |
630 | | - |
| 633 | + |
631 | 634 | /** |
632 | 635 | * Display response message to user with submitted user-supplied data |
633 | 636 | * |
— | — | @@ -732,8 +735,8 @@ |
733 | 736 | * (which is opt-out), we need to reverse the values |
734 | 737 | */ |
735 | 738 | 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'; |
738 | 741 | return $optout; |
739 | 742 | } |
740 | 743 | |
— | — | @@ -744,11 +747,11 @@ |
745 | 748 | $tracked_contribution = array( |
746 | 749 | 'note' => $data['comment'], |
747 | 750 | 'referrer' => $data['referrer'], |
748 | | - 'anonymous' => $optout[ 'anonymous' ], |
| 751 | + 'anonymous' => $optout['anonymous'], |
749 | 752 | 'utm_source' => $data['utm_source'], |
750 | 753 | 'utm_medium' => $data['utm_medium'], |
751 | 754 | 'utm_campaign' => $data['utm_campaign'], |
752 | | - 'optout' => $optout[ 'optout' ], |
| 755 | + 'optout' => $optout['optout'], |
753 | 756 | 'language' => $data['language'], |
754 | 757 | 'ts' => '', |
755 | 758 | ); |
— | — | @@ -756,7 +759,7 @@ |
757 | 760 | // insert tracking data and get the tracking id |
758 | 761 | $data['contribution_tracking_id'] = self::insertContributionTracking( $tracked_contribution ); |
759 | 762 | |
760 | | - if ( !$data[ 'contribution_tracking_id' ] ) { |
| 763 | + if ( !$data['contribution_tracking_id'] ) { |
761 | 764 | return false; |
762 | 765 | } |
763 | 766 | return true; |
— | — | @@ -772,16 +775,18 @@ |
773 | 776 | public static function insertContributionTracking( $tracking_data ) { |
774 | 777 | $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
775 | 778 | |
776 | | - if ( !$db ) { return false; } |
| 779 | + if ( !$db ) { |
| 780 | + return false; |
| 781 | + } |
777 | 782 | |
778 | 783 | // 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(); |
781 | 786 | } |
782 | 787 | |
783 | 788 | // Store the contribution data |
784 | 789 | if ( $db->insert( 'contribution_tracking', $tracking_data ) ) { |
785 | | - return $db->insertId(); |
| 790 | + return $db->insertId(); |
786 | 791 | } else { |
787 | 792 | return false; |
788 | 793 | } |
— | — | @@ -801,8 +806,8 @@ |
802 | 807 | // clean up the optout values if necessary |
803 | 808 | if ( $clean_optouts ) { |
804 | 809 | $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']; |
807 | 812 | } |
808 | 813 | |
809 | 814 | // define valid tracking fields |
— | — | @@ -822,7 +827,7 @@ |
823 | 828 | foreach ( $tracking_data as $key => $value ) { |
824 | 829 | // Make sure we only have valid fields |
825 | 830 | if ( !in_array( $key, $tracking_fields ) ) { |
826 | | - unset( $tracking_data[ $key ] ); |
| 831 | + unset( $tracking_data[$key] ); |
827 | 832 | } |
828 | 833 | |
829 | 834 | // Make all empty strings NULL |
— | — | @@ -852,12 +857,12 @@ |
853 | 858 | // make sure we have a session open for tracking a CSRF-prevention token |
854 | 859 | self::fnPayflowEnsureSession(); |
855 | 860 | |
856 | | - if ( !isset( $_SESSION[ 'payflowEditToken' ] ) ) { |
| 861 | + if ( !isset( $_SESSION['payflowEditToken'] ) ) { |
857 | 862 | // generate unsalted token to place in the session |
858 | 863 | $token = self::fnPayflowGenerateToken(); |
859 | | - $_SESSION[ 'payflowEditToken' ] = $token; |
| 864 | + $_SESSION['payflowEditToken'] = $token; |
860 | 865 | } else { |
861 | | - $token = $_SESSION[ 'payflowEditToken' ]; |
| 866 | + $token = $_SESSION['payflowEditToken']; |
862 | 867 | } |
863 | 868 | |
864 | 869 | if ( is_array( $salt ) ) { |
— | — | @@ -897,7 +902,7 @@ |
898 | 903 | * Unset the payflow edit token from a user's session |
899 | 904 | */ |
900 | 905 | function fnPayflowUnsetEditToken() { |
901 | | - unset( $_SESSION[ 'payflowEditToken' ] ); |
| 906 | + unset( $_SESSION['payflowEditToken'] ); |
902 | 907 | } |
903 | 908 | |
904 | 909 | /** |
— | — | @@ -908,7 +913,8 @@ |
909 | 914 | */ |
910 | 915 | public static function fnPayflowEnsureSession() { |
911 | 916 | // if the session is already started, do nothing |
912 | | - if ( session_id() ) return; |
| 917 | + if ( session_id() ) |
| 918 | + return; |
913 | 919 | |
914 | 920 | // otherwise, fire it up using global mw function wfSetupSession |
915 | 921 | wfSetupSession(); |
— | — | @@ -925,7 +931,7 @@ |
926 | 932 | |
927 | 933 | // fetch ID for the url reference for OWA tracking |
928 | 934 | $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 ) ) { |
930 | 936 | $owa_ref = $this->get_owa_ref_id( $owa_ref ); |
931 | 937 | } |
932 | 938 | |
— | — | @@ -943,7 +949,7 @@ |
944 | 950 | $card_index = array_rand( $cards ); |
945 | 951 | |
946 | 952 | // 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]] ); |
948 | 954 | |
949 | 955 | $data = array( |
950 | 956 | 'amount' => ( $amount != "0.00" ) ? $amount : "35", |
— | — | @@ -966,8 +972,8 @@ |
967 | 973 | 'country2' => 'US', |
968 | 974 | 'size' => 'small', |
969 | 975 | '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], |
972 | 978 | 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
973 | 979 | 'cvv' => '001', |
974 | 980 | 'currency' => 'USD', |
— | — | @@ -1016,7 +1022,7 @@ |
1017 | 1023 | * to be 'country' for downstream processing (until we fully support passing in two separate addresses). I thought about completely |
1018 | 1024 | * disabling country2 support in the forms, etc but realized there's a chance it'll be resurrected shortly. Hence this silly hack. |
1019 | 1025 | */ |
1020 | | - 'country2' => ( strlen( $wgRequest->getText( 'country2' ))) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ), |
| 1026 | + 'country2' => ( strlen( $wgRequest->getText( 'country2' ) )) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ), |
1021 | 1027 | 'size' => $wgRequest->getText( 'size' ), |
1022 | 1028 | 'premium_language' => $wgRequest->getText( 'premium_language', "en" ), |
1023 | 1029 | 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ), |
— | — | @@ -1047,7 +1053,7 @@ |
1048 | 1054 | 'owa_ref' => $owa_ref, |
1049 | 1055 | ); |
1050 | 1056 | } |
1051 | | - |
| 1057 | + |
1052 | 1058 | // sanitize user input |
1053 | 1059 | array_walk( $data, array( $this, 'sanitizeInput' ) ); |
1054 | 1060 | |
— | — | @@ -1067,7 +1073,7 @@ |
1068 | 1074 | public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) { |
1069 | 1075 | $value = htmlspecialchars( $value, $flags, 'UTF-8', $double_encode ); |
1070 | 1076 | } |
1071 | | - |
| 1077 | + |
1072 | 1078 | public function getPossibleErrors() { |
1073 | 1079 | return array( |
1074 | 1080 | 'general' => '', |
— | — | @@ -1139,7 +1145,8 @@ |
1140 | 1146 | |
1141 | 1147 | // if there are no sourceparts element, then the banner portion of the string needs to be set. |
1142 | 1148 | // 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] = ''; |
1144 | 1151 | |
1145 | 1152 | // if the utm_source_id is set, set the landing page portion of the string to cc# |
1146 | 1153 | $source_parts[1] = ( $utm_source_id ) ? 'cc' . $utm_source_id : ( isset( $source_parts[1] ) ? $source_parts[1] : '' ); |
— | — | @@ -1161,8 +1168,8 @@ |
1162 | 1169 | // ony update contrib tracking if we're coming from a single-step landing page |
1163 | 1170 | // which we know with cc# in utm_source or if force=true or if contribution_tracking_id is not set |
1164 | 1171 | 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'] ) ) { |
1167 | 1174 | return; |
1168 | 1175 | } |
1169 | 1176 | |
— | — | @@ -1172,18 +1179,20 @@ |
1173 | 1180 | |
1174 | 1181 | $db = payflowGatewayConnection(); |
1175 | 1182 | |
1176 | | - if ( !$db ) { return true ; } |
| 1183 | + if ( !$db ) { |
| 1184 | + return true; |
| 1185 | + } |
1177 | 1186 | |
1178 | 1187 | $tracked_contribution = array( |
1179 | 1188 | 'note' => $data['comment'], |
1180 | 1189 | 'referrer' => $data['referrer'], |
1181 | | - 'anonymous' => $optout[ 'anonymous' ], |
| 1190 | + 'anonymous' => $optout['anonymous'], |
1182 | 1191 | 'utm_source' => $data['utm_source'], |
1183 | 1192 | 'utm_medium' => $data['utm_medium'], |
1184 | 1193 | 'utm_campaign' => $data['utm_campaign'], |
1185 | 1194 | 'owa_session' => $data['owa_session'], |
1186 | 1195 | 'owa_ref' => $data['owa_ref'], |
1187 | | - 'optout' => $optout[ 'optout' ], |
| 1196 | + 'optout' => $optout['optout'], |
1188 | 1197 | 'language' => $data['language'], |
1189 | 1198 | ); |
1190 | 1199 | |
— | — | @@ -1195,10 +1204,10 @@ |
1196 | 1205 | } |
1197 | 1206 | |
1198 | 1207 | // 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 ); |
1201 | 1210 | } 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'] ) ); |
1203 | 1212 | } |
1204 | 1213 | } |
1205 | 1214 | |
— | — | @@ -1215,42 +1224,42 @@ |
1216 | 1225 | |
1217 | 1226 | // if we don't have a URL enabled throw a graceful error to the user |
1218 | 1227 | 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' ); |
1220 | 1229 | return; |
1221 | 1230 | } |
1222 | 1231 | |
1223 | 1232 | // 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'] ); |
1225 | 1234 | $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']; |
1229 | 1238 | /** |
1230 | 1239 | * update contribution tracking |
1231 | 1240 | */ |
1232 | 1241 | $this->updateContributionTracking( $data, true ); |
1233 | 1242 | |
1234 | | - $wgPayflowProGatewayPaypalURL .= "/" . $data[ 'language' ] . "?gateway=paypal"; |
1235 | | - |
| 1243 | + $wgPayflowProGatewayPaypalURL .= "/" . $data['language'] . "?gateway=paypal"; |
| 1244 | + |
1236 | 1245 | // submit the data to the paypal redirect URL |
1237 | 1246 | $wgOut->redirect( $wgPayflowProGatewayPaypalURL . '&' . http_build_query( $data ) ); |
1238 | 1247 | } |
1239 | | - |
| 1248 | + |
1240 | 1249 | public static function log( $msg, $identifier='payflowpro_gateway', $log_level=LOG_INFO ) { |
1241 | 1250 | global $wgPayflowGatewayUseSyslog; |
1242 | | - |
| 1251 | + |
1243 | 1252 | // if we're not using the syslog facility, use wfDebugLog |
1244 | 1253 | if ( !$wgPayflowGatewayUseSyslog ) { |
1245 | 1254 | wfDebugLog( $identifier, $msg ); |
1246 | 1255 | return; |
1247 | 1256 | } |
1248 | | - |
| 1257 | + |
1249 | 1258 | // otherwise, use syslogging |
1250 | 1259 | openlog( $identifier, LOG_ODELAY, LOG_SYSLOG ); |
1251 | 1260 | syslog( $log_level, $msg ); |
1252 | | - closelog(); |
| 1261 | + closelog(); |
1253 | 1262 | } |
1254 | | - |
| 1263 | + |
1255 | 1264 | /** |
1256 | 1265 | * Convert an amount for a particular currency to an amount in USD |
1257 | 1266 | * |
— | — | @@ -1325,7 +1334,10 @@ |
1326 | 1335 | $usd_amount = $amount; |
1327 | 1336 | break; |
1328 | 1337 | } |
1329 | | - |
| 1338 | + |
1330 | 1339 | return $usd_amount; |
1331 | 1340 | } |
1332 | | -} // end class |
| 1341 | + |
| 1342 | +} |
| 1343 | + |
| 1344 | +// end class |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php |
— | — | @@ -1,44 +1,31 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$dir = dirname( __FILE__ ) . '/'; |
5 | | -require_once( $dir . '../gateway_common/gateway.adapter.php' ); |
6 | | - |
7 | 4 | class PayflowProAdapter extends GatewayAdapter { |
8 | 5 | //Contains the map of THEIR var names, to OURS. |
9 | 6 | //I'd have gone the other way, but we'd run into 1:many pretty quick. |
10 | 7 | |
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'; |
15 | 12 | |
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 | + } |
17 | 20 | |
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", |
38 | 26 | ); |
| 27 | + } |
39 | 28 | |
40 | | - |
41 | | - ///ehh. Most of this should be broken up into functions for the sake of readibility. |
42 | | - |
| 29 | + function defineVarMap() { |
43 | 30 | $this->var_map = array( |
44 | 31 | 'ORDERID' => 'order_id', |
45 | 32 | 'AMOUNT' => 'amount', |
— | — | @@ -49,121 +36,70 @@ |
50 | 37 | 'RETURNURL' => 'returnto', //I think. It might not even BE here yet. Boo-urns. |
51 | 38 | 'IPADDRESS' => 'user_ip', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm. |
52 | 39 | ); |
| 40 | + } |
53 | 41 | |
| 42 | + function defineReturnValueMap() { |
54 | 43 | $this->return_value_map = array( |
55 | 44 | 'OK' => true, |
56 | 45 | 'NOK' => false, |
57 | 46 | ); |
| 47 | + } |
58 | 48 | |
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( ); |
67 | 51 | |
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' |
96 | 69 | ), |
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', |
115 | 78 | ) |
116 | 79 | ) |
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 | | - ) |
136 | 80 | ) |
137 | 81 | ), |
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', |
144 | 95 | // '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( ) |
166 | 99 | ) |
167 | 100 | ), |
| 101 | + 'values' => array( |
| 102 | + 'ACTION' => 'TEST_CONNECTION' |
| 103 | + ) |
168 | 104 | ); |
169 | 105 | } |
170 | 106 | |
— | — | @@ -176,10 +112,10 @@ |
177 | 113 | } |
178 | 114 | |
179 | 115 | //TODO: Actually pull these status messages from somewhere legit. |
180 | | - if ( $response['result'] !== false ){ |
| 116 | + if ( $response['result'] !== false ) { |
181 | 117 | //now, parse the thing. |
182 | | - |
183 | | - |
| 118 | + |
| 119 | + |
184 | 120 | if ( $response['status'] === true ) { |
185 | 121 | $response['message'] = "$transaction Transaction Successful!"; |
186 | 122 | } elseif ( $response['status'] === false ) { |
— | — | @@ -204,27 +140,51 @@ |
205 | 141 | * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off. |
206 | 142 | * return a string. |
207 | 143 | */ |
208 | | - function getTrimmedResponse( $rawResponse ){} |
209 | | - |
| 144 | + function getTrimmedResponse( $rawResponse ) { |
| 145 | + |
| 146 | + } |
| 147 | + |
210 | 148 | /** |
211 | 149 | * Parse the response to get the status. Not sure if this should return a bool, or something more... telling. |
212 | 150 | */ |
213 | | - function getResponseStatus( $response ){} |
214 | | - |
| 151 | + function getResponseStatus( $response ) { |
| 152 | + |
| 153 | + } |
| 154 | + |
215 | 155 | /** |
216 | 156 | * Parse the response to get the errors in a format we can log and otherwise deal with. |
217 | 157 | * return a key/value array of codes (if they exist) and messages. |
218 | 158 | */ |
219 | | - function getResponseErrors( $response ){} |
220 | | - |
| 159 | + function getResponseErrors( $response ) { |
| 160 | + |
| 161 | + } |
| 162 | + |
221 | 163 | /** |
222 | 164 | * Harvest the data we need back from the gateway. |
223 | 165 | * return a key/value array |
224 | 166 | */ |
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 | + |
229 | 189 | function parseXMLResponse( $rawResponse ) { |
230 | 190 | //TODO: Something. |
231 | 191 | $rawXML = $this->stripResponseHeaders( $rawResponse ); |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -21,26 +21,7 @@ |
22 | 22 | // Set up the new special page |
23 | 23 | $dir = dirname( __FILE__ ) . '/'; |
24 | 24 | $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'; |
45 | 26 | |
46 | 27 | $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php'; |
47 | 28 | $wgExtensionMessagesFiles['PayflowProGatewayCountries'] = $dir . 'payflowpro_gateway.countries.i18n.php'; |
— | — | @@ -139,7 +120,7 @@ |
140 | 121 | * /never/ be loaded by the rapid html form loader! |
141 | 122 | * @var string |
142 | 123 | */ |
143 | | -$wgPayflowProGatewayAllowedHtmlForms = array( $wgPayflowProGatewayHtmlFormDir . "/demo.html" ); |
| 124 | +$wgPayflowProGatewayAllowedHtmlForms = $wgDonationInterfaceAllowedHtmlForms; |
144 | 125 | |
145 | 126 | /** |
146 | 127 | * Configure PayflowproGateway to use syslog for log messages rather than wfDebugLog |
— | — | @@ -168,7 +149,6 @@ |
169 | 150 | $wgAPIModules['pfp'] = 'ApiPayflowProGateway'; |
170 | 151 | $wgAutoloadClasses['ApiPayflowProGateway'] = $dir . 'api_payflowpro_gateway.php'; |
171 | 152 | |
172 | | - |
173 | 153 | /** |
174 | 154 | * Hook to register form value and display name of this gateway |
175 | 155 | * also supplies currencies supported by this gateway |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter2.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | class Gateway_Form_TwoColumnLetter2 extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | public $paypal = false; // true for paypal only version |
6 | 6 | |
7 | | - public function __construct( &$form_data, &$form_errors ) { |
| 7 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
8 | 8 | global $wgScriptPath; |
9 | 9 | |
10 | 10 | // 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 @@ |
12 | 12 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' ); |
13 | 13 | } |
14 | 14 | |
15 | | - parent::__construct( $form_data, $form_errors ); |
| 15 | + parent::__construct( $form_data, $form_errors, $gateway ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter3.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | class Gateway_Form_TwoColumnLetter3 extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | public $paypal = false; // true for paypal only version |
6 | 6 | |
7 | | - public function __construct( &$form_data, &$form_errors ) { |
| 7 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
8 | 8 | global $wgScriptPath; |
9 | 9 | |
10 | 10 | // 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 @@ |
12 | 12 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' ); |
13 | 13 | } |
14 | 14 | |
15 | | - parent::__construct( $form_data, $form_errors ); |
| 15 | + parent::__construct( $form_data, $form_errors, $gateway ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter4.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | class Gateway_Form_TwoColumnLetter4 extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | public $paypal = false; // true for paypal only version |
6 | 6 | |
7 | | - public function __construct( &$form_data, &$form_errors ) { |
| 7 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
8 | 8 | global $wgScriptPath; |
9 | 9 | |
10 | 10 | // 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 @@ |
12 | 12 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter4.css' ); |
13 | 13 | } |
14 | 14 | |
15 | | - parent::__construct( $form_data, $form_errors ); |
| 15 | + parent::__construct( $form_data, $form_errors, $gateway ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter5.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class Gateway_Form_TwoColumnLetter5 extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | |
6 | | - public function __construct( &$form_data, &$form_errors ) { |
| 6 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
7 | 7 | global $wgScriptPath; |
8 | 8 | |
9 | 9 | // 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 @@ |
11 | 11 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter5.css' ); |
12 | 12 | } |
13 | 13 | |
14 | | - parent::__construct( $form_data, $form_errors ); |
| 14 | + parent::__construct( $form_data, $form_errors, $gateway ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter6.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class Gateway_Form_TwoColumnLetter6 extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | |
6 | | - public function __construct( &$form_data, &$form_errors ) { |
| 6 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
7 | 7 | global $wgScriptPath; |
8 | 8 | |
9 | 9 | // 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 @@ |
11 | 11 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter6.css' ); |
12 | 12 | } |
13 | 13 | |
14 | | - parent::__construct( $form_data, $form_errors ); |
| 14 | + parent::__construct( $form_data, $form_errors, $gateway ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ) { |
6 | 6 | global $wgScriptPath; |
7 | 7 | |
8 | 8 | // 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 @@ |
10 | 10 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' ); |
11 | 11 | } |
12 | 12 | |
13 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + parent::__construct( $form_data, $form_errors, $gateway ); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter7.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class Gateway_Form_TwoColumnLetter7 extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | |
6 | | - public function __construct( &$form_data, &$form_errors ) { |
| 6 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
7 | 7 | global $wgScriptPath; |
8 | 8 | |
9 | 9 | // 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 @@ |
11 | 11 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter7.css' ); |
12 | 12 | } |
13 | 13 | |
14 | | - parent::__construct( $form_data, $form_errors ); |
| 14 | + parent::__construct( $form_data, $form_errors, $gateway ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function loadPlaceholders() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnPayPal.php |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ); |
7 | 7 | } |
8 | 8 | |
9 | 9 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/SingleColumn.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class Gateway_Form_SingleColumn extends Gateway_Form_TwoColumnLetter { |
5 | 5 | |
6 | | - public function __construct( &$form_data, &$form_errors ) { |
| 6 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
7 | 7 | global $wgScriptPath; |
8 | 8 | |
9 | 9 | // 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 @@ |
11 | 11 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/SingleColumn.css' ); |
12 | 12 | } |
13 | 13 | |
14 | | - parent::__construct( $form_data, $form_errors ); |
| 14 | + parent::__construct( $form_data, $form_errors, $gateway ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function generateFormEnd() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ) { |
6 | 6 | global $wgScriptPath; |
7 | 7 | |
8 | 8 | // 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 @@ |
10 | 10 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' ); |
11 | 11 | } |
12 | 12 | |
13 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + parent::__construct( $form_data, $form_errors, $gateway ); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -49,12 +49,13 @@ |
50 | 50 | */ |
51 | 51 | abstract function getForm(); |
52 | 52 | |
53 | | - public function __construct( &$data, &$error ) { |
| 53 | + public function __construct( &$data, &$error, &$gateway ) { |
54 | 54 | global $wgDonationInterfaceTest, $wgOut; |
55 | 55 | |
56 | 56 | $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; |
59 | 60 | |
60 | 61 | /** |
61 | 62 | * add form-specific css - the path can be set in child classes |
— | — | @@ -71,7 +72,7 @@ |
72 | 73 | * We do this here (rather than in individual forms) because if OWA is |
73 | 74 | * enabled, we ALWAYS want to make sure it gets included. |
74 | 75 | */ |
75 | | - if(defined('OWA')){ |
| 76 | + if ( defined( 'OWA' ) ) { |
76 | 77 | $this->loadOwaJs(); |
77 | 78 | } |
78 | 79 | } |
— | — | @@ -141,7 +142,7 @@ |
142 | 143 | |
143 | 144 | // create a new array of countries with potentially translated country names for alphabetizing later |
144 | 145 | 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 ); |
146 | 147 | } |
147 | 148 | |
148 | 149 | // alphabetically sort the country names |
— | — | @@ -149,8 +150,8 @@ |
150 | 151 | |
151 | 152 | // generate a dropdown option for each country |
152 | 153 | 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; |
155 | 156 | } else { |
156 | 157 | $selected = ( $iso_value == $defaultCountry ) ? true : false; // Select default |
157 | 158 | } |
— | — | @@ -159,8 +160,7 @@ |
160 | 161 | |
161 | 162 | // build the actual select |
162 | 163 | $country_menu = Xml::openElement( |
163 | | - 'select', |
164 | | - array( |
| 164 | + 'select', array( |
165 | 165 | 'name' => 'country', |
166 | 166 | 'id' => 'country' |
167 | 167 | ) ); |
— | — | @@ -190,14 +190,13 @@ |
191 | 191 | // generate a dropdown opt for each card |
192 | 192 | foreach ( $available_cards as $value => $card_name ) { |
193 | 193 | // 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; |
195 | 195 | $card_options .= Xml::option( $card_name, $value, $selected ); |
196 | 196 | } |
197 | 197 | |
198 | 198 | // build the actual select |
199 | 199 | $card_menu = Xml::openElement( |
200 | | - 'select', |
201 | | - array( |
| 200 | + 'select', array( |
202 | 201 | 'name' => 'card_type', |
203 | 202 | 'id' => 'card_type' |
204 | 203 | ) ); |
— | — | @@ -212,8 +211,8 @@ |
213 | 212 | |
214 | 213 | // derive the previously set expiry month, if set |
215 | 214 | $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 ); |
218 | 217 | } |
219 | 218 | |
220 | 219 | $expiry_months = ''; |
— | — | @@ -222,14 +221,11 @@ |
223 | 222 | for ( $i = 1; $i < 13; $i++ ) { |
224 | 223 | $selected = ( $i == $month && $this->test ) ? true : false; |
225 | 224 | $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 ); |
229 | 226 | } |
230 | 227 | |
231 | 228 | $expiry_month_menu = Xml::openElement( |
232 | | - 'select', |
233 | | - array( |
| 229 | + 'select', array( |
234 | 230 | 'name' => 'mos', |
235 | 231 | 'id' => 'expiration' |
236 | 232 | ) ); |
— | — | @@ -241,8 +237,8 @@ |
242 | 238 | public function generateExpiryYearDropdown() { |
243 | 239 | // derive the previously set expiry year, if set |
244 | 240 | $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 ); |
247 | 243 | } |
248 | 244 | |
249 | 245 | $expiry_years = ''; |
— | — | @@ -255,8 +251,7 @@ |
256 | 252 | } |
257 | 253 | |
258 | 254 | $expiry_year_menu = Xml::openElement( |
259 | | - 'select', |
260 | | - array( |
| 255 | + 'select', array( |
261 | 256 | 'name' => 'year', |
262 | 257 | 'id' => 'year', |
263 | 258 | ) ); |
— | — | @@ -280,13 +275,12 @@ |
281 | 276 | |
282 | 277 | // generate dropdown of state opts |
283 | 278 | foreach ( $states as $value => $state_name ) { |
284 | | - $selected = ( $this->form_data[ 'state' ] == $value ) ? true : false; |
| 279 | + $selected = ( $this->form_data['state'] == $value ) ? true : false; |
285 | 280 | $state_opts .= Xml::option( wfMsg( 'payflowpro_gateway-state-dropdown-' . $value ), $value, $selected ); |
286 | 281 | } |
287 | 282 | |
288 | 283 | $state_menu = Xml::openElement( |
289 | | - 'select', |
290 | | - array( |
| 284 | + 'select', array( |
291 | 285 | 'name' => 'state', |
292 | 286 | 'id' => 'state' |
293 | 287 | ) ); |
— | — | @@ -318,13 +312,12 @@ |
319 | 313 | |
320 | 314 | // generate dropdown of currency opts |
321 | 315 | 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; |
323 | 317 | $currency_opts .= Xml::option( wfMsg( 'donate_interface-' . $value ), $value, $selected ); |
324 | 318 | } |
325 | 319 | |
326 | 320 | $currency_menu = Xml::openElement( |
327 | | - 'select', |
328 | | - array( |
| 321 | + 'select', array( |
329 | 322 | 'name' => 'currency_code', |
330 | 323 | 'id' => 'input_currency_code', |
331 | 324 | 'onchange' => 'showCards()' |
— | — | @@ -343,28 +336,28 @@ |
344 | 337 | */ |
345 | 338 | public function setHiddenFields( $hidden_fields = NULL ) { |
346 | 339 | 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'], |
358 | 351 | 'process' => 'CreditCard', |
359 | 352 | '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'], |
369 | 362 | ); |
370 | 363 | } |
371 | 364 | |
— | — | @@ -410,15 +403,17 @@ |
411 | 404 | } |
412 | 405 | |
413 | 406 | protected function generateBannerHeader() { |
414 | | - global $wgPayflowProGatewayHeader, $wgOut, $wgRequest; |
| 407 | + global $wgOut, $wgRequest; |
| 408 | + $g = $this->gateway; |
| 409 | + $header = $g::getGlobal( 'Header' ); |
415 | 410 | |
416 | 411 | $template = ''; |
417 | 412 | |
418 | 413 | // intro text |
419 | 414 | 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 ); |
423 | 418 | $template = $wgOut->parse( $header ); |
424 | 419 | } |
425 | 420 | |
— | — | @@ -455,13 +450,13 @@ |
456 | 451 | $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount' ) . '</td>'; |
457 | 452 | $form .= '<td>' . Xml::radio( 'amount', 100, $this->form_data['amount'] == 100 ) . '100 ' . |
458 | 453 | 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 ' . |
460 | 455 | Xml::radio( 'amount', 20, $this->form_data['amount'] == 20 ) . '20 ' . |
461 | 456 | '</td>'; |
462 | 457 | $form .= '</tr>'; |
463 | 458 | $form .= '<tr>'; |
464 | 459 | $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' ) ) . |
466 | 461 | ' ' . $this->generateCurrencyDropdown() . '</td>'; |
467 | 462 | $form .= '</tr>'; |
468 | 463 | return $form; |
— | — | @@ -469,7 +464,7 @@ |
470 | 465 | |
471 | 466 | protected function getCardnumberField() { |
472 | 467 | global $wgDonationInterfaceTest; |
473 | | - $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data[ 'card_num' ] : ''; |
| 468 | + $card_num = ( $wgDonationInterfaceTest ) ? $this->form_data['card_num'] : ''; |
474 | 469 | $form = ''; |
475 | 470 | if ( $this->form_errors['card_num'] ) { |
476 | 471 | $form .= '<tr>'; |
— | — | @@ -491,7 +486,7 @@ |
492 | 487 | |
493 | 488 | protected function getCvvField() { |
494 | 489 | global $wgDonationInterfaceTest; |
495 | | - $cvv = ( $wgDonationInterfaceTest ) ? $this->form_data[ 'cvv' ] : ''; |
| 490 | + $cvv = ( $wgDonationInterfaceTest ) ? $this->form_data['cvv'] : ''; |
496 | 491 | |
497 | 492 | $form = '<tr>'; |
498 | 493 | $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['cvv'] . '</span></td>'; |
— | — | @@ -549,8 +544,8 @@ |
550 | 545 | $form .= '</tr>'; |
551 | 546 | $form .= '<tr>'; |
552 | 547 | $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>'; |
555 | 550 | $form .= "</tr>"; |
556 | 551 | return $form; |
557 | 552 | } |
— | — | @@ -558,7 +553,7 @@ |
559 | 554 | protected function getCommentMessageField() { |
560 | 555 | $form = '<tr>'; |
561 | 556 | $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' ) ); |
563 | 558 | $form .= '</td>'; |
564 | 559 | $form .= '</tr>'; |
565 | 560 | return $form; |
— | — | @@ -567,14 +562,14 @@ |
568 | 563 | protected function getCommentField() { |
569 | 564 | $form = '<tr>'; |
570 | 565 | $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>'; |
572 | 567 | $form .= '</tr>'; |
573 | 568 | return $form; |
574 | 569 | } |
575 | 570 | |
576 | 571 | protected function getCommentOptionField() { |
577 | 572 | 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; |
579 | 574 | $form = '<tr>'; |
580 | 575 | $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
581 | 576 | $form .= ' ' . Xml::label( wfMsg( 'donate_interface-anon-message' ), 'comment-option' ) . '</td>'; |
— | — | @@ -584,7 +579,7 @@ |
585 | 580 | |
586 | 581 | protected function getEmailOptField() { |
587 | 582 | 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; |
589 | 584 | $form = '<tr>'; |
590 | 585 | $form .= '<td class="check-option" colspan="2">' . Xml::check( 'email-opt', $email_opt_value ); |
591 | 586 | $form .= ' '; |
— | — | @@ -604,10 +599,8 @@ |
605 | 600 | $form = '<tr>'; |
606 | 601 | $form .= '<td class="paypal-button" colspan="2">'; |
607 | 602 | $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 | + ); |
612 | 605 | $form .= '</td>'; |
613 | 606 | $form .= '</tr>'; |
614 | 607 | return $form; |
— | — | @@ -631,8 +624,8 @@ |
632 | 625 | $form .= '<tr>'; |
633 | 626 | $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-country' ), 'country' ) . '</td>'; |
634 | 627 | $form .= '<td>' . $this->generateCountryDropdown( $defaultCountry ) . '</td>'; |
635 | | - $form .= '</tr>'; |
636 | | - return $form; |
| 628 | + $form .= '</tr>'; |
| 629 | + return $form; |
637 | 630 | } |
638 | 631 | |
639 | 632 | protected function getCreditCardTypeField() { |
— | — | @@ -654,45 +647,44 @@ |
655 | 648 | protected function loadValidateJs() { |
656 | 649 | global $wgOut, $wgScriptPath; |
657 | 650 | $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>' ); |
660 | 653 | } |
661 | 654 | |
662 | 655 | protected function loadApiJs() { |
663 | 656 | global $wgOut, $wgScriptPath; |
664 | 657 | $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>' ); |
667 | 660 | } |
668 | 661 | |
669 | 662 | protected function loadOwaJs() { |
670 | 663 | 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 | + |
673 | 666 | $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>' ); |
676 | 669 | $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>' ); |
680 | 672 | } |
681 | 673 | |
682 | | - |
683 | 674 | /** |
684 | 675 | * Generate HTML for <noscript> tags |
685 | 676 | * |
686 | 677 | * For displaying when a user does not have Javascript enabled in their browser. |
687 | 678 | */ |
688 | 679 | protected function getNoScript() { |
689 | | - global $wgPayflowProGatewayNoScriptRedirect; |
| 680 | + $g = $this->gateway; |
| 681 | + $noScriptRedirect = $g::getGlobal( 'NoScriptRedirect' ); |
690 | 682 | |
691 | 683 | $form = '<noscript>'; |
692 | 684 | $form .= '<div id="noscript">'; |
693 | 685 | $form .= '<p id="noscript-msg">' . wfMsg( 'payflowpro_gateway-noscript-msg' ) . '</p>'; |
694 | | - if ( $wgPayflowProGatewayNoScriptRedirect ) { |
| 686 | + if ( $noScriptRedirect ) { |
695 | 687 | $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>'; |
697 | 689 | } |
698 | 690 | $form .= '</div>'; |
699 | 691 | $form .= '</noscript>'; |
— | — | @@ -712,21 +704,22 @@ |
713 | 705 | |
714 | 706 | $url = $wgRequest->getFullRequestURL(); |
715 | 707 | $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'] ); |
718 | 710 | } else { |
719 | | - $query_array = array(); |
| 711 | + $query_array = array( ); |
720 | 712 | } |
721 | 713 | |
722 | 714 | // ensure that _cache_ does not get set in the URL |
723 | | - unset( $query_array[ '_cache_' ] ); |
| 715 | + unset( $query_array['_cache_'] ); |
724 | 716 | |
725 | 717 | // make sure no other data that might overwrite posted data makes it into the URL |
726 | 718 | foreach ( $this->form_data as $key => $value ) { |
727 | | - unset( $query_array[ $key ] ); |
| 719 | + unset( $query_array[$key] ); |
728 | 720 | } |
729 | 721 | |
730 | 722 | // construct the submission url |
731 | 723 | return wfAppendQuery( $wgTitle->getLocalURL(), $query_array ); |
732 | 724 | } |
| 725 | + |
733 | 726 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoColumnLetter.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | class Gateway_Form_TwoColumnLetter extends Gateway_Form_OneStepTwoColumn { |
5 | 5 | public $paypal = false; // true for paypal only version |
6 | 6 | |
7 | | - public function __construct( &$form_data, &$form_errors ) { |
| 7 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
8 | 8 | global $wgScriptPath; |
9 | 9 | |
10 | 10 | // 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 @@ |
12 | 12 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css' ); |
13 | 13 | } |
14 | 14 | |
15 | | - parent::__construct( $form_data, $form_errors ); |
| 15 | + parent::__construct( $form_data, $form_errors, $gateway ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ) { |
6 | 6 | global $wgScriptPath; |
7 | 7 | |
8 | 8 | // 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 @@ |
10 | 10 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnPremium.css' ); |
11 | 11 | } |
12 | 12 | |
13 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + parent::__construct( $form_data, $form_errors, $gateway ); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function generateFormStart() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php |
— | — | @@ -2,10 +2,10 @@ |
3 | 3 | |
4 | 4 | class Gateway_Form_TwoStepTwoColumn extends Gateway_Form { |
5 | 5 | |
6 | | - public function __construct( &$form_data, &$form_errors ) { |
| 6 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
7 | 7 | global $wgOut; |
8 | 8 | |
9 | | - parent::__construct( $form_data, $form_errors ); |
| 9 | + parent::__construct( $form_data, $form_errors, $gateway ); |
10 | 10 | |
11 | 11 | // we only want to load this JS if the form is being rendered |
12 | 12 | $this->loadValidateJs(); // validation JS |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter2.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ) { |
6 | 6 | global $wgScriptPath; |
7 | 7 | |
8 | 8 | // 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 @@ |
10 | 10 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter2.css' ); |
11 | 11 | } |
12 | 12 | |
13 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + parent::__construct( $form_data, $form_errors, $gateway ); |
14 | 14 | } |
15 | 15 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ) { |
6 | 6 | global $wgExtensionAssetsPath; |
7 | 7 | |
8 | 8 | // 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 @@ |
10 | 10 | $this->setStylePath( $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/TwoStepTwoColumnLetter3.css' ); |
11 | 11 | } |
12 | 12 | |
13 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + parent::__construct( $form_data, $form_errors, $gateway ); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function loadPlaceholders() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/RapidHtml.php |
— | — | @@ -1,13 +1,13 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class Gateway_Form_RapidHtml extends Gateway_Form { |
5 | | - |
| 5 | + |
6 | 6 | /** |
7 | 7 | * Full path of HTML form to load |
8 | 8 | * @var string |
9 | 9 | */ |
10 | 10 | protected $html_file_path = ''; |
11 | | - |
| 11 | + |
12 | 12 | /** |
13 | 13 | * Tokens used in HTML form for data replacement |
14 | 14 | * |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | // @script_path -> maps to $wgScriptPath |
59 | 59 | // @action -> generate correct form action for this form |
60 | 60 | ); |
61 | | - |
| 61 | + |
62 | 62 | /** |
63 | 63 | * Error field names used as tokens |
64 | 64 | * @var array |
— | — | @@ -78,26 +78,26 @@ |
79 | 79 | '#zip', |
80 | 80 | '#emailAdd', |
81 | 81 | ); |
82 | | - |
83 | | - public function __construct( &$form_data, &$form_errors ) { |
| 82 | + |
| 83 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
84 | 84 | global $wgRequest; |
85 | | - parent::__construct( $form_data, $form_errors ); |
| 85 | + parent::__construct( $form_data, $form_errors, $gateway ); |
86 | 86 | |
87 | 87 | $this->loadValidateJs(); |
88 | | - |
| 88 | + |
89 | 89 | // 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 | + |
92 | 92 | // 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'] ) ) { |
94 | 94 | $general_errors = ""; |
95 | | - foreach ( $form_errors[ 'general' ] as $general_error ) { |
| 95 | + foreach ( $form_errors['general'] as $general_error ) { |
96 | 96 | $general_errors .= "<p class='creditcard'>$general_error</p>"; |
97 | 97 | } |
98 | | - $form_errors[ 'general' ] = $general_errors; |
| 98 | + $form_errors['general'] = $general_errors; |
99 | 99 | } |
100 | 100 | } |
101 | | - |
| 101 | + |
102 | 102 | /** |
103 | 103 | * Return the HTML form with data added |
104 | 104 | */ |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | $html = $this->load_html(); |
107 | 107 | return $this->add_data( $html ); |
108 | 108 | } |
109 | | - |
| 109 | + |
110 | 110 | /** |
111 | 111 | * Load the HTML form from a file into a string |
112 | 112 | * @return string |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | public function load_html() { |
115 | 115 | return file_get_contents( $this->html_file_path ); |
116 | 116 | } |
117 | | - |
| 117 | + |
118 | 118 | /** |
119 | 119 | * Add data into the HTML form |
120 | 120 | * |
— | — | @@ -127,34 +127,36 @@ |
128 | 128 | * This is a hack and should be replaced with something more performant. |
129 | 129 | */ |
130 | 130 | $form = $html; |
131 | | - |
| 131 | + |
132 | 132 | // handle form action |
133 | 133 | $form = str_replace( "@action", $this->getNoCacheAction(), $form ); |
134 | 134 | |
135 | 135 | // replace data |
136 | 136 | 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]; |
142 | 144 | } else { |
143 | 145 | $replace = ''; |
144 | 146 | } |
145 | 147 | $form = str_replace( $token, $replace, $form ); |
146 | 148 | } |
147 | | - |
| 149 | + |
148 | 150 | // replace errors |
149 | 151 | $form = str_replace( $this->error_tokens, $this->form_errors, $form ); |
150 | 152 | |
151 | 153 | // handle captcha |
152 | 154 | $form = str_replace( "@captcha", $this->getCaptchaHtml(), $form ); |
153 | | - |
| 155 | + |
154 | 156 | // handle script path |
155 | 157 | $form = str_replace( "@script_path", $wgScriptPath, $form ); |
156 | | - |
| 158 | + |
157 | 159 | $form = $this->fix_dropdowns( $form ); |
158 | | - |
| 160 | + |
159 | 161 | return $form; |
160 | 162 | } |
161 | 163 | |
— | — | @@ -170,83 +172,77 @@ |
171 | 173 | // currency code |
172 | 174 | $start = strpos( $html, 'name="currency_code"' ); |
173 | 175 | if ( $start ) { |
174 | | - $currency_code = $this->form_data[ 'currency' ]; |
| 176 | + $currency_code = $this->form_data['currency']; |
175 | 177 | $end = strpos( $html, '</select>', $start ); |
176 | | - $str = substr( $html, $start, ( $end - $start )); |
| 178 | + $str = substr( $html, $start, ( $end - $start ) ); |
177 | 179 | $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 ); |
179 | 181 | } |
180 | | - |
| 182 | + |
181 | 183 | // mos |
182 | | - $month = substr( $this->form_data[ 'expiration' ], 0, 2 ); |
| 184 | + $month = substr( $this->form_data['expiration'], 0, 2 ); |
183 | 185 | $start = strpos( $html, 'name="mos"' ); |
184 | 186 | if ( $start ) { |
185 | 187 | $end = strpos( $html, '</select>', $start ); |
186 | | - $str = substr( $html, $start, ( $end - $start )); |
| 188 | + $str = substr( $html, $start, ( $end - $start ) ); |
187 | 189 | $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 ); |
189 | 191 | } |
190 | | - |
| 192 | + |
191 | 193 | // year |
192 | | - $year = substr( $this->form_data[ 'expiration' ], 2, 2 ); |
| 194 | + $year = substr( $this->form_data['expiration'], 2, 2 ); |
193 | 195 | $start = strpos( $html, 'name="year"' ); |
194 | | - if ( $start ) { |
| 196 | + if ( $start ) { |
195 | 197 | $end = strpos( $html, '</select>', $start ); |
196 | | - $str = substr( $html, $start, ( $end - $start )); |
| 198 | + $str = substr( $html, $start, ( $end - $start ) ); |
197 | 199 | // dbl extra huge hack alert! note the '20' prefix... |
198 | 200 | $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 ); |
200 | 202 | } |
201 | | - |
| 203 | + |
202 | 204 | // state |
203 | | - $state = $this->form_data[ 'state' ]; |
| 205 | + $state = $this->form_data['state']; |
204 | 206 | $start = strpos( $html, 'name="state"' ); |
205 | 207 | if ( $start ) { |
206 | 208 | $end = strpos( $html, '</select>', $start ); |
207 | | - $str = substr( $html, $start, ( $end - $start )); |
| 209 | + $str = substr( $html, $start, ( $end - $start ) ); |
208 | 210 | $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 ); |
210 | 212 | } |
211 | | - |
| 213 | + |
212 | 214 | //country |
213 | | - $country = $this->form_data[ 'country' ]; |
| 215 | + $country = $this->form_data['country']; |
214 | 216 | $start = strpos( $html, 'name="country"' ); |
215 | 217 | if ( $start ) { |
216 | 218 | $end = strpos( $html, '</select>', $start ); |
217 | | - $str = substr( $html, $start, ( $end - $start )); |
| 219 | + $str = substr( $html, $start, ( $end - $start ) ); |
218 | 220 | $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 ); |
220 | 222 | } |
221 | | - |
| 223 | + |
222 | 224 | return $html; |
223 | 225 | } |
224 | | - |
| 226 | + |
225 | 227 | /** |
226 | 228 | * Validate and set the path to the HTML file |
227 | 229 | * |
228 | 230 | * @param string $file_name |
229 | 231 | */ |
230 | 232 | 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 | + |
248 | 243 | throw new MWException( 'Requested an unavailable or non-existent form.' ); |
249 | 244 | } |
250 | | - |
251 | | - $this->html_file_path = $full_path; |
| 245 | + |
| 246 | + $this->html_file_path = $allowedForms[$file_name]; |
252 | 247 | } |
| 248 | + |
253 | 249 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 ) { |
6 | 6 | global $wgScriptPath; |
7 | 7 | |
8 | 8 | // 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 @@ |
10 | 10 | $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnPremiumUS.css' ); |
11 | 11 | } |
12 | 12 | |
13 | | - parent::__construct( $form_data, $form_errors ); |
| 13 | + parent::__construct( $form_data, $form_errors, $gateway ); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function loadPlaceholders() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_forms/OneStepTwoColumn.php |
— | — | @@ -3,10 +3,10 @@ |
4 | 4 | class Gateway_Form_OneStepTwoColumn extends Gateway_Form { |
5 | 5 | public $paypal = false; // true for paypal only version |
6 | 6 | |
7 | | - public function __construct( &$form_data, &$form_errors ) { |
| 7 | + public function __construct( &$form_data, &$form_errors, &$gateway ) { |
8 | 8 | global $wgOut; |
9 | 9 | |
10 | | - parent::__construct( $form_data, $form_errors ); |
| 10 | + parent::__construct( $form_data, $form_errors, $gateway ); |
11 | 11 | |
12 | 12 | // update the list of hidden fields we need to use in this form. |
13 | 13 | $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&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, 'First' )" maxlength="25" class="required" id="fname" /> |
| 38 | + <input name="lname" size="30" value="@lname" type="text" onfocus="clearField( this, 'Last' )" 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 @@ |
21 | 21 | * Holds the GlobalCollect response from a transaction |
22 | 22 | * @var array |
23 | 23 | */ |
24 | | - public $payflow_response = array(); |
| 24 | + public $payflow_response = array( ); |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * A container for the form class |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | * An array of form errors |
36 | 36 | * @var array |
37 | 37 | */ |
38 | | - public $errors = array(); |
| 38 | + public $errors = array( ); |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Constructor - set up the new special page |
— | — | @@ -42,9 +42,7 @@ |
43 | 43 | public function __construct() { |
44 | 44 | parent::__construct( 'GlobalCollectGateway' ); |
45 | 45 | $this->errors = $this->getPossibleErrors(); |
46 | | - |
47 | | - $dir = dirname( __FILE__ ) . '/'; |
48 | | - require_once($dir . 'globalcollect.adapter.php'); |
| 46 | + |
49 | 47 | $this->adapter = new GlobalCollectAdapter(); |
50 | 48 | } |
51 | 49 | |
— | — | @@ -55,7 +53,7 @@ |
56 | 54 | */ |
57 | 55 | public function execute( $par ) { |
58 | 56 | global $wgRequest, $wgOut, $wgExtensionAssetsPath, |
59 | | - $wgPayFlowProGatewayCSSVersion; |
| 57 | + $wgPayFlowProGatewayCSSVersion; |
60 | 58 | |
61 | 59 | $wgOut->addExtensionStyle( |
62 | 60 | $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/gateway.css?284' . |
— | — | @@ -83,29 +81,28 @@ |
84 | 82 | $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
85 | 83 | |
86 | 84 | // @fixme can this be moved into the form generators? |
87 | | - $js = <<<EOT |
| 85 | + $js = <<<EOT |
88 | 86 | <script type="text/javascript"> |
89 | 87 | jQuery(document).ready(function() { |
90 | 88 | jQuery("div#p-logo a").attr("href","#"); |
91 | 89 | }); |
92 | 90 | </script> |
93 | 91 | EOT; |
94 | | - $wgOut->addHeadItem( 'logolinkoverride', $js ); |
| 92 | + $wgOut->addHeadItem( 'logolinkoverride', $js ); |
95 | 93 | |
96 | | - $this->setHeaders(); |
97 | | - |
| 94 | + $this->setHeaders(); |
| 95 | + |
98 | 96 | //TODO: This is short-circuiting what I really want to do here. |
99 | 97 | //so stop it. |
100 | 98 | $data = $this->adapter->getDisplayData(); |
101 | | - |
| 99 | + |
102 | 100 | // dispatch forms/handling |
103 | 101 | if ( $this->adapter->checkTokens() ) { |
104 | 102 | if ( $this->adapter->posted && $data['payment_method'] == 'processed' ) { |
105 | | - $this->adapter->log("Posted and processed."); |
106 | | - |
| 103 | + $this->adapter->log( "Posted and processed." ); |
| 104 | + |
107 | 105 | // increase the count of attempts |
108 | 106 | //++$data['numAttempt']; |
109 | | - |
110 | 107 | // Check form for errors and redisplay with messages |
111 | 108 | $form_errors = $this->fnPayflowValidateForm( $data, $this->errors ); |
112 | 109 | |
— | — | @@ -113,32 +110,28 @@ |
114 | 111 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
115 | 112 | } else { // The submitted form data is valid, so process it |
116 | 113 | // allow any external validators to have their way with the data |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | 114 | $result = $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
122 | 115 | //$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" ); |
129 | 122 | } |
130 | | - $wgOut->addHTML("</ul>"); |
| 123 | + $wgOut->addHTML( "</ul>" ); |
131 | 124 | } |
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" ); |
137 | 130 | } |
138 | | - $wgOut->addHTML("</ul>"); |
| 131 | + $wgOut->addHTML( "</ul>" ); |
139 | 132 | } |
140 | | - |
141 | | - |
142 | | - |
| 133 | + |
| 134 | + |
| 135 | + |
143 | 136 | // self::log( $data[ 'order_id' ] . " Preparing to query MaxMind" ); |
144 | 137 | // wfRunHooks( 'PayflowGatewayValidate', array( &$this, &$data ) ); |
145 | 138 | // self::log( $data[ 'order_id' ] . ' Finished querying Maxmind' ); |
— | — | @@ -176,9 +169,9 @@ |
177 | 170 | } |
178 | 171 | } else { |
179 | 172 | // 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." ); |
181 | 174 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
182 | | - } |
| 175 | + } |
183 | 176 | } else { |
184 | 177 | if ( !$this->adapter->isCache() ) { |
185 | 178 | // if we're not caching, there's a token mismatch |
— | — | @@ -187,7 +180,6 @@ |
188 | 181 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
189 | 182 | } |
190 | 183 | } |
191 | | - |
192 | 184 | |
193 | 185 | /** |
194 | 186 | * Build and display form to user |
— | — | @@ -210,7 +202,7 @@ |
211 | 203 | // } |
212 | 204 | |
213 | 205 | $form_class = $this->getFormClass(); |
214 | | - $form_obj = new $form_class( $data, $error ); |
| 206 | + $form_obj = new $form_class( $data, $error, $this->adapter ); |
215 | 207 | $form = $form_obj->getForm(); |
216 | 208 | $wgOut->addHTML( $form ); |
217 | 209 | } |
— | — | @@ -245,7 +237,7 @@ |
246 | 238 | * Using logic in setFormClass() |
247 | 239 | * @return string |
248 | 240 | */ |
249 | | - public function getFormClass( ) { |
| 241 | + public function getFormClass() { |
250 | 242 | if ( !isset( $this->form_class ) ) { |
251 | 243 | $this->setFormClass(); |
252 | 244 | } |
— | — | @@ -257,7 +249,7 @@ |
258 | 250 | */ |
259 | 251 | private function fnPayflowValidateForm( &$data, &$error ) { |
260 | 252 | global $wgPayflowProGatewayPriceFloor, $wgPayflowProGatewayPriceCeiling; |
261 | | - |
| 253 | + |
262 | 254 | // begin with no errors |
263 | 255 | $error_result = '0'; |
264 | 256 | |
— | — | @@ -279,7 +271,7 @@ |
280 | 272 | |
281 | 273 | // find all empty fields and create message |
282 | 274 | foreach ( $data as $key => $value ) { |
283 | | - if ( $value == '' || ($key == 'state' && $value == 'YY' )) { |
| 275 | + if ( $value == '' || ($key == 'state' && $value == 'YY' ) ) { |
284 | 276 | // ignore fields that are not required |
285 | 277 | if ( isset( $msg[$key] ) ) { |
286 | 278 | $error[$key] = "**" . wfMsg( 'payflowpro_gateway-error-msg', $msg[$key] ) . "**<br />"; |
— | — | @@ -289,9 +281,9 @@ |
290 | 282 | } |
291 | 283 | |
292 | 284 | // 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 ) ) { |
296 | 288 | $error['invalidamount'] = wfMsg( 'payflowpro_gateway-error-msg-invalid-amount' ); |
297 | 289 | $error_result = '1'; |
298 | 290 | } |
— | — | @@ -306,20 +298,20 @@ |
307 | 299 | } |
308 | 300 | |
309 | 301 | // 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'; |
318 | 310 | } 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! |
320 | 312 | //$error_result = '1'; |
321 | 313 | //$error[ 'card_num' ] = wfMsg( 'payflowpro_gateway-error-msg-card-num' ); |
322 | 314 | } |
323 | | - |
| 315 | + |
324 | 316 | return $error_result; |
325 | 317 | } |
326 | 318 | |
— | — | @@ -333,18 +325,18 @@ |
334 | 326 | */ |
335 | 327 | private function fnPayflowGetResults( $data, $result ) { |
336 | 328 | // prepare NVP response for sorting and outputting |
337 | | - $responseArray = array(); |
| 329 | + $responseArray = array( ); |
338 | 330 | |
339 | 331 | /** |
340 | 332 | * 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 |
342 | 334 | * We want to turn this into an array of key value pairs, so explode on '&' and then |
343 | 335 | * split up the resulting strings into $key => $value |
344 | 336 | */ |
345 | 337 | $result_arr = explode( "&", $result ); |
346 | 338 | foreach ( $result_arr as $result_pair ) { |
347 | 339 | list( $key, $value ) = preg_split( "/=/", $result_pair ); |
348 | | - $responseArray[ $key ] = $value; |
| 340 | + $responseArray[$key] = $value; |
349 | 341 | } |
350 | 342 | |
351 | 343 | // store the response array as an object property for easy retrival/manipulation elsewhere |
— | — | @@ -360,33 +352,34 @@ |
361 | 353 | // interpret result code, return |
362 | 354 | // approved (1), denied (2), try again (3), general error (4) |
363 | 355 | $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg ); |
364 | | - |
| 356 | + |
365 | 357 | // 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 | + |
368 | 360 | // if approved, display results and send transaction to the queue |
369 | 361 | 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 ); |
371 | 363 | $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ); |
372 | 364 | // give user a second chance to enter incorrect data |
373 | 365 | } 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 ); |
375 | 367 | // pass responseMsg as an array key as required by displayForm |
376 | 368 | $this->errors['retryMsg'] = $responseMsg; |
377 | 369 | $this->fnPayflowDisplayForm( $data, $this->errors ); |
378 | 370 | // if declined or if user has already made two attempts, decline |
379 | 371 | } 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 ); |
381 | 373 | $this->fnPayflowDisplayDeclinedResults( $responseMsg ); |
382 | 374 | } 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 ); |
384 | 376 | $this->fnPayflowDisplayOtherResults( $responseMsg ); |
385 | 377 | } 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 ); |
387 | 379 | $this->fnPayflowDisplayPending( $data, $responseArray, $responseMsg ); |
388 | 380 | } |
| 381 | + } |
389 | 382 | |
390 | | - }// end display results |
| 383 | +// end display results |
391 | 384 | |
392 | 385 | /** |
393 | 386 | * Interpret response code, return |
— | — | @@ -398,7 +391,7 @@ |
399 | 392 | function fnPayflowGetResponseMsg( $resultCode, &$responseMsg ) { |
400 | 393 | $responseMsg = wfMsg( 'globalcollect_gateway-response-default' ); |
401 | 394 | |
402 | | - switch( $resultCode ) { |
| 395 | + switch ( $resultCode ) { |
403 | 396 | case '0': |
404 | 397 | $responseMsg = wfMsg( 'globalcollect_gateway-response-0' ); |
405 | 398 | $errorCode = '1'; |
— | — | @@ -457,25 +450,25 @@ |
458 | 451 | */ |
459 | 452 | public function prepareStompTransaction( $data, $responseArray, $responseMsg ) { |
460 | 453 | $countries = $this->getCountries(); |
461 | | - |
462 | | - $transaction = array(); |
463 | 454 | |
| 455 | + $transaction = array( ); |
| 456 | + |
464 | 457 | // include response message |
465 | 458 | $transaction['response'] = $responseMsg; |
466 | | - |
| 459 | + |
467 | 460 | // include date |
468 | 461 | $transaction['date'] = time(); |
469 | | - |
| 462 | + |
470 | 463 | // put all data into one array |
471 | 464 | $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 | + |
475 | 468 | $transaction += array_merge( $data, $responseArray ); |
476 | | - |
| 469 | + |
477 | 470 | return $transaction; |
478 | 471 | } |
479 | | - |
| 472 | + |
480 | 473 | /** |
481 | 474 | * Fetch an array of country abbrevs => country names |
482 | 475 | */ |
— | — | @@ -483,7 +476,7 @@ |
484 | 477 | require_once( 'includes/countryCodes.inc' ); |
485 | 478 | return countryCodes(); |
486 | 479 | } |
487 | | - |
| 480 | + |
488 | 481 | /** |
489 | 482 | * Display response message to user with submitted user-supplied data |
490 | 483 | * |
— | — | @@ -600,7 +593,6 @@ |
601 | 594 | ); |
602 | 595 | } |
603 | 596 | |
604 | | - |
605 | 597 | /** |
606 | 598 | * Handle redirection of form content to PayPal |
607 | 599 | * |
— | — | @@ -614,42 +606,42 @@ |
615 | 607 | |
616 | 608 | // if we don't have a URL enabled throw a graceful error to the user |
617 | 609 | 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' ); |
619 | 611 | return; |
620 | 612 | } |
621 | 613 | |
622 | 614 | // 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'] ); |
624 | 616 | $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']; |
628 | 620 | /** |
629 | 621 | * update contribution tracking |
630 | 622 | */ |
631 | 623 | $this->updateContributionTracking( $data, true ); |
632 | 624 | |
633 | | - $wgPayflowProGatewayPaypalURL .= "/" . $data[ 'language' ] . "?gateway=paypal"; |
634 | | - |
| 625 | + $wgPayflowProGatewayPaypalURL .= "/" . $data['language'] . "?gateway=paypal"; |
| 626 | + |
635 | 627 | // submit the data to the paypal redirect URL |
636 | 628 | $wgOut->redirect( $wgPayflowProGatewayPaypalURL . '&' . http_build_query( $data ) ); |
637 | 629 | } |
638 | | - |
| 630 | + |
639 | 631 | public static function log( $msg, $identifier='globalcollect_gateway', $log_level=LOG_INFO ) { |
640 | 632 | global $wgGlobalCollectGatewayUseSyslog; |
641 | | - |
| 633 | + |
642 | 634 | // if we're not using the syslog facility, use wfDebugLog |
643 | 635 | if ( !$wgGlobalCollectGatewayUseSyslog ) { |
644 | 636 | wfDebugLog( $identifier, $msg ); |
645 | 637 | return; |
646 | 638 | } |
647 | | - |
| 639 | + |
648 | 640 | // otherwise, use syslogging |
649 | 641 | openlog( $identifier, LOG_ODELAY, LOG_SYSLOG ); |
650 | 642 | syslog( $log_level, $msg ); |
651 | | - closelog(); |
| 643 | + closelog(); |
652 | 644 | } |
653 | | - |
| 645 | + |
654 | 646 | /** |
655 | 647 | * Convert an amount for a particular currency to an amount in USD |
656 | 648 | * |
— | — | @@ -724,7 +716,10 @@ |
725 | 717 | $usd_amount = $amount; |
726 | 718 | break; |
727 | 719 | } |
728 | | - |
| 720 | + |
729 | 721 | return $usd_amount; |
730 | 722 | } |
731 | | -} // end class |
| 723 | + |
| 724 | +} |
| 725 | + |
| 726 | +// end class |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -1,37 +1,28 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$dir = dirname( __FILE__ ) . '/'; |
5 | | -require_once( $dir . '../gateway_common/gateway.adapter.php' ); |
6 | | - |
7 | 4 | 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'; |
12 | 9 | |
13 | 10 | /** |
14 | 11 | * stageData should alter the postdata array in all ways necessary in preparation for |
15 | 12 | * communication with the gateway. |
16 | 13 | */ |
17 | | - function stageData(){ |
| 14 | + function stageData() { |
18 | 15 | $this->postdata['amount'] = $this->postdata['amount'] * 100; |
19 | 16 | } |
20 | | - |
21 | 17 | |
22 | | - function __construct( ) { |
23 | | - $this->classlocation = __FILE__; |
24 | | - parent::__construct(); |
25 | | - } |
26 | | - |
27 | | - function defineAccountInfo(){ |
| 18 | + function defineAccountInfo() { |
28 | 19 | $this->accountInfo = array( |
29 | | - 'MERCHANTID' => self::getGlobal('MerchantID'), |
| 20 | + 'MERCHANTID' => self::getGlobal( 'MerchantID' ), |
30 | 21 | //'IPADDRESS' => '', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm. |
31 | 22 | 'VERSION' => "1.0", |
32 | 23 | ); |
33 | 24 | } |
34 | | - |
35 | | - function defineVarMap(){ |
| 25 | + |
| 26 | + function defineVarMap() { |
36 | 27 | $this->var_map = array( |
37 | 28 | 'ORDERID' => 'order_id', |
38 | 29 | 'AMOUNT' => 'amount', |
— | — | @@ -43,17 +34,17 @@ |
44 | 35 | 'IPADDRESS' => 'user_ip', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm. |
45 | 36 | ); |
46 | 37 | } |
47 | | - |
48 | | - function defineReturnValueMap(){ |
| 38 | + |
| 39 | + function defineReturnValueMap() { |
49 | 40 | $this->return_value_map = array( |
50 | 41 | 'OK' => true, |
51 | 42 | 'NOK' => false, |
52 | 43 | ); |
53 | 44 | } |
54 | | - |
55 | | - function defineTransactions(){ |
56 | | - $this->transactions = array(); |
57 | | - |
| 45 | + |
| 46 | + function defineTransactions() { |
| 47 | + $this->transactions = array( ); |
| 48 | + |
58 | 49 | $this->transactions['INSERT_ORDERWITHPAYMENT'] = array( |
59 | 50 | 'request' => array( |
60 | 51 | 'REQUEST' => array( |
— | — | @@ -90,7 +81,7 @@ |
91 | 82 | 'PAYMENTPRODUCTID' => '3', |
92 | 83 | ), |
93 | 84 | ); |
94 | | - |
| 85 | + |
95 | 86 | $this->transactions['TEST_CONNECTION'] = array( |
96 | 87 | 'request' => array( |
97 | 88 | 'REQUEST' => array( |
— | — | @@ -114,19 +105,19 @@ |
115 | 106 | * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off. |
116 | 107 | * return a string. |
117 | 108 | */ |
118 | | - function getFormattedResponse( $rawResponse ){ |
119 | | - $xmlString = $this->stripXMLResponseHeaders($rawResponse); |
| 109 | + function getFormattedResponse( $rawResponse ) { |
| 110 | + $xmlString = $this->stripXMLResponseHeaders( $rawResponse ); |
120 | 111 | $displayXML = $this->formatXmlString( $xmlString ); |
121 | 112 | $realXML = new DomDocument( '1.0' ); |
122 | 113 | self::log( "Here is the Raw XML: " . $displayXML ); //I am apparently a huge fibber. |
123 | 114 | $realXML->loadXML( trim( $xmlString ) ); |
124 | 115 | return $realXML; |
125 | 116 | } |
126 | | - |
| 117 | + |
127 | 118 | /** |
128 | 119 | * Parse the response to get the status. Not sure if this should return a bool, or something more... telling. |
129 | 120 | */ |
130 | | - function getResponseStatus( $response ){ |
| 121 | + function getResponseStatus( $response ) { |
131 | 122 | |
132 | 123 | $aok = true; |
133 | 124 | |
— | — | @@ -135,24 +126,24 @@ |
136 | 127 | $aok = false; |
137 | 128 | } |
138 | 129 | } |
139 | | - |
140 | | - return $aok; |
| 130 | + |
| 131 | + return $aok; |
141 | 132 | } |
142 | | - |
| 133 | + |
143 | 134 | /** |
144 | 135 | * Parse the response to get the errors in a format we can log and otherwise deal with. |
145 | 136 | * return a key/value array of codes (if they exist) and messages. |
146 | 137 | */ |
147 | | - function getResponseErrors( $response ){ |
148 | | - $errors = array(); |
| 138 | + function getResponseErrors( $response ) { |
| 139 | + $errors = array( ); |
149 | 140 | foreach ( $response->getElementsByTagName( 'ERROR' ) as $node ) { |
150 | 141 | $code = ''; |
151 | 142 | $message = ''; |
152 | 143 | foreach ( $node->childNodes as $childnode ) { |
153 | | - if ($childnode->nodeName === "CODE"){ |
| 144 | + if ( $childnode->nodeName === "CODE" ) { |
154 | 145 | $code = $childnode->nodeValue; |
155 | 146 | } |
156 | | - if ($childnode->nodeName === "MESSAGE"){ |
| 147 | + if ( $childnode->nodeName === "MESSAGE" ) { |
157 | 148 | $message = $childnode->nodeValue; |
158 | 149 | } |
159 | 150 | } |
— | — | @@ -160,24 +151,24 @@ |
161 | 152 | } |
162 | 153 | return $errors; |
163 | 154 | } |
164 | | - |
| 155 | + |
165 | 156 | /** |
166 | 157 | * Harvest the data we need back from the gateway. |
167 | 158 | * return a key/value array |
168 | 159 | */ |
169 | | - function getResponseData( $response ){ |
170 | | - $data = array(); |
| 160 | + function getResponseData( $response ) { |
| 161 | + $data = array( ); |
171 | 162 | foreach ( $response->getElementsByTagName( 'ROW' ) as $node ) { |
172 | 163 | foreach ( $node->childNodes as $childnode ) { |
173 | | - if (trim($childnode->nodeValue) != ''){ |
| 164 | + if ( trim( $childnode->nodeValue ) != '' ) { |
174 | 165 | $data[$childnode->nodeName] = $childnode->nodeValue; |
175 | 166 | } |
176 | 167 | } |
177 | 168 | } |
178 | | - self::log( "Returned Data: " . print_r($data, true)); |
| 169 | + self::log( "Returned Data: " . print_r( $data, true ) ); |
179 | 170 | return $data; |
180 | 171 | } |
181 | | - |
| 172 | + |
182 | 173 | function processResponse( $response ) { |
183 | 174 | //TODO: Stuff. |
184 | 175 | } |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | // Set up the new special page |
25 | 25 | $dir = dirname( __FILE__ ) . '/'; |
26 | 26 | $wgAutoloadClasses['GlobalCollectGateway'] = $dir . 'globalcollect_gateway.body.php'; |
| 27 | +$wgAutoloadClasses['GlobalCollectAdapter'] = $dir . 'globalcollect.adapter.php'; |
27 | 28 | $wgExtensionMessagesFiles['GlobalCollectGateway'] = $dir . '../payflowpro_gateway/payflowpro_gateway.i18n.php'; |
28 | 29 | $wgExtensionMessagesFiles['GlobalCollectGatewayCountries'] = $dir . '../payflowpro_gateway/payflowpro_gateway.countries.i18n.php'; |
29 | 30 | $wgExtensionMessagesFiles['GlobalCollectGatewayUSStates'] = $dir . '../payflowpro_gateway/payflowpro_gateway.us-states.i18n.php'; |
— | — | @@ -54,10 +55,6 @@ |
55 | 56 | */ |
56 | 57 | $wgGlobalCollectGatewaySalt = $wgSecretKey; |
57 | 58 | |
58 | | -$wgGlobalCollectGatewayDBserver = $wgDBserver; |
59 | | -$wgGlobalCollectGatewayDBname = $wgDBname; |
60 | | -$wgGlobalCollectGatewayDBuser = $wgDBuser; |
61 | | -$wgGlobalCollectGatewayDBpassword = $wgDBpassword; |
62 | 59 | |
63 | 60 | /** |
64 | 61 | * A string that can contain wikitext to display at the head of the credit card form |
— | — | @@ -99,7 +96,7 @@ |
100 | 97 | * Directory for HTML forms (used by RapidHtml form class) |
101 | 98 | * @var string |
102 | 99 | */ |
103 | | -$wgGlobalCollectGatewayHtmlFormDir = dirname( __FILE__ ) . "/../gateway_forms/html"; |
| 100 | +$wgGlobalCollectGatewayHtmlFormDir = dirname( __FILE__ ) . "/forms/html"; |
104 | 101 | |
105 | 102 | /** |
106 | 103 | * An array of allowed HTML forms. |
— | — | @@ -108,7 +105,7 @@ |
109 | 106 | * /never/ be loaded by the rapid html form loader! |
110 | 107 | * @var string |
111 | 108 | */ |
112 | | -$wgGlobalCollectGatewayAllowedHtmlForms = array( $wgGlobalCollectGatewayHtmlFormDir . "/demo.html" ); |
| 109 | +$wgGlobalCollectGatewayAllowedHtmlForms = $wgDonationInterfaceAllowedHtmlForms; |
113 | 110 | |
114 | 111 | /** |
115 | 112 | * Configure price cieling and floor for valid contribution amount. Values |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -9,36 +9,36 @@ |
10 | 10 | * return a string. |
11 | 11 | */ |
12 | 12 | function getFormattedResponse( $rawResponse ); |
13 | | - |
| 13 | + |
14 | 14 | /** |
15 | 15 | * Parse the response to get the status. Not sure if this should return a bool, or something more... telling. |
16 | 16 | */ |
17 | 17 | function getResponseStatus( $response ); |
18 | | - |
| 18 | + |
19 | 19 | /** |
20 | 20 | * Parse the response to get the errors in a format we can log and otherwise deal with. |
21 | 21 | * return a key/value array of codes (if they exist) and messages. |
22 | 22 | */ |
23 | 23 | function getResponseErrors( $response ); |
24 | | - |
| 24 | + |
25 | 25 | /** |
26 | 26 | * Harvest the data we need back from the gateway. |
27 | 27 | * return a key/value array |
28 | 28 | */ |
29 | 29 | function getResponseData( $response ); |
30 | | - |
| 30 | + |
31 | 31 | /** |
32 | 32 | * Actually do... stuff. Here. |
33 | 33 | * TODO: Better comment. |
34 | 34 | * Process the entire response gott'd by the last four functions. |
35 | 35 | */ |
36 | 36 | function processResponse( $response ); |
37 | | - |
| 37 | + |
38 | 38 | /** |
39 | 39 | * Anything we need to do to the data coming in, before we send it off. |
40 | 40 | */ |
41 | 41 | function stageData(); |
42 | | - |
| 42 | + |
43 | 43 | /** |
44 | 44 | * defineTransactions will define the $transactions array. |
45 | 45 | * The array will contain everything we need to know about the request structure for all the transactions we care about, |
— | — | @@ -46,25 +46,25 @@ |
47 | 47 | * 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. |
48 | 48 | * Second array key: |
49 | 49 | * '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. |
51 | 51 | * 'values' contains default values for the transaction. Things that are typically not overridden should go here. |
52 | 52 | */ |
53 | 53 | function defineTransactions(); |
54 | | - |
| 54 | + |
55 | 55 | /** |
56 | 56 | * defineVarMap needs to set up the $var_map array. |
57 | 57 | * Keys = the name (or node name) value in the gateway transaction |
58 | 58 | * Values = the mediawiki field name for the corresponding piece of data. |
59 | 59 | */ |
60 | 60 | function defineVarMap(); |
61 | | - |
| 61 | + |
62 | 62 | /** |
63 | 63 | * defineAccountInfo needs to set up the $accountInfo array. |
64 | 64 | * Keys = the name (or node name) value in the gateway transaction |
65 | 65 | * Values = The actual values for those keys. Probably have to access a global or two. (use getGlobal()!) |
66 | 66 | */ |
67 | 67 | function defineAccountInfo(); |
68 | | - |
| 68 | + |
69 | 69 | /** |
70 | 70 | * defineReturnValueMap sets up the $return_value_map array. |
71 | 71 | * Keys = The different constants that may be contained as values in the gateway's response. |
— | — | @@ -88,47 +88,45 @@ |
89 | 89 | protected $dataObj; |
90 | 90 | |
91 | 91 | //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() { |
98 | 98 | global $wgDonationInterfaceTest; //this is so the forms can see it. |
99 | 99 | //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' ); |
102 | 102 | $wgDonationInterfaceTest = false; |
103 | 103 | } else { |
104 | | - $this->url = self::getGlobal('TestingURL'); |
| 104 | + $this->url = self::getGlobal( 'TestingURL' ); |
105 | 105 | $wgDonationInterfaceTest = true; |
106 | 106 | } |
107 | 107 | |
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 | + |
112 | 110 | $this->postdata = $this->dataObj->getData(); |
113 | 111 | //TODO: Fix this a bit. |
114 | 112 | $this->posted = $this->dataObj->wasPosted(); |
115 | | - |
| 113 | + |
116 | 114 | $this->setPostDefaults(); |
117 | 115 | $this->defineTransactions(); |
118 | 116 | $this->defineVarMap(); |
119 | 117 | $this->defineAccountInfo(); |
120 | 118 | $this->defineReturnValueMap(); |
121 | | - |
| 119 | + |
122 | 120 | $this->displaydata = $this->postdata; |
123 | 121 | $this->stageData(); |
124 | 122 | } |
125 | | - |
| 123 | + |
126 | 124 | /** |
127 | 125 | * Override this in children if you want different defaults. |
128 | 126 | */ |
129 | | - function setPostDefaults(){ |
| 127 | + function setPostDefaults() { |
130 | 128 | $returnTitle = Title::newFromText( 'Donate-thanks/en' ); |
131 | 129 | $returnto = $returnTitle->getFullURL(); |
132 | | - |
| 130 | + |
133 | 131 | $this->postdatadefaults = array( |
134 | 132 | 'order_id' => '112358' . rand(), |
135 | 133 | 'amount' => '11.38', |
— | — | @@ -136,29 +134,30 @@ |
137 | 135 | 'language' => 'en', |
138 | 136 | 'country' => 'US', |
139 | 137 | '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 |
141 | 139 | ); |
142 | 140 | } |
143 | | - |
144 | | - function checkTokens(){ |
| 141 | + |
| 142 | + function checkTokens() { |
145 | 143 | return $this->dataObj->checkTokens(); |
146 | 144 | } |
147 | | - |
148 | | - function getData(){ |
| 145 | + |
| 146 | + function getData() { |
149 | 147 | return $this->postdata; |
150 | 148 | } |
151 | | - function getDisplayData(){ |
| 149 | + |
| 150 | + function getDisplayData() { |
152 | 151 | return $this->displaydata; |
153 | 152 | } |
154 | | - |
155 | | - function isCache(){ |
| 153 | + |
| 154 | + function isCache() { |
156 | 155 | return $this->dataObj->isCache(); |
157 | 156 | } |
158 | | - |
159 | | - static function getGlobal($varname){ |
160 | | - static $gotten = array(); //cache. |
| 157 | + |
| 158 | + static function getGlobal( $varname ) { |
| 159 | + static $gotten = array( ); //cache. |
161 | 160 | $globalname = self::getGlobalPrefix() . $varname; |
162 | | - if (!array_key_exists($globalname, $gotten)){ |
| 161 | + if ( !array_key_exists( $globalname, $gotten ) ) { |
163 | 162 | global $$globalname; |
164 | 163 | $gotten[$globalname] = $$globalname; |
165 | 164 | } |
— | — | @@ -174,7 +173,7 @@ |
175 | 174 | $transaction = $this->currentTransaction(); |
176 | 175 | |
177 | 176 | //If there's a hard-coded value in the transaction definition, use that. |
178 | | - if (!empty($transaction)){ |
| 177 | + if ( !empty( $transaction ) ) { |
179 | 178 | if ( array_key_exists( $transaction, $this->transactions ) && is_array( $this->transactions[$transaction] ) && |
180 | 179 | array_key_exists( 'values', $this->transactions[$transaction] ) && |
181 | 180 | array_key_exists( $gateway_field_name, $this->transactions[$transaction]['values'] ) ) { |
— | — | @@ -249,36 +248,36 @@ |
250 | 249 | function do_transaction( $transaction ) { |
251 | 250 | $this->currentTransaction( $transaction ); |
252 | 251 | //update the contribution tracking data |
253 | | - $this->dataObj->updateContributionTracking(defined( 'OWA' )); |
| 252 | + $this->dataObj->updateContributionTracking( defined( 'OWA' ) ); |
254 | 253 | if ( $this->getCommunicationType() === 'xml' ) { |
255 | 254 | $xml = $this->buildRequestXML(); |
256 | 255 | $returned = $this->curl_transaction( $xml ); |
257 | 256 | //put the response in a universal form, and return it. |
258 | 257 | } |
259 | | - |
| 258 | + |
260 | 259 | if ( $this->getCommunicationType() === 'namevalue' ) { |
261 | 260 | $namevalue = $this->postdata; |
262 | 261 | $returned = $this->curl_transaction( $namevalue ); |
263 | 262 | //put the response in a universal form, and return it. |
264 | 263 | } |
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. |
268 | 267 | return $returned; |
269 | 268 | } |
270 | | - |
| 269 | + |
271 | 270 | //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 | + |
275 | 274 | //get errors |
276 | | - $returned['errors'] = $this->getResponseErrors($formatted); |
277 | | - |
| 275 | + $returned['errors'] = $this->getResponseErrors( $formatted ); |
| 276 | + |
278 | 277 | //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 | + |
283 | 282 | //TODO: Actually pull these from somewhere legit. |
284 | 283 | if ( $returned['status'] === true ) { |
285 | 284 | $returned['message'] = "$transaction Transaction Successful!"; |
— | — | @@ -306,7 +305,7 @@ |
307 | 306 | CURLOPT_USERAGENT => Http::userAgent(), |
308 | 307 | CURLOPT_HEADER => 1, |
309 | 308 | CURLOPT_RETURNTRANSFER => 1, |
310 | | - CURLOPT_TIMEOUT => self::getGlobal('Timeout'), |
| 309 | + CURLOPT_TIMEOUT => self::getGlobal( 'Timeout' ), |
311 | 310 | CURLOPT_FOLLOWLOCATION => 0, |
312 | 311 | CURLOPT_SSL_VERIFYPEER => 0, |
313 | 312 | CURLOPT_SSL_VERIFYHOST => 2, |
— | — | @@ -315,9 +314,9 @@ |
316 | 315 | ); |
317 | 316 | |
318 | 317 | // set proxy settings if necessary |
319 | | - if ( self::getGlobal('UseHTTPProxy') ) { |
| 318 | + if ( self::getGlobal( 'UseHTTPProxy' ) ) { |
320 | 319 | $opts[CURLOPT_HTTPPROXYTUNNEL] = 1; |
321 | | - $opts[CURLOPT_PROXY] = self::getGlobal('UseHTTPProxy'); |
| 320 | + $opts[CURLOPT_PROXY] = self::getGlobal( 'UseHTTPProxy' ); |
322 | 321 | } |
323 | 322 | return $opts; |
324 | 323 | } |
— | — | @@ -372,7 +371,7 @@ |
373 | 372 | $return = array( ); |
374 | 373 | |
375 | 374 | 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() ); |
377 | 376 | $return['result'] = curl_exec( $ch ); |
378 | 377 | $return['headers'] = curl_getinfo( $ch ); |
379 | 378 | |
— | — | @@ -380,7 +379,7 @@ |
381 | 380 | self::log( $this->postdatadefaults['order_id'] . ' Failed sending transaction to ' . self::getGatewayName() . ', retrying' ); |
382 | 381 | sleep( 1 ); |
383 | 382 | } 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() ); |
385 | 384 | break; |
386 | 385 | } |
387 | 386 | } |
— | — | @@ -399,7 +398,6 @@ |
400 | 399 | curl_close( $ch ); |
401 | 400 | |
402 | 401 | return $return; |
403 | | - |
404 | 402 | } |
405 | 403 | |
406 | 404 | function stripXMLResponseHeaders( $rawResponse ) { |
— | — | @@ -467,25 +465,25 @@ |
468 | 466 | |
469 | 467 | return $result; |
470 | 468 | } |
471 | | - |
| 469 | + |
472 | 470 | static function getCommunicationType() { |
473 | 471 | $c = get_called_class(); |
474 | | - return $c::communicationtype; |
| 472 | + return $c::COMMUNICATION_TYPE; |
475 | 473 | } |
476 | | - |
| 474 | + |
477 | 475 | static function getGatewayName() { |
478 | 476 | $c = get_called_class(); |
479 | | - return $c::gatewayname; |
| 477 | + return $c::GATEWAY_NAME; |
480 | 478 | } |
481 | | - |
| 479 | + |
482 | 480 | static function getGlobalPrefix() { |
483 | 481 | $c = get_called_class(); |
484 | | - return $c::globalprefix; |
| 482 | + return $c::GLOBAL_PREFIX; |
485 | 483 | } |
486 | | - |
| 484 | + |
487 | 485 | static function getIdentifier() { |
488 | 486 | $c = get_called_class(); |
489 | | - return $c::identifier; |
| 487 | + return $c::IDENTIFIER; |
490 | 488 | } |
491 | 489 | |
492 | 490 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -6,54 +6,52 @@ |
7 | 7 | * @author khorn |
8 | 8 | */ |
9 | 9 | class DonationData { |
10 | | - |
11 | | - protected $normalized = array(); |
12 | | - |
| 10 | + |
| 11 | + protected $normalized = array( ); |
13 | 12 | public $boss; |
14 | | - |
15 | | - function __construct($owning_class, $test = false, $testdata = false){ |
| 13 | + |
| 14 | + function __construct( $owning_class, $test = false, $testdata = false ) { |
16 | 15 | //TODO: Actually think about this bit. |
17 | 16 | // ...and keep in mind we can re-populate if it's a test or whatever. (But that may not be a good idea either) |
18 | 17 | //maybe we should just explicitly pass in where we get the data from. (Test, post, API...) |
19 | 18 | $this->boss = $owning_class; |
20 | | - $this->populateData($test, $testdata); |
| 19 | + $this->populateData( $test, $testdata ); |
21 | 20 | } |
22 | | - |
23 | | - function populateData($test = false, $testdata = false){ |
24 | | - $this->normalized = array(); |
| 21 | + |
| 22 | + function populateData( $test = false, $testdata = false ) { |
| 23 | + $this->normalized = array( ); |
25 | 24 | //TODO: Uh, the API should probably be able to get in this far, too... and have its own populate function. |
26 | 25 | //Maybe check for the boss class... |
27 | | - if ($test){ |
28 | | - $this->populateData_Test($testdata); |
| 26 | + if ( $test ) { |
| 27 | + $this->populateData_Test( $testdata ); |
29 | 28 | } else { |
30 | 29 | $this->populateData_Form(); |
31 | 30 | } |
32 | 31 | $this->doCacheStuff(); |
33 | | - |
34 | | - |
35 | | - if (!empty($this->normalized)){ |
| 32 | + |
| 33 | + |
| 34 | + if ( !empty( $this->normalized ) ) { |
36 | 35 | $this->setNormalizedAmount(); |
37 | 36 | $this->setNormalizedOrderIDs(); |
38 | 37 | $this->setGateway(); |
39 | 38 | array_walk( $this->normalized, array( $this, 'sanitizeInput' ) ); |
40 | 39 | } |
41 | 40 | //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' ) ) ) { |
43 | 42 | $this->saveContributionTracking(); |
44 | 43 | } |
45 | | - |
46 | 44 | } |
47 | | - |
48 | | - function getData(){ |
| 45 | + |
| 46 | + function getData() { |
49 | 47 | return $this->normalized; |
50 | 48 | } |
51 | | - |
52 | | - function isCache(){ |
| 49 | + |
| 50 | + function isCache() { |
53 | 51 | return $this->cache; |
54 | 52 | } |
55 | | - |
56 | | - function populateData_Test($testdata = false){ |
57 | | - if (is_array($testdata)){ |
| 53 | + |
| 54 | + function populateData_Test( $testdata = false ) { |
| 55 | + if ( is_array( $testdata ) ) { |
58 | 56 | $this->normalized = $testdata; |
59 | 57 | } else { |
60 | 58 | // define arrays of cc's and cc #s for random selection |
— | — | @@ -68,8 +66,8 @@ |
69 | 67 | $card_index = array_rand( $cards ); |
70 | 68 | |
71 | 69 | // 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 | + |
74 | 72 | global $wgRequest; //TODO: ARRRGHARGHARGH. That is all. |
75 | 73 | |
76 | 74 | $this->normalized = array( |
— | — | @@ -93,8 +91,8 @@ |
94 | 92 | 'country2' => 'US', |
95 | 93 | 'size' => 'small', |
96 | 94 | '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], |
99 | 97 | 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
100 | 98 | 'cvv' => '001', |
101 | 99 | 'currency' => 'USD', |
— | — | @@ -121,8 +119,8 @@ |
122 | 120 | ); |
123 | 121 | } |
124 | 122 | } |
125 | | - |
126 | | - function populateData_Form(){ |
| 123 | + |
| 124 | + function populateData_Form() { |
127 | 125 | global $wgRequest; //I'll let you have this one, because it makes sense. |
128 | 126 | $this->normalized = array( |
129 | 127 | 'posted' => 'true', //moderately sneaky. |
— | — | @@ -149,11 +147,11 @@ |
150 | 148 | * to be 'country' for downstream processing (until we fully support passing in two separate addresses). I thought about completely |
151 | 149 | * disabling country2 support in the forms, etc but realized there's a chance it'll be resurrected shortly. Hence this silly hack. |
152 | 150 | */ |
153 | | - 'country2' => ( strlen( $wgRequest->getText( 'country2' ))) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ), |
| 151 | + 'country2' => ( strlen( $wgRequest->getText( 'country2' ) )) ? $wgRequest->getText( 'country2' ) : $wgRequest->getText( 'country' ), |
154 | 152 | 'size' => $wgRequest->getText( 'size' ), |
155 | 153 | 'premium_language' => $wgRequest->getText( 'premium_language', "en" ), |
156 | 154 | 'card_num' => str_replace( ' ', '', $wgRequest->getText( 'card_num' ) ), |
157 | | - 'card' => $wgRequest->getText( 'card' ), |
| 155 | + 'card_type' => $wgRequest->getText( 'card' ), |
158 | 156 | 'expiration' => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ), |
159 | 157 | 'cvv' => $wgRequest->getText( 'cvv' ), |
160 | 158 | 'currency' => $wgRequest->getText( 'currency_code' ), |
— | — | @@ -180,82 +178,81 @@ |
181 | 179 | 'owa_session' => $wgRequest->getText( 'owa_session', null ), |
182 | 180 | 'owa_ref' => $wgRequest->getText( 'owa_ref', null ), |
183 | 181 | ); |
184 | | - if (!$wgRequest->wasPosted()){ |
185 | | - $this->setVal('posted', false); |
186 | | - } |
| 182 | + if ( !$wgRequest->wasPosted() ) { |
| 183 | + $this->setVal( 'posted', false ); |
| 184 | + } |
187 | 185 | } |
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] ) ) { |
191 | 189 | return true; |
192 | 190 | } else { |
193 | 191 | return false; |
194 | 192 | } |
195 | 193 | } |
196 | | - |
197 | | - function getVal($key){ |
198 | | - if ($this->isSomething($key)){ |
| 194 | + |
| 195 | + function getVal( $key ) { |
| 196 | + if ( $this->isSomething( $key ) ) { |
199 | 197 | return $this->normalized[$key]; |
200 | 198 | } else { |
201 | 199 | return null; |
202 | 200 | } |
203 | 201 | } |
204 | | - |
205 | | - function setVal($key, $val){ |
| 202 | + |
| 203 | + function setVal( $key, $val ) { |
206 | 204 | $this->normalized[$key] = $val; |
207 | 205 | } |
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] ); |
212 | 210 | } |
213 | 211 | } |
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' ) ); |
222 | 220 | } else { |
223 | | - $this->setVal('amount', '0.00'); |
| 221 | + $this->setVal( 'amount', '0.00' ); |
224 | 222 | } |
225 | 223 | } |
226 | | - |
227 | | - $this->expunge('amountGiven'); |
228 | | - $this->expunge('amountOther'); |
| 224 | + |
| 225 | + $this->expunge( 'amountGiven' ); |
| 226 | + $this->expunge( 'amountOther' ); |
229 | 227 | } |
230 | | - |
231 | | - function setOwaRefId(){ |
| 228 | + |
| 229 | + function setOwaRefId() { |
232 | 230 | //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'] ) ) { |
234 | 232 | $owa_ref = $this->get_owa_ref_id( $owa_ref ); |
235 | 233 | } |
236 | 234 | } |
237 | | - |
238 | | - function setNormalizedOrderIDs(){ |
| 235 | + |
| 236 | + function setNormalizedOrderIDs() { |
239 | 237 | //basically, we need a new order_id every time we come through here, but if there's an internal already there, |
240 | 238 | //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 | + } |
246 | 244 | } |
247 | | - |
| 245 | + |
248 | 246 | /** |
249 | 247 | * Generate an order id exactly once for this go-round. |
250 | 248 | */ |
251 | 249 | function generateOrderId() { |
252 | 250 | static $order_id = null; |
253 | | - if ($order_id === null){ |
| 251 | + if ( $order_id === null ) { |
254 | 252 | $order_id = ( double ) microtime() * 1000000 . mt_rand( 1000, 9999 ); |
255 | 253 | } |
256 | 254 | return $order_id; |
257 | 255 | } |
258 | | - |
259 | | - |
| 256 | + |
260 | 257 | /** |
261 | 258 | * Sanitize user input |
262 | 259 | * |
— | — | @@ -269,27 +266,27 @@ |
270 | 267 | public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) { |
271 | 268 | $value = htmlspecialchars( $value, $flags, 'UTF-8', $double_encode ); |
272 | 269 | } |
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 ) ) { |
276 | 273 | $c = $this->boss; |
277 | | - $c::log($message, $log_level); |
| 274 | + $c::log( $message, $log_level ); |
278 | 275 | } |
279 | 276 | } |
280 | | - |
281 | | - function setGateway(){ |
| 277 | + |
| 278 | + function setGateway() { |
282 | 279 | //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 ) ) { |
284 | 281 | $c = $this->boss; |
285 | 282 | $gateway = $c::getIdentifier(); |
286 | | - $this->setVal('gateway', $gateway); |
287 | | - } |
| 283 | + $this->setVal( 'gateway', $gateway ); |
| 284 | + } |
288 | 285 | } |
289 | | - |
290 | | - function doCacheStuff(){ |
| 286 | + |
| 287 | + function doCacheStuff() { |
291 | 288 | //TODO: Wow, name. |
292 | 289 | global $wgRequest; |
293 | | - |
| 290 | + |
294 | 291 | // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax |
295 | 292 | if ( $this->isSomething( '_cache_' ) ) { |
296 | 293 | self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Cache requested', LOG_DEBUG ); |
— | — | @@ -298,26 +295,25 @@ |
299 | 296 | |
300 | 297 | // if we have squid caching enabled, set the maxage |
301 | 298 | global $wgUseSquid, $wgOut; |
302 | | - if (class_exists($this->boss)){ |
| 299 | + if ( class_exists( $this->boss ) ) { |
303 | 300 | $g = $this->boss; //the 'g' is for "Gateway"! |
304 | | - $maxAge = $g::getGlobal('SMaxAge'); |
| 301 | + $maxAge = $g::getGlobal( 'SMaxAge' ); |
305 | 302 | |
306 | 303 | if ( $wgUseSquid ) { |
307 | 304 | self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG ); |
308 | | - $wgOut->setSquidMaxage( $maxAge ); |
| 305 | + $wgOut->setSquidMaxage( $maxAge ); |
309 | 306 | } |
310 | 307 | } |
311 | 308 | } else { |
312 | 309 | $this->cache = false; //TODO: Kill this one in the face, too. (see above) |
313 | 310 | } |
314 | 311 | } |
315 | | - |
316 | | - function getAnnoyingOrderIDLogLinePrefix(){ |
| 312 | + |
| 313 | + function getAnnoyingOrderIDLogLinePrefix() { |
317 | 314 | //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' ) . ': '; |
319 | 316 | } |
320 | | - |
321 | | - |
| 317 | + |
322 | 318 | /** |
323 | 319 | * Establish an 'edit' token to help prevent CSRF, etc |
324 | 320 | * |
— | — | @@ -335,20 +331,20 @@ |
336 | 332 | |
337 | 333 | // make sure we have a session open for tracking a CSRF-prevention token |
338 | 334 | self::ensureSession(); |
339 | | - |
340 | | - if (class_exists($this->boss)){ |
| 335 | + |
| 336 | + if ( class_exists( $this->boss ) ) { |
341 | 337 | $g = $this->boss; |
342 | 338 | $gateway_ident = $g::getIdentifier(); |
343 | 339 | } else { |
344 | 340 | $gateway_ident = 'DonationData'; |
345 | 341 | } |
346 | 342 | |
347 | | - if ( !isset( $_SESSION[ $gateway_ident . 'EditToken' ] ) ) { |
| 343 | + if ( !isset( $_SESSION[$gateway_ident . 'EditToken'] ) ) { |
348 | 344 | // generate unsalted token to place in the session |
349 | 345 | $token = self::generateToken(); |
350 | | - $_SESSION[ $gateway_ident . 'EditToken' ] = $token; |
| 346 | + $_SESSION[$gateway_ident . 'EditToken'] = $token; |
351 | 347 | } else { |
352 | | - $token = $_SESSION[ $gateway_ident . 'EditToken' ]; |
| 348 | + $token = $_SESSION[$gateway_ident . 'EditToken']; |
353 | 349 | } |
354 | 350 | |
355 | 351 | if ( is_array( $salt ) ) { |
— | — | @@ -381,8 +377,8 @@ |
382 | 378 | if ( $val != $sessionToken ) { |
383 | 379 | wfDebug( "DonationData::matchEditToken: broken session data\n" ); |
384 | 380 | } |
385 | | - $this->log("Val = $val"); |
386 | | - $this->log("Session Token = $sessionToken"); |
| 381 | + $this->log( "Val = $val" ); |
| 382 | + $this->log( "Session Token = $sessionToken" ); |
387 | 383 | return $val == $sessionToken; |
388 | 384 | } |
389 | 385 | |
— | — | @@ -390,13 +386,13 @@ |
391 | 387 | * Unset the payflow edit token from a user's session |
392 | 388 | */ |
393 | 389 | function unsetEditToken() { |
394 | | - if (class_exists($this->boss)){ |
| 390 | + if ( class_exists( $this->boss ) ) { |
395 | 391 | $g = $this->boss; |
396 | 392 | $gateway_ident = $g::getIdentifier(); |
397 | 393 | } else { |
398 | 394 | $gateway_ident = "DonationData"; |
399 | 395 | } |
400 | | - unset( $_SESSION[ $gateway_ident . 'EditToken' ] ); |
| 396 | + unset( $_SESSION[$gateway_ident . 'EditToken'] ); |
401 | 397 | } |
402 | 398 | |
403 | 399 | /** |
— | — | @@ -407,52 +403,49 @@ |
408 | 404 | */ |
409 | 405 | public static function ensureSession() { |
410 | 406 | // if the session is already started, do nothing |
411 | | - if ( session_id() ) return; |
| 407 | + if ( session_id() ) |
| 408 | + return; |
412 | 409 | |
413 | 410 | // otherwise, fire it up using global mw function wfSetupSession |
414 | 411 | wfSetupSession(); |
415 | 412 | } |
416 | | - |
| 413 | + |
417 | 414 | public function checkTokens() { |
418 | 415 | 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 ) ) { |
422 | 419 | $g = $this->boss; |
423 | | - $salt = $g::getGlobal('Salt'); |
| 420 | + $salt = $g::getGlobal( 'Salt' ); |
424 | 421 | } else { |
425 | 422 | $salt = 'gotToBeInAUnitTest'; |
426 | 423 | } |
427 | | - |
| 424 | + |
428 | 425 | // establish the edit token to prevent csrf |
429 | 426 | $token = $this->getEditToken( $salt ); |
430 | | - |
| 427 | + |
431 | 428 | $this->log( $this->getAnnoyingOrderIDLogLinePrefix() . ' editToken: ' . $token, LOG_DEBUG ); |
432 | | - |
| 429 | + |
433 | 430 | // match token |
434 | 431 | $token_check = ( $this->isSomething( 'token' ) ) ? $this->getVal( 'token' ) : $token; //TODO: does this suck as much as it looks like it does? |
435 | 432 | $match = $this->matchEditToken( $token_check, $salt ); |
436 | 433 | 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 ); |
438 | 435 | $this->log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Token match: ' . ($match ? 'true' : 'false' ), LOG_DEBUG ); |
439 | 436 | } |
440 | | - |
441 | 437 | } |
442 | | - |
| 438 | + |
443 | 439 | return $match; |
444 | 440 | } |
445 | | - |
446 | | - function wasPosted(){ |
| 441 | + |
| 442 | + function wasPosted() { |
447 | 443 | //TODO: Get rid of these log statements. |
448 | | - if ( $this->isSomething('posted') ){ |
| 444 | + if ( $this->isSomething( 'posted' ) ) { |
449 | 445 | return true; |
450 | 446 | } |
451 | 447 | return false; |
452 | 448 | } |
453 | 449 | |
454 | | - |
455 | | - |
456 | | - |
457 | 450 | /** |
458 | 451 | * Get the utm_source string |
459 | 452 | * |
— | — | @@ -505,7 +498,8 @@ |
506 | 499 | |
507 | 500 | // if there are no sourceparts element, then the banner portion of the string needs to be set. |
508 | 501 | // 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] = ''; |
510 | 504 | |
511 | 505 | // if the utm_source_id is set, set the landing page portion of the string to cc# |
512 | 506 | $source_parts[1] = ( $utm_source_id ) ? 'cc' . $utm_source_id : ( isset( $source_parts[1] ) ? $source_parts[1] : '' ); |
— | — | @@ -516,8 +510,7 @@ |
517 | 511 | // return a reconstructed string |
518 | 512 | return implode( ".", $source_parts ); |
519 | 513 | } |
520 | | - |
521 | | - |
| 514 | + |
522 | 515 | /** |
523 | 516 | * Determine proper opt-out settings for contribution tracking |
524 | 517 | * |
— | — | @@ -526,11 +519,10 @@ |
527 | 520 | * (which is opt-out), we need to reverse the values |
528 | 521 | */ |
529 | 522 | 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'; |
532 | 525 | return $optout; |
533 | 526 | } |
534 | | - |
535 | 527 | |
536 | 528 | /** |
537 | 529 | * Clean array of tracking data to contain valid fields |
— | — | @@ -555,35 +547,35 @@ |
556 | 548 | 'ts' |
557 | 549 | ); |
558 | 550 | |
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 ); |
562 | 554 | } else { |
563 | 555 | $tracking_data[$value] = null; |
564 | 556 | } |
565 | 557 | } |
566 | | - |
| 558 | + |
567 | 559 | // clean up the optout values if necessary |
568 | 560 | if ( $clean_optouts ) { |
569 | 561 | $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']; |
572 | 564 | } |
573 | 565 | |
574 | 566 | return $tracking_data; |
575 | 567 | } |
576 | | - |
| 568 | + |
577 | 569 | //if ( !empty($data) && ( $data[ 'numAttempt' ] == '0' && ( !$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) ) { |
578 | 570 | //so, basically, if this is the first attempt. This seems to get called nowhere else. |
579 | 571 | function saveContributionTracking() { |
580 | 572 | |
581 | | - $tracked_contribution = $this->getCleanTrackingData(true); |
| 573 | + $tracked_contribution = $this->getCleanTrackingData( true ); |
582 | 574 | |
583 | 575 | // insert tracking data and get the tracking id |
584 | 576 | $result = self::insertContributionTracking( $tracked_contribution ); |
585 | | - |
586 | | - $this->setVal('contribution_tracking_id', $result); |
587 | 577 | |
| 578 | + $this->setVal( 'contribution_tracking_id', $result ); |
| 579 | + |
588 | 580 | if ( !$result ) { |
589 | 581 | return false; |
590 | 582 | } |
— | — | @@ -599,22 +591,23 @@ |
600 | 592 | public static function insertContributionTracking( $tracking_data ) { |
601 | 593 | $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
602 | 594 | |
603 | | - if ( !$db ) { return false; } |
| 595 | + if ( !$db ) { |
| 596 | + return false; |
| 597 | + } |
604 | 598 | |
605 | 599 | // 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(); |
608 | 602 | } |
609 | 603 | |
610 | 604 | // Store the contribution data |
611 | 605 | if ( $db->insert( 'contribution_tracking', $tracking_data ) ) { |
612 | | - return $db->insertId(); |
| 606 | + return $db->insertId(); |
613 | 607 | } else { |
614 | 608 | return false; |
615 | 609 | } |
616 | 610 | } |
617 | | - |
618 | | - |
| 611 | + |
619 | 612 | /** |
620 | 613 | * Update contribution_tracking table |
621 | 614 | * |
— | — | @@ -629,25 +622,27 @@ |
630 | 623 | // ony update contrib tracking if we're coming from a single-step landing page |
631 | 624 | // which we know with cc# in utm_source or if force=true or if contribution_tracking_id is not set |
632 | 625 | 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' ) ) ) { |
635 | 628 | return; |
636 | 629 | } |
637 | 630 | |
638 | 631 | $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
639 | 632 | |
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. |
641 | 636 | |
642 | | - $tracked_contribution = $this->getCleanTrackingData(true); |
| 637 | + $tracked_contribution = $this->getCleanTrackingData( true ); |
643 | 638 | |
644 | 639 | // 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 ) ); |
647 | 642 | } 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' ) ) ); |
649 | 644 | } |
650 | 645 | } |
651 | | - |
| 646 | + |
652 | 647 | } |
653 | 648 | |
654 | 649 | ?> |