I am trying to read the credit card data from the VISA card but could not able to make a success.As in the internet resources I have found that for the MASTER card we can select the PSE directory using 1PAY.SYS.DDF01 file and then read the records. But for VISA its not mandatory and when I use the following file using SELECT command for getting the PSE directory I get the response as '6A82'.Which means its is not supported by the file system. I looked for the Error in the EMV 4.2 Book 1(EMV specification) and it says that we have to use a "List of AIDs". It says "The terminal issues another SELECT command using the next AID in its list". I am unable to understand this and proceed further.
Any help on how to get the PSE for the VISA card or the AID to get the credit card details?
Thanks, Shekhar
First of all PPSE applet is nothing specific for VISA nor for MasterCard. It is defined by EMV, and it is used as you correctly noticed for listing the AIDs of the available payment applications on the card. But if it is not there the terminals try all the supported AIDs to build the candidate list.
If you want to select the VISA applet, but you do not know the complete AID you can use partial selection. Since all the VISA AIDs begin with the VISA's RID: A0 00 00 00 03. You can try to send this command:
This will return the first instance:
00 A4 04 00 05 A0 00 00 00 03 00
and this will give you more if you have on your card:
00 A4 04 02 05 A0 00 00 00 03 00
So the problem is you don't know AID of your application on the card? There's no method to get them (except PSE), you have to know first what applications on card you support. So the "List of AIDs" is list of AIDs you support, which was told you by your acquirer. You can try to create this list yourself basing on some standard AIDs which you have listed here: http://en.wikipedia.org/wiki/EMV#Application_selection
It is kind of weird for me... My research indicates that for VISA that application will always be available, but for Mastercard it is not mandatory...
Anyway, Here is the command I send to my cardreader inorder to select that application:
// OP CL P1 P2 LN DATA------------------------------------- EL
//select command 00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00
NSString* str= @"1PAY.SYS.DDF01";
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding];
int datalength = data.length;
NSMutableData *selectPSECommand = [[NSMutableData alloc] init];
[selectPSECommand appendBytes:"\x00" length:1]; //command class
[selectPSECommand appendBytes:"\xA4" length:1]; //APDU_INSTRUCTION_SELECT_FILE
[selectPSECommand appendBytes:"\x04" length:1]; //select file by name
[selectPSECommand appendBytes:"\x00" length:1]; //First or only occurrence of file
[selectPSECommand appendBytes:&datalength length:1]; //data length
[selectPSECommand appendData:data]; //the data we are sending
[selectPSECommand appendBytes:"\x00" length:1]; //expected response length. here it is 0. We are only selecting a file.
The code sample is for Objective C.
Compare the data you send with the data I'm sending and see if it corresponds. In the meantime, I'll be looking into running through the AID list.
Hope it helps. Ezfrag
You can use an AID List like this one. However some cards respond with "wrong" data when iterating through the list. i.e., I had the case where a V-Pay VISA card was read as Maestro. If you have to iterate through a big AID List to "open" the card info, I would recommend you to add a flag to get the actual AIDs from the card, then go back to the main method to read the card with the main AID provided.
Something like:
- Read Card iterating through a AID List
- If 0x90 is returned (successful read), extract data
- Check where the data returned is of type AID (0x4f).
- When so, clear your list and get the data again with the proper AID now that you know it is right for sure as it comes directly from the card.
As the AID usually comes in the first records from the card, this loop ensures the process is correct at a minimum time cost.
来源:https://stackoverflow.com/questions/6503783/how-to-read-emv-based-smart-visa-card-details