We're updating the issue view to help you get more done. 

Luhn Credit Card Validator incorrect return statement

Description

The calculateLuhnMod10Check(final List<Integer> digits) method returns values 1 through 10 instead of 0 through 9. Since the check digit on the credit card can never be 10 and will sometimes be zero, all credit cards ending in zero, which are valid credit card numbers, are failing the validation. Example: 5105 1051 0510 5100.

This is the portion of the validator we are using, but I believe this might also apply to the other two validations for mod 10 and mod 11 in the same ModUtil class, where an additional mod of the appropriate value will be needed to obtain the correct mod if the result is either 10 or 11.

I am suggesting a change from the current return 10 - (sum % 10); to return (10 - sum % 10) %10;, in order to convert any result of 10 to zero, but still maintaining the integrity of all other possible results.

Environment

None

Status

Assignee

Hardy Ferentschik

Reporter

Sue Rocher

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

5.1.1.Final
5.1.0.Final

Priority

Major