Hacker News new | ask | show | jobs
by thechangelog 5199 days ago
The credit card one is especially important. We run a hosted online ticket system for some of our customers and noticed they were getting a bunch of 'Invalid CC' responses from their payment gateway (and paying for each invalid attempt).

We implemented the Luhn[1] algo credit card check on the checkout page. Invalid CCs would trigger a little warning but still allow the form to be submitted. Invalid CC transactions dropped ~90% immediately. Even better we were able to get rid of the 'select your card type' field since that was detected by Luhn. A little JS was a win all around.

[1] http://en.wikipedia.org/wiki/Luhn_algorithm

2 comments

"Even better we were able to get rid of the 'select your card type' field since that was detected by Luhn."

FYI: Card Type is not determined by Luhn algorithms, but rather (broad brush strokes, see http://en.wikipedia.org/wiki/Bank_card_number#Issuer_Identif... for more detail):

3 - American Express 4 - Visa 5 - Mastercard / Diners 6 - Discover

> Invalid CCs would trigger a little warning but still allow the form to be submitted.

Out of curiosity, why allow the form to submit anyways?

Rule #1: never assume your code covers 100% of all cases.
What richthegeek said. We put it in as a rough helper but didn't want to run the risk of denying something valid. The middle ground seems to work well.