General steps for credit card verification services

zhaozj2021-02-16  62

1. Delete all unnecessary characters (spaces, dash, period, even characters), so that the returned credit card number only contains numbers.

Using the function trimtodigits.

2. Check if the credit card number is valid.

1). Determine the credit card type. Mastercard is 16-bit numbers, always starting with 51, 52, 53, 54 or 55.

The Visa card number is typically 13 or 16 bits, always starting with 4.

The Discover credit card is always 16 characters, always starting with 6011.

The American Express credit card is always 15 characters, starting with 34 or 37.

2). See if the number is valid. First get the number of digits, and create a checksum.

The odd number × 2, then the result is greater than 9, then minus 9, add the remainder to the checksum. The even digit is directly added to the checksum. The resulting final check and if it can be removed by 10, it is an effective credit card number.

转载请注明原文地址:https://www.9cbs.com/read-20226.html

New Post(0)