3

Is it better to ask the user what type of credit card is being entered or to attempt to auto-detect card type using regular expressions?

Some online merchants ask for the credit card type explicitly (Visa, Mastercard, Amex, etc) in a drop-down menu. While others, including Amazon and GitHub, never ask explicitly and instead rely on the properties of the card to determine the card number.

One problem with relying on card type auto-detection is credit card regular expression patterns seem to need updating over time. So these regular expression patterns may need constant updating to remain accurate and prevent holes in the patterns.

Which is better, asking the user for card type explicitly or attempting to auto-detect card type? Are there other considerations?

steampowered
  • 11,809
  • 12
  • 78
  • 98

2 Answers2

2

I've done this kinda sfwr for 20 years and I still sometimes make the mistake of mis-marking my card when I place an order online. Then I get the error that the number I gave is not a VISA card. Silly, when it's so trivial for the programmer to attend to this and never show such an error to the shopper.

Paypal is the only major gateway that wants you to submit the card type with the transaction (I've never tested to see if they will return an error if you get it wrong). The shopper may get the card wrong as I sometimes do, but a regexp never will. If you are writing for any major gateway but Paypal anyway, you either won't be asked or the answer you furnish will be ignored.

Make the checkout process easiest on your shopper and your merchant happy with a speedier checkout. It's not going to have a material effect on the transaction.

Look closely at your gateway API - I'll bet they are not even asking - they can tell by looking at the card number.

Ron Robinson
  • 558
  • 1
  • 3
  • 8
  • 1
    You are correct the gateway does not ask. However, so many payment checkouts do ask. So I was wondering why so many do ask for card type? – steampowered Oct 04 '12 at 21:19
  • Some gateways used to ask back in the 1990s, but then most stopped as they realized it did not add any security to the transaction. Now the programmers who insist on asking or checking I guess are doing it because that's what they've seen on many sites. Our carts never ask unless they are connecting to one of those few gateways that thinks it has to know, then we always calculate it - why give a customer a chance to make a boo-boo when they are about to spend money with your client? – Ron Robinson Oct 05 '12 at 00:44
1

One of the reasons they may ask for the credit card type is to provide with multi-part text input.

  • XXX - XXXX - XXXX - XXXX for American Express
  • XXXX - XXXX - XXXX - XXX for Enroute
  • XXXX - XXXX - XXXX - XXXX for Others

One may argue, it's more usable this way since the user gets a visual representation that matches the card. Also, it may be for hinting where to find the CSC (tho, that can also be inferred from the number).

Alix Axel
  • 151,645
  • 95
  • 393
  • 500