Hacker News new | ask | show | jobs
by notdonspaulding 4528 days ago
If you only accept the 4 biggest card issuers, you can get away with some dead-simple code to indicate to the user what card type their number indicates they are.

Personally, I bind an onkeyup event handler to fade in the appropriate icon based on the first digit of the number. This is not safe if you accept more than these 4 card types, (we don't).

    function detect_cc_type(number){
        return {
            '3': 'american_express',
            '4': 'visa',
            '5': 'mastercard',
            '6': 'discover'
        }[number[0]];
    }
2 comments

Except that Maestro cards start with 6 as well.

Also, many ATM cards (a foreign concept to this European until very recently) overlap with Visa ranges. In fact, my ATM card parses exactly as a Visa number. It even has the Visa trademark mentioned on the back. No, you can't use it for online transactions. Apparently, Visa Debit is not a thing in Canada ...

My point is, showing wrong UI is often worse than clunkier UI.

Just so I understand, your complaint is: if you enter a number that isn't a credit card number, but that can't actually be differentiated from a valid credit card number, the credit card widget isn't able to determine that it's not valid? You seem to be expecting a great deal from this widget.
> My point is, showing wrong UI is often worse than clunkier UI.

Point taken. As I thought I pointed out however, it's not wrong UI for my app. Since our company only accepts those 4 options, any other code that does more work than my example is a pointless waste of time (for both the programmer and computer).

If you only accept the 4 biggest card issuers

Heads up: If you're in (say) Europe or UK, then American Express and Discover aren't a "big card issuer"

>Heads up: If you're in (say) Europe or UK, then American Express and Discover aren't a "big card issuer"

Do you only have Visa and Mastercard then?

Yes. And local bank debit cards usually combined on the VISA card, in Norway there is BankAxept, Dankort in Denmark and something else Germany can't remember. The fees for these transactions are next to nothing compared to Visa/MC here in Norway. But very rarely accepted online (unfortunately).
This is similar in Australia and New Zealand as well. Visa and MasterCard are extremely common, AMEX is sometimes offered with fancy accounts (usually as a second card), and Discover is all but unheard of.

We have a checking account payment system called EFTPOS which has near universal acceptance, and can be combined on the same card as a Visa/MC/AMEX.

Contactless payment (PayWave and PayPass) is rapidly becoming commonplace among retailers, and can be used for transactions up to AU$100.

http://en.wikipedia.org/wiki/Debit_card#Australia

Australia plans to deprecate the use of signature verification for domestic credit cards later this year, requiring Chip+PIN for all cards issued by Australian banks. Signatures will still be accepted for foreign cards, because tourists.

http://www.lifehacker.com.au/2014/01/credit-card-pin-number-...

Visa Debit is available and works, but doesn't really have any domestic advantages over EFTPOS. Maestro and PLUS aren't brands Australians generally interact with, except when traveling.

Frustratingly, Australian Chip+PIN cards don't seem to travel overseas well -- in ATMs they work fine (with fees galore) but in retail, the terminal often insists on a signature instead of a PIN.

And a boatload of country-specific systems (both credit cards, debit cards and various systems for direct bank transfers)
Yes, there are often country-specific debit cards, but I'm not aware of many country-specific credit cards in Europe? Within the EU (and especially Eurozone), bank transfers are all easy to do and interoperable.
I'm in the UK and had an AmEx card for many years. Visa and Mastercard dominate the market, though.
Yes.
In Canada, it's Visa and Mastercard, and the occasional AmEx. I don't think anyone here takes Discover.
Amex is big enough that it is accepted almost everywhere in Europe. When it isn't, it is usually over cost, not lack of demand.

As for Discover, I don't think I've ever seen a Discover card in Europe...