Live data from Hacker News

Why is this shameful practice so common?

unixwiz.net

11–20 of 40 posts

Re: Why is this shameful practice so common?

#12
post #7

Earlier quoted context omitted.

But your application server can strip out spaces and dashes before you send the number to the gateway. Right?

Of course - We do it. Wondering if anyone uses a payment gateway which prohibits this..

how could they possibly even know you've already stripped out non-numeric characters?

Re: Why is this shameful practice so common?

#13
post #11

The payment gateways I've used have explicitly stated in their documentation, that there must be no validation of credit card numbers. I guess it's to avoid programmers messing up the card numbers or something.

I've never seen that before (then again, I haven't looked...).

Do they literally mean no validation? Can't even check to see and strip any non-numeric characters? No luhn algorithm?

Also, how would they know? :p

Re: Why is this shameful practice so common?

#16
It's common for one very simple reason: Programatically, it is much easier to demand user input in a single form than to code for different cases. In this specific case I don't understand it so much because it's exceedingly simple to write a regex replace that replaces every instance of "not a number" with nothing. The linked page describes a less-general use of this in Perl, but it's just as easy in any other modern language.

Here's a single line of python that removes any character that isn't a digit from the string "s":

    re.sub(r'[^\d]', '', s)
Wow, that was almost too easy. Now the user can put spaces, dashes, periods, underscores... who cares! Oh, and if they put in the CSV code or something at the end...

    re.sub(r'[^\d]', '', s)[0:16] 
A single line should cover 99% of the problems the user can create. Compliment it by giving an example of how the number should be input and... done.

Re: Why is this shameful practice so common?

#18
post #15

Even worse is the good ol "4 text boxes" solution.

I personally don't find that particulary annoying, I just hit the tab key. You can always take the user to the next textbox automatically with JavaScript.

I find that intensely annoying. I type 4 digits; press the tab key; start typing the next 4 digits; realise that the page had automatically taken me to the next box, so I’m typing into the 3rd box instead of the 2nd; swear…

Re: Why is this shameful practice so common?

#19
post #16

It's common for one very simple reason: Programatically, it is much easier to demand user input in a single form than to code for different cases. In this specific case I don't understand it so much because it's exceedingly simple to write a regex replace that replaces every instance of "not a number" with nothing. The linked page describes a less-general use of this in Perl, but it's just as easy in any other modern…

Some cards have 19 digit numbers. (If all the cards you accept always have 16 digit numbers then you don’t have to worry about that, of course.)

Re: Why is this shameful practice so common?

#20
Can people submitting posts please take the time to give a few words of description if the title doesn't explain. It would save lots of others reading posts they've no interest in. Some of us use RSS to follow the site and having to pick and choose based on "Why is this shameful practice so common?" doesn't help.
Post reply on HN