r102318 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102317‎ | r102318 | r102319 >
Date:20:06, 7 November 2011
Author:khorn
Status:ok
Tags:fundraising 
Comment:
Removes all unnecessary references to 'currency', in favor of referencing 'currency_code'.
Please note: A couple references to 'currency' do still exist. For instance: In DonationData, if some external bit of code is still passing 'currency' in the querystring, we'll pull that in and rename it appropriately, and 'currency' is still the expected outgoing key in stomp messages.
related to r102309
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/minfraud/minfraud.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/GatewayForm.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/rapidhtml/js/lightbox1.js (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/GlobalCollectTestCase.php (modified) (history)
  • /trunk/extensions/DonationInterface/tests/DonationDataTestCase.php (modified) (history)
  • /trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/GlobalCollectTestCase.php
@@ -54,7 +54,7 @@
5555 $var_map = array(
5656 'ORDERID' => 'order_id',
5757 'AMOUNT' => 'amount',
58 - 'CURRENCYCODE' => 'currency',
 58+ 'CURRENCYCODE' => 'currency_code',
5959 'LANGUAGECODE' => 'language',
6060 'COUNTRYCODE' => 'country',
6161 'MERCHANTREFERENCE' => 'order_id',
Index: trunk/extensions/DonationInterface/tests/DonationDataTestCase.php
@@ -60,7 +60,7 @@
6161 'card_type' => 'visa',
6262 'expiration' => '1138',
6363 'cvv' => '665',
64 - 'currency' => 'USD',
 64+ 'currency_code' => 'USD',
6565 'payment_method' => '',
6666 'i_order_id' => '1234567890',
6767 'numAttempt' => '5',
@@ -119,7 +119,7 @@
120120 'card_type' => '',
121121 'expiration' => '',
122122 'cvv' => '',
123 - 'currency' => '',
 123+ 'currency_code' => '',
124124 'payment_method' => '',
125125 'numAttempt' => '0',
126126 'referrer' => '',
@@ -175,7 +175,7 @@
176176 'card_type' => 'american',
177177 'expiration' => '1012',
178178 'cvv' => '001',
179 - 'currency' => 'USD',
 179+ 'currency_code' => 'USD',
180180 'payment_method' => '',
181181 'i_order_id' => '1234567890',
182182 'numAttempt' => '0',
Index: trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php
@@ -193,7 +193,7 @@
194194 'zip' => $zip,
195195 'country' => $country,
196196 //'size' => 'small',
197 - 'currency' => $currency,
 197+ 'currency_code' => $currency,
198198 //'order_id' => '5038287830',
199199 //'i_order_id' => '1234567890',
200200 'numAttempt' => 0,
@@ -262,7 +262,7 @@
263263 $options['state'] = 'XX';
264264 $options['zip'] = '';
265265 $options['country'] = 'ES';
266 - $options['currency'] = 'EUR';
 266+ $options['currency_code'] = 'EUR';
267267
268268 return $this->getGatewayAdapterTestData( $options );
269269 }
@@ -285,7 +285,7 @@
286286 $expected .= '<ORDER>';
287287 $expected .= '<ORDERID>' . $orderId . '</ORDERID>';
288288 $expected .= '<AMOUNT>' . $options['testData']['amount'] * 100 . '</AMOUNT>';
289 - $expected .= '<CURRENCYCODE>' . $options['testData']['currency'] . '</CURRENCYCODE>';
 289+ $expected .= '<CURRENCYCODE>' . $options['testData']['currency_code'] . '</CURRENCYCODE>';
290290 $expected .= '<LANGUAGECODE>' . $options['testData']['language'] . '</LANGUAGECODE>';
291291 $expected .= '<COUNTRYCODE>' . $options['testData']['country'] . '</COUNTRYCODE>';
292292 $expected .= '<MERCHANTREFERENCE>' . $orderId . '</MERCHANTREFERENCE>';
@@ -293,7 +293,7 @@
294294 $expected .= '<PAYMENT>';
295295 $expected .= '<PAYMENTPRODUCTID>' . $optionsForTestData['payment_product_id'] . '</PAYMENTPRODUCTID>';
296296 $expected .= '<AMOUNT>' . $options['testData']['amount'] * 100 . '</AMOUNT>';
297 - $expected .= '<CURRENCYCODE>' . $options['testData']['currency'] . '</CURRENCYCODE>';
 297+ $expected .= '<CURRENCYCODE>' . $options['testData']['currency_code'] . '</CURRENCYCODE>';
298298 $expected .= '<LANGUAGECODE>' . $options['testData']['language'] . '</LANGUAGECODE>';
299299 $expected .= '<COUNTRYCODE>' . $options['testData']['country'] . '</COUNTRYCODE>';
300300 $expected .= '<HOSTEDINDICATOR>1</HOSTEDINDICATOR>';
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php
@@ -43,11 +43,11 @@
4444 'ZIP' => 'zip',
4545 'INVNUM' => 'order_id',
4646 'CVV2' => 'cvv',
47 - 'CURRENCY' => 'currency',
 47+ 'CURRENCY' => 'currency_code',
4848 'CUSTIP' => 'user_ip',
4949 // 'ORDERID' => 'order_id',
5050 // 'AMOUNT' => 'amount',
51 -// 'CURRENCYCODE' => 'currency',
 51+// 'CURRENCYCODE' => 'currency_code',
5252 // 'LANGUAGECODE' => 'language',
5353 // 'COUNTRYCODE' => 'country',
5454 // 'MERCHANTREFERENCE' => 'order_id',
Index: trunk/extensions/DonationInterface/extras/minfraud/minfraud.body.php
@@ -89,7 +89,7 @@
9090 public function log_query( $minfraud_query, $action ) {
9191 if ( $this->log_fh ) {
9292 $log_message = '"' . addslashes( $this->gateway_adapter->getData_Raw( 'comment' ) ) . '"';
93 - $log_message .= "\t" . '"' . addslashes( $this->gateway_adapter->getData_Raw( 'amount' ) . ' ' . $this->gateway_adapter->getData_Raw( 'currency' ) ) . '"';
 93+ $log_message .= "\t" . '"' . addslashes( $this->gateway_adapter->getData_Raw( 'amount' ) . ' ' . $this->gateway_adapter->getData_Raw( 'currency_code' ) ) . '"';
9494 $log_message .= "\t" . '"' . addslashes( json_encode( $minfraud_query ) ) . '"';
9595 $log_message .= "\t" . '"' . addslashes( json_encode( $this->minfraud_response ) ) . '"';
9696 $log_message .= "\t" . '"' . addslashes( $action ) . '"';
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter.php
@@ -99,7 +99,7 @@
100100 $form .= '</tr>';
101101
102102 // card logos
103 - if ( $this->form_data[ 'currency' ] == 'USD' ) {
 103+ if ( $this->form_data[ 'currency_code' ] == 'USD' ) {
104104 $form .= '<tr id="four_cards" style="display:table-row;">';
105105 $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos.gif" ) ) . '</td>';
106106 $form .= '</tr>';
Index: trunk/extensions/DonationInterface/gateway_forms/rapidhtml/js/lightbox1.js
@@ -187,7 +187,7 @@
188188 error = ( amount == null || isNaN( amount ) || amount.value <= 0 );
189189 // Check amount is at least the minimum
190190 var currency = 'USD'; // hard-coded for these forms and tests
191 - $( "input[name='currency']" ).val( currency );
 191+ $( "input[name='currency_code']" ).val( currency );
192192 if ( typeof( wgCurrencyMinimums[currency] ) == 'undefined' ) {
193193 wgCurrencyMinimums[currency] = 1;
194194 }
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetterCA.php
@@ -99,7 +99,7 @@
100100 $form .= '</tr>';
101101
102102 // card logos
103 - if ( $this->form_data[ 'currency' ] == 'USD' ) {
 103+ if ( $this->form_data[ 'currency_code' ] == 'USD' ) {
104104 $form .= '<tr id="four_cards" style="display:table-row;">';
105105 $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos.gif" ) ) . '</td>';
106106 $form .= '</tr>';
Index: trunk/extensions/DonationInterface/gateway_forms/Form.php
@@ -366,8 +366,8 @@
367367 $availableCurrencies = $this->gateway->getCurrencies();
368368
369369 // If a currency has already been posted, use that, otherwise use the default.
370 - if ( $this->form_data['currency'] ) {
371 - $selectedCurrency = $this->form_data['currency'];
 370+ if ( $this->form_data['currency_code'] ) {
 371+ $selectedCurrency = $this->form_data['currency_code'];
372372 } else {
373373 $selectedCurrency = $defaultCurrencyCode;
374374 }
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremium.php
@@ -105,7 +105,7 @@
106106 $form .= '</tr>';
107107
108108 // card logos
109 - if ( $this->form_data[ 'currency' ] == 'USD' ) {
 109+ if ( $this->form_data[ 'currency_code' ] == 'USD' ) {
110110 $form .= '<tr id="four_cards" style="display:table-row;">';
111111 $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos.gif" ) ) . '</td>';
112112 $form .= '</tr>';
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php
@@ -208,8 +208,8 @@
209209 $form .= '<td class="amount_data" style="text-align:right;width:75px;">'.$this->form_data['amount'] .
210210 Html::hidden( 'amount', $this->form_data['amount'] ) .
211211 '</td>';
212 - $form .= '<td class="amount_data" style="text-align:right;width:75px;">'.$this->form_data[ 'currency' ] .
213 - Html::hidden( 'currency_code', $this->form_data['currency'] ) .
 212+ $form .= '<td class="amount_data" style="text-align:right;width:75px;">'.$this->form_data[ 'currency_code' ] .
 213+ Html::hidden( 'currency_code', $this->form_data['currency_code'] ) .
214214 '</td>';
215215 $form .= '</tr>';
216216 $form .= '</table>';
@@ -224,7 +224,7 @@
225225 // card logos
226226 $form .= '<tr>';
227227 $form .= '<td class="label"> </td>';
228 - if ( $this->form_data[ 'currency' ] == 'USD' ) {
 228+ if ( $this->form_data[ 'currency_code' ] == 'USD' ) {
229229 $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos.gif" ) ) . '</td>';
230230 } else {
231231 $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos3.gif" ) ) . '</td>';
Index: trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php
@@ -31,7 +31,7 @@
3232 '@card_type', // => $wgRequest->getText( 'card_type' ),
3333 '@expiration', // => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ),
3434 '@cvv', // => $wgRequest->getText( 'cvv' ),
35 - '@currency_code', //'currency' => $wgRequest->getText( 'currency_code' ),
 35+ '@currency_code', //'currency_code' => $wgRequest->getText( 'currency_code' ),
3636 '@payment_method', // => $wgRequest->getText( 'payment_method' ),
3737 '@order_id', // => $order_id,
3838 '@numAttempt', // => $numAttempt,
@@ -169,7 +169,6 @@
170170 foreach ( $this->data_tokens as $token ) {
171171 $key = substr( $token, 1, strlen( $token )); //get the token string w/o the '@'
172172 if ( $key == 'emailAdd' ) $key = 'email';
173 - if ( $key == 'currency_code' ) $key = 'currency';
174173 if ( array_key_exists( $key, $this->form_data )) {
175174 $replace = $this->form_data[ $key ];
176175 } else {
@@ -270,7 +269,7 @@
271270 // currency code
272271 $start = strpos( $html, 'name="currency_code"' );
273272 if ( $start ) {
274 - $currency_code = $this->form_data['currency'];
 273+ $currency_code = $this->form_data['currency_code'];
275274 $end = strpos( $html, '</select>', $start );
276275 $str = substr( $html, $start, ( $end - $start ) );
277276 $str = str_replace( 'value="' . $currency_code . '"', 'value="' . $currency_code . '" selected="selected"', $str );
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnPremiumUS.php
@@ -192,8 +192,8 @@
193193 $form .= '<td class="amount_data" style="text-align:right;width:75px;">'.$this->form_data['amount'] .
194194 Html::hidden( 'amount', $this->form_data['amount'] ) .
195195 '</td>';
196 - $form .= '<td class="amount_data" style="text-align:right;width:75px;">'.$this->form_data[ 'currency' ] .
197 - Html::hidden( 'currency_code', $this->form_data['currency'] ) .
 196+ $form .= '<td class="amount_data" style="text-align:right;width:75px;">'.$this->form_data[ 'currency_code' ] .
 197+ Html::hidden( 'currency_code', $this->form_data['currency_code'] ) .
198198 '</td>';
199199 $form .= '</tr>';
200200 $form .= '</table>';
@@ -208,7 +208,7 @@
209209 // card logos
210210 $form .= '<tr>';
211211 $form .= '<td class="label"> </td>';
212 - if ( $this->form_data[ 'currency' ] == 'USD' ) {
 212+ if ( $this->form_data[ 'currency_code' ] == 'USD' ) {
213213 $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos.gif" ) ) . '</td>';
214214 } else {
215215 $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/gateway_forms/includes/credit_card_logos3.gif" ) ) . '</td>';
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js
@@ -144,7 +144,7 @@
145145 var sendData = {
146146 'action': 'donate',
147147 'gateway': 'globalcollect',
148 - 'currency': 'USD',
 148+ 'currency_code': 'USD',
149149 'amount': $( "input[name='amount']" ).val(),
150150 'fname': $( "input[name='fname']" ).val(),
151151 'lname': $( "input[name='lname']" ).val(),
@@ -221,7 +221,7 @@
222222 error = ( amount == null || isNaN( amount ) || amount.value <= 0 );
223223 // Check amount is at least the minimum
224224 var currency = 'USD'; // hard-coded for these forms and tests
225 - $( "input[name='currency']" ).val( currency );
 225+ $( "input[name='currency_code']" ).val( currency );
226226 if ( typeof( wgCurrencyMinimums[currency] ) == 'undefined' ) {
227227 wgCurrencyMinimums[currency] = 1;
228228 }
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -79,7 +79,7 @@
8080 'CUSTOMERBANKNUMBER'=> 'customer_bank_number', // dd
8181 'CUSTOMERBANKZIP' => 'customer_bank_zip', // dd
8282 'CREDITCARDNUMBER' => 'card_num',
83 - 'CURRENCYCODE' => 'currency',
 83+ 'CURRENCYCODE' => 'currency_code',
8484 'CVV' => 'cvv',
8585 'DATECOLLECT' => 'date_collect',
8686 'DIRECTDEBITTEXT' => 'direct_debit_text',
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -238,7 +238,7 @@
239239 $this->postdatadefaults = array(
240240 'order_id' => '112358' . rand(),
241241 'amount' => '11.38',
242 - 'currency' => 'USD',
 242+ 'currency_code' => 'USD',
243243 'language' => 'en',
244244 'country' => 'US',
245245 'returnto' => $returnTo,
@@ -1476,7 +1476,7 @@
14771477 }
14781478
14791479 function getPaypalRedirectURL() {
1480 - $currency = $this->getData_Raw( 'currency' );
 1480+ $currency = $this->getData_Raw( 'currency_code' );
14811481
14821482 // update the utm source to set the payment instrument to pp rather than cc
14831483 $data['payment_method'] = 'pp';
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -57,7 +57,7 @@
5858 'card_type' => $wgRequest->getText( 'card_type' ),
5959 'expiration' => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ),
6060 'cvv' => $wgRequest->getText( 'cvv' ),
61 - //Leave both of these here.
 61+ //Leave both of the currencies here, in case something external didn't get the memo.
6262 'currency' => $wgRequest->getVal( 'currency' ),
6363 'currency_code' => $wgRequest->getVal( 'currency_code' ),
6464 'payment_method' => $wgRequest->getText( 'payment_method', 'cc' ),
@@ -187,7 +187,7 @@
188188 'card_type' => $cards[$card_index],
189189 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ),
190190 'cvv' => '001',
191 - 'currency' => 'USD',
 191+ 'currency_code' => 'USD',
192192 'payment_method' => 'cc',
193193 'payment_submethod' => '', //cards have no payment submethods.
194194 'issuer_id' => '',
@@ -265,7 +265,7 @@
266266 'anonymous',
267267 'language',
268268 'contribution_tracking_id', //sort of...
269 - 'currency'
 269+ 'currency_code',
270270 );
271271 return $fields;
272272 }
@@ -323,17 +323,15 @@
324324 $currency = $this->getVal( 'currency_code' );
325325 } elseif ( $this->isSomething( 'currency' ) ) {
326326 $currency = $this->getVal( 'currency' );
 327+ $this->expunge( 'currency' );
327328 }
328329
329330 if ( $currency ){
330 - //set them both.
331331 $this->setVal( 'currency_code', $currency );
332 - $this->setVal( 'currency', $currency );
333332 } else {
334 - //we want these unset if neither of them was anything, so things
335 - //using this data know to use their own defaults.
336 - $this->expunge( 'currency_code' );
337 - $this->expunge( 'currency' );
 333+ //we want this set tu null if neither of them was anything, so
 334+ //things using this data know to use their own defaults.
 335+ $this->setVal( 'currency_code', null );
338336 }
339337 }
340338
@@ -940,7 +938,7 @@
941939 'gateway',
942940 'gateway_txn_id',
943941 'response',
944 - 'currency',
 942+ 'currency_code',
945943 'amount',
946944 'date',
947945 );
Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php
@@ -194,8 +194,8 @@
195195 $priceFloor = $this->adapter->getGlobal( 'PriceFloor' );
196196 $priceCeiling = $this->adapter->getGlobal( 'PriceCeiling' );
197197 if ( !preg_match( '/^\d+(\.(\d+)?)?$/', $data['amount'] ) ||
198 - ( ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) < ( float ) $priceFloor ||
199 - ( float ) $this->convert_to_usd( $data['currency'], $data['amount'] ) > ( float ) $priceCeiling ) ) {
 198+ ( ( float ) $this->convert_to_usd( $data['currency_code'], $data['amount'] ) < ( float ) $priceFloor ||
 199+ ( float ) $this->convert_to_usd( $data['currency_code'], $data['amount'] ) > ( float ) $priceCeiling ) ) {
200200
201201 $error['invalidamount'] = wfMsg( 'donate_interface-error-msg-invalid-amount' );
202202
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -166,8 +166,8 @@
167167 'gateway' => $transaction['gateway'],
168168 'gateway_txn_id' => $transaction['gateway_txn_id'],
169169 'response' => $transaction['response'],
170 - 'currency' => $transaction['currency'],
171 - 'original_currency' => $transaction['currency'],
 170+ 'currency' => $transaction['currency_code'],
 171+ 'original_currency' => $transaction['currency_code'],
172172 'original_gross' => $transaction['amount'],
173173 'fee' => '0',
174174 'gross' => $transaction['amount'],

Follow-up revisions

RevisionCommit summaryAuthorDate
r102732MFT r100644, r100785, r101785, r102120, r102318, r102332, r102341, r102342, r...awjrichards01:31, 11 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102309Changes the way the currency code is pulled from the source data, to prevent ...khorn19:22, 7 November 2011

Status & tagging log