签证令牌服务(VTS)

时间:2017-03-28 01:58:08

标签: java

是否有人通过有效加密将请求发送给Visa令牌服务?

https://developer.visa.com/products/vts/reference#vts__payment_data

能够通过XPAY TOKEN genration,请在代码中帮助JWE:

public static String generateJWE3(PlainPan pan) throws Exception {
    Gson gson = new Gson();
    String json = gson.toJson(pan);

    String sharedSecret = Constants.VTS_SHARED_SECRET;
    MessageDigest md = MessageDigest.getInstance("SHA-256");
    byte[] digest = md.digest(sharedSecret.getBytes("UTF-8"));

    String kid = "gUkXp2s5v8y/A?D(G+KbPeShVmYq3t6w";

    KeyGenerator kg = KeyGenerator.getInstance("AES");
    kg.init(256);

    String encryptionKey = Constants.VTS_API_KEY;

    JWEAlgorithm jweAlgorithm = JWEAlgorithm.A256GCMKW;
    EncryptionMethod encryptionMethod = EncryptionMethod.A256GCM;

    JWEHeader.Builder headerBuilder = new JWEHeader.Builder(jweAlgorithm, encryptionMethod);

    headerBuilder.keyID(encryptionKey);

    JWEHeader header = headerBuilder.build();
    JWEEncrypter encrypter = new AESEncrypter(digest);

    encrypter.getJCAContext().setProvider(BouncyCastleProviderSingleton.getInstance());
    JWEObject jweObject = new JWEObject(header, new Payload(json));
    jweObject.encrypt(encrypter);

    String serialized = jweObject.serialize();
    JWEObject temp = JWEObject.parse(serialized);

    System.out.println("In JWE Header= " + temp.getHeader());
    System.out.println("In Enc Key= " + temp.getEncryptedKey());
    System.out.println("In IV= " + temp.getIV());
    System.out.println("In CT= " + temp.getCipherText());
    System.out.println("In AT= " + temp.getAuthTag());

    //  decrypt(sharedSecret,serialized);

    return serialized;
}

{
  "errorResponse":{
    "status":400,
    "message":"Input for encPaymentInstrument is invalid or inconsistent with the profile.",
    "reason":"invalidParameter",
    "details":[{
      "location":"encPaymentInstrument"
    }]
  }
}

1 个答案:

答案 0 :(得分:1)

问题是由于无效encPaymentInstrument数据,请让用户按照以下步骤操作,

步骤进行API调用:

  • 创建VTS APP

  • 转到已注册的gmail查看来自VTS的电子邮件

  • 导航到该网址(https://developer.digital.visa.com/self-service-ic)设置密码并创建个人资料,为APPID字段指定的值将为“clientAppID”

  • 请使用nimbus-jose-jwt-4.12.jar实用程序生成jwe加密。