?
Solved

Credit card data, what datatype / length.

Posted on 2004-09-14
4
Medium Priority
?
515 Views
Last Modified: 2013-11-18
Morning experts,  I want to update our old database fields we are using for credit cards.  Right now they are all varchar, but I wanted to find out what I should use for lengths and datatype for the following:

Card type (visa mastercard etc)
Card number
Experation date


0
Comment
Question by:moonrisesystems
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:AaronAbend
ID: 12055280
for a card type I would use a char(1) and select letters that can be used to quickly identify the card (M for mastercard for example). easier than an int and virtually no difference in performance. Make sure it is NOT NULL. Use some other character for "unknown" if you must

Card number should still be a varchar. You save very little space with a char and can accommodate any card type.

Expiration date should be a date. Use the last date of the month/year (some cards actually have a complete date). If you do not do that and go with a char or varchar you will cause yourself a lot of trouble with date math.

Those are my recommendations. I have worked with credit cards though it has not been my focus. Others may have better experience.

Aaron
0
 
LVL 8

Accepted Solution

by:
MartinCMS earned 500 total points
ID: 12055417
I have worked with database with credit cards info for more then 5 yrs.... thru many data type conversion before we have a stable set of data.  Here are my recommendations:

Card Type:   Varchar(20)     spell out the word Visa not just the V,M,A,etc.,
Card Number:   Varchar(20)
Card Expire:  Varchar(5)  mm/yy

you might want to consider the CVC or Card Code to.  This is the verification code from the back of the card.  Most Merchants required this number now.

CVC:  Varchar(5)

Good Luck!




0
 
LVL 7

Expert Comment

by:ChrisFretwell
ID: 12056786
This site is good to explain the different card types, their lengths and check digits.

http://www.beachnet.com/~hstiles/cardtype.html

You may want to be careful about storing the CVV. Its purpose, wehn used, is to prove that the person making the transaction is in physical posession of the card. Its not on the magnetic stripe and not printed on receipts. This will mean reduced loss if somehow your system is comprimised. It can also reduce chargebacks if you require this number to be entered each time. This increases customer confidence etc. But those are marketing/business issues. Just thought I'd throw them in.
0
 
LVL 10

Expert Comment

by:AaronAbend
ID: 12057429
If you store the year and month as a varchar, I would recommend formatting it YYMM (good for another 96 years at least) or YYYYMM so you can do easier queries if necessary. Depends on what you plan to do with the data of course (even just for validating the expiration has not been passed would be easier if it were in this format).
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question