Mwalker has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/72661


Change subject: (FR #987) Fix Luhn Check for Odd Numbered Cards
......................................................................

(FR #987) Fix Luhn Check for Odd Numbered Cards

Silly logic errors...

Change-Id: I4ca0483d2fd33343106501b94f87a75960f5c05e
---
M gateway_common/DataValidator.php
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/61/72661/1

diff --git a/gateway_common/DataValidator.php b/gateway_common/DataValidator.php
index 26f6e60..30e7649 100644
--- a/gateway_common/DataValidator.php
+++ b/gateway_common/DataValidator.php
@@ -861,14 +861,14 @@
         * @return bool True if the number was valid according to the algorithm
         */
        public static function luhn_check( $str ) {
-               $odd = !strlen( $str ) % 2;
+               $odd = (strlen( $str ) % 2);
                $sum = 0;
 
                for( $i = 0; $i < strlen( $str ); $i++ ) {
                        if ( $odd ) {
                                $sum += $str[$i];
                        } else {
-                               if (( $str[$i] * 2 ) > 9 ) {
+                               if ( ( $str[$i] * 2 ) > 9 ) {
                                        $sum += $str[$i] * 2 - 9;
                                } else {
                                        $sum += $str[$i] * 2;

-- 
To view, visit https://gerrit.wikimedia.org/r/72661
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ca0483d2fd33343106501b94f87a75960f5c05e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to