Which algorithm does CreditCardAttribute use for credit card number format validation

落爺英雄遲暮 提交于 2019-12-05 11:50:42

The last line:

return num % 10 == 0;

Is a very strong hint that this is a Luhn Algorithm

This algorithm is really a Luhn's algorithm. Unfortunately not all card numbers could be verified by this algorithm so it is not 100% method. However, card numbers of Mastercard and Visa products that allow keyed card number entry should pass this check.

The only 100% way to validate if the card number exist is to perform a transaction. Usually Acquirer Host System protocols used for PoS connections have provisions to validate if the card is not on stop lists and exist in routing tables.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!