Credit Card number Validation algorithm
Is there any other algorithm开发者_StackOverflow中文版 apart from Luhn's algorithm which is used for validation of credit card number as Visa card numbers are not passing the criteria of Luhn's algorithm.
Credit cards are now online validated.
There is no more criterion to validate a credit card else than directly querying the VISA service, which also validates the card against currently available plafond.
In a few words, today it's all online.
If you are using the Luhn Algorithm to calculate the final digit of the card (lets call this digit x); then I have heard that some banks are now issuing cards with a value of x +/- 5.
This effectively doubles the amount of valid card numbers. I have no idea as to whether this is true or not as I don't have access to that many card numbers, but maybe you could compare the numbers you have.
Yes, sometimes the Luhn algorithm does not validate actual cards. This API implements checks against the Luhn algorithm in a more expanded way which should be able to handle all scenarios.
const options = {
method: 'GET',
headers: {Accept: 'application/json', 'X-Api-Key': '[APIkey]'}
};
fetch('https://api.epaytools.com/Tools/luhn?number=[CardNumber]&metaData=true', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
精彩评论