简体   繁体   中英

APDU command to read credit card data from visa Paywave NFC enabled card using Samsung Galaxy S4

  byte[] APDUCommand = { 
            (byte) 0x00, // CLA Class           
            (byte) 0xA4, // INS Instruction     
            (byte) 0x04, // P1  Parameter 1
            (byte) 0x00, // P2  Parameter 2
            (byte) 0x0A, // Length
            0x63,0x64,0x63,0x00,0x00,0x00,0x00,0x32,0x32,0x31 // AID
        };


    Intent intent = getIntent();
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    IsoDep iso = IsoDep.get(tag);        
    iso.connect();

    byte[] result = iso.transceive(APDUCommand);

I am using the above code to read VisaPayWave NFC card details(card holder's name, expiry date, card number etc) using samsung galaxy s4. The output that i am getting is [106,-126]. I think the APDU command i am using is not correct. Kindly suggest the correct command.

Change your APDU command definition

byte[] APDUCommand = { 
        (byte) 0x00, // CLA Class           
        (byte) 0xA4, // INS Instruction     
        (byte) 0x04, // P1  Parameter 1
        (byte) 0x00, // P2  Parameter 2
        (byte) 0x07, // Length
        (byte) 0xA0,0x00,0x00,0x00,0x03,0x10,0x10 // AID
    };

As lletami answered, Visa payWave is typically selectable with the AID A0000000031010 . So you can use the APDU

00 A4 04 00 07 A0000000031010 00

to select the payWave appplication.

On contactless EMV payment cards, you could also select the PPSE (Proximity Payment System Environment) to retrieve a list of available applications (and their AIDs):

00 A4 04 00 0E 325041592E5359532E4444463031 00

Selecting the EMV payment application is only the first step. You would need to issue several further commands to get the readable credit card data (see this answer ).

For instance, you could issue a GET PROCESSING OPTIONS command (see eg this answer , this answer and this answer ).

And/or you could issue READ RECORD commands to get data from known elementary files. Eg

00 B2 01 0C 00

to read record 1 of EF 1,

00 B2 02 0C 00

to read record 2 of EF 1, or

00 B2 01 14 00

to read record 1 of EF 2, etc.

You can get the EMV specifications for payment systems from http://www.emvco.com/ to learn about possible commands and data structures.

Your response code [106, -126] is better represented as hexadecimal, rather than implying any signed values.

It actually would be 6A82 - which forms SW1 and SW2 of the APDU Response Code. 6A82 corresponds to "Wrong parameter(s) P1 P2; file not found". See EMV Book 1 for more details. Ie "0x63,0x64,0x63,0x00,0x00,0x00,0x00,0x32,0x32,0x31" was not found on the card - but "0xA0,0x00,0x00,0x00,0x03,0x10,0x10" should be.

As lletami says, your APDU command needs rebuilding, including the AID using 'compressed numeric' (as described in EMV Book 1), very similar to Binary Coded Decimal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM