【问题标题】:reading apple pay token using a ACR122 NFC reader使用 ACR122 NFC 阅读器读取苹果支付令牌
【发布时间】:2014-10-21 19:18:00
【问题描述】:

我有一个 ACR122 NFC 阅读器,并尝试查看是否可以读取 Apple Pay 生成的令牌。下面是我正在尝试的一些 Java 代码,但每次只返回一个 4 个字母数字字符。 Apple Pay iphone 感应到 nfc 阅读器 - 我需要发送特定的 apdu 命令来检索令牌吗?

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 < bytes.length; j++ ) {
      v = bytes[j] & 0xFF;
      hexChars[j * 2] = hexArray[v >>> 4];
      hexChars[j * 2 + 1] = hexArray[v & 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<CardTerminal> 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();
      }
    }
  }
}

【问题讨论】:

    标签: java iphone nfc acr122 applepay


    【解决方案1】:

    你发出的命令

    FF CA 00 00 04
    

    将为您提供 iPhone 的智能卡(安全元件)的防冲突标识符(或者实际上是前 4 个字节,如果它有超过 4 个字节)。

    Apple Pay(通过非接触式接口)实施非接触式支付卡的 EMV 标准。因此,为了与非接触式 EMV 支付卡进行通信,您需要实现该协议。

    顺便说一句。不要将支付令牌视为一串字节。它远不止于此。 EMV 支付令牌可以是

    • 由临时“信用卡号”(等)和用于生成交易的密钥组成的临时支付“卡”(仅限单次/有限时间/有限次数的交易使用)授权(-> 这通常用于 HCE 应用程序,例如 Google 钱包)

    • 一张永久支付卡(独立但固定的信用卡号、有效期、密钥等),用于授权稍后从关联信用卡中扣除的付款(-> 这似乎是与 Apple Pay 一起使用——也与基于安全元素的 Google 钱包一起使用)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-26
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 2014-01-21
      相关资源
      最近更新 更多