r79212 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79211‎ | r79212 | r79213 >
Date:22:16, 29 December 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Switched from using 'switch' format to elseif for credit card number validation (i wasn't thinking when i did the switch statement and of course, it can't work); Removed depircated error message for credit card number
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -295,7 +295,7 @@
296296 'city' => wfMsg( 'payflowpro_gateway-error-msg-city' ),
297297 'state' => wfMsg( 'payflowpro_gateway-error-msg-state' ),
298298 'zip' => wfMsg( 'payflowpro_gateway-error-msg-zip' ),
299 - 'card_num' => wfMsg( 'payflowpro_gateway-error-msg-card_num' ),
 299+ 'card_num' => wfMsg( 'payflowpro_gateway-error-msg-card-num' ),
300300 'expiration' => wfMsg( 'payflowpro_gateway-error-msg-expiration' ),
301301 'cvv' => wfMsg( 'payflowpro_gateway-error-msg-cvv' ),
302302 );
@@ -329,32 +329,17 @@
330330 }
331331
332332 // validate that credit card number entered is correct and set the card type
333 - switch( $data[ 'card_num' ] ) {
334 - // american express
335 - case preg_match( '/^3[47][0-9]{13}$/', $data[ 'card_num' ] ):
336 - $data[ 'card' ] = 'american';
337 - break;
338 -
339 - // mastercard
340 - case preg_match( '/^5[1-5][0-9]{14}$/', $data[ 'card_num' ] ):
341 - $data[ 'card' ] = 'mastercard';
342 - break;
343 -
344 - // visa
345 - case preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data[ 'card_num' ] ):
346 - $data[ 'card' ] = 'visa';
347 - break;
348 -
349 - // discover
350 - case preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data[ 'card_num' ] ):
351 - $data[ 'card' ] = 'discover';
352 - break;
353 -
354 - // an invalid credit card number was entered
355 - default:
356 - $error_result = '1';
357 - $error[ 'card_num' ] = wfMsg( 'payflowpro_gateway-error-msg-card-num' );
358 - break;
 333+ if ( preg_match( '/^3[47][0-9]{13}$/', $data[ 'card_num' ] ) ) { // american express
 334+ $data[ 'card' ] = 'american';
 335+ } elseif ( preg_match( '/^5[1-5][0-9]{14}$/', $data[ 'card_num' ] ) ) { // mastercard
 336+ $data[ 'card' ] = 'mastercard';
 337+ } elseif ( preg_match( '/^4[0-9]{12}(?:[0-9]{3})?$/', $data[ 'card_num' ] ) ) {// visa
 338+ $data[ 'card' ] = 'visa';
 339+ } elseif ( preg_match( '/^6(?:011|5[0-9]{2})[0-9]{12}$/', $data[ 'card_num' ] ) ) { // discover
 340+ $data[ 'card' ] = 'discover';
 341+ } else { // an invalid credit card number was entered
 342+ $error_result = '1';
 343+ $error[ 'card_num' ] = wfMsg( 'payflowpro_gateway-error-msg-card-num' );
359344 }
360345
361346 return $error_result;
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -60,7 +60,6 @@
6161 'payflowpro_gateway-error-msg-state' => 'state',
6262 'payflowpro_gateway-error-msg-zip' => 'postal code',
6363 'payflowpro_gateway-error-msg-country' => 'country',
64 - 'payflowpro_gateway-error-msg-card_num' => 'credit card number',
6564 'payflowpro_gateway-error-msg-expiration' => "card's expiration date",
6665 'payflowpro_gateway-error-msg-cvv' => 'CVV from the back of your card',
6766 'payflowpro_gateway-error-msg-captcha' => "The Captcha value you entered is incorrect. Please try again.",

Follow-up revisions

RevisionCommit summaryAuthorDate
r79267Partially reverted r79212 to replace 'payflowpro_gateway-error-msg-card_num' ...awjrichards17:16, 30 December 2010

Status & tagging log