2
votes

I am working on a mobile payment app. User can add all his cards, both payment (e.g. Credit/Debit/Cash cards) and non-payment (loyalty cards to earn points) cards to the app.

While adding card, I want to differentiate between these two types of cards and want to show them in separate lists within app.

I though Luhn algorithm will do but even non-payment cards happen to calculate check digit as per the Luhn algorithm.

Please suggest if there is any other mechanism which I can use to differentiate between these two types of cards pragmatically.

thanks

1
I would suggest to let your application users to group cards as they want or use regexps to quick card number analysis for common ranges. There are a lot of ready to use examples, just google. Usual regexps are not 100% correct. Support of Card BIN tables will be more complicated due to the size of such tables and permanent updates.iso8583.info support
In addition to comment above, ISO/IEC 7812 is the standard for most payment cards, and therefore you can be fairly confident payment card numbers start with 4/5/6. There may be some loyalty cards within those ranges though, particularly in the 6 range. Further, some card issuers (JCB for one) follow different standards entirely (JCB cards start with 3). In summary - let the users sort it out!PaulG
@PaulG - Actually, 7812 applies to all credit cards, JCB included. This table has all the major BIN ranges (first few digits). It's worth noting that American Express cards also start with 3, but are very easy to distinguish from JCB based on the second digit.Bobson
github.com/card-io/card.io-Android-SDK CardIO implementation differentiate card on the basis of first 4 digits. May be it helpsAndroidGeek

1 Answers

0
votes

As @iso8583-info-support implied in their comment, the only good way to do this is a BIN range lookup. A BIN is the first few digits of a card (technically, up to 6) which are issued in ranges to card issuers. So for example, Visa "owns" 4*, so any card that starts with a 4 is a Visa card. MasterCard "owns" 2221*-2720* and 51*-55*, so any card which starts with a 51, 52, 53, 54, or 55 is a MasterCard, but a card which start with a 56 is not. (It's actually a Maestro card, which is a MasterCard sub-brand, but it's still technically separate - one's debit, the other is credit.) Anything unrecognized on a public BIN is almost certainly a loyalty card.

This can be a database table, but it doesn't have to be - you can easily hard code it into your app. But be sure to make it adjustable. MasterCard will start introducing card numbers which begin with a 2 in this coming October... if you can't modify your app to support that, you're going to annoy users.

This table on Wikipedia has all the major BIN ranges. There's also at least one company that sells an API which goes into far more detail and is kept much more up-to-date than Wikipedia.