title: reading apple pay token using a ACR122 NFC reader
body: <p>I have a ACR122 NFC reader and trying to see if I can read the token generated by Apple Pay.  Below is some code in Java I am trying but only returns a 4 alpha numeric character every time.  The Apple Pay iphone senses the nfc reader - are there specific apdu commands I need to send to retrieve the token?</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  import javax.smartcardio.*;
  
  public class CardTest {
  
    final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
  
    public static String bytesToHex(byte[] bytes) {
      char[] hexChars = new char[bytes.length * 2];
      int v;
      for ( int j = 0; j &lt; bytes.length; j++ ) {
        v = bytes[j] &amp; 0xFF;
        hexChars[j * 2] = hexArray[v &gt;&gt;&gt; 4];
        hexChars[j * 2 + 1] = hexArray[v &amp; 0x0F];
      }
      return new String(hexChars);
    }
  
    public static void main(String[] args) throws Exception {
      TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null);
      System.out.println(factory);
  
      List&lt;CardTerminal&gt; terminals = factory.terminals().list();
      System.out.println("Terminals: " + terminals);
      if (terminals.isEmpty()) {
        throw new Exception("No card terminals available");
      }
  
      CardTerminal terminal = terminals.get(0);
  
      // Keep looping looking for cards until the application is closed
      while( true )
      {
        terminal.waitForCardPresent( 0 );
        try {
          Card card = terminal.connect("*");
          CardChannel channel = card.getBasicChannel();
  
          CommandAPDU command = new CommandAPDU(new byte[]{(byte)0xFF,(byte)0xCA,(byte)0x00,(byte)0x00,(byte)0x04});
          ResponseAPDU response = channel.transmit(command);
  
          byte[] byteArray = response.getBytes();
          System.out.println( bytesToHex( byteArray ) );
          Thread.sleep(1000);
        } catch (CardException e) {
          e.printStackTrace();
        }
      }
    }
  }
  </code></pre>