如何通过直接令牌规范方法在Google Pay集成中获取公钥

问题描述 投票:1回答:1

我正在尝试将google pay集成到我的android应用中。我想集成google pay之间没有任何支付网关(意味着直接方法,而不是PAYMENT_GATWAY令牌规范)。我在官方网站上找到了DIRECT方法集成代码。在那个谷歌要求提供protocolVersion和publicKey作为参数,在下面我发现我可以在我的Google Pay开发者资料中获取我的公钥。我搜索了Google Pay开发者帐户,但找不到公共密钥有人可以帮助我获取Google Pay DIRECT集成的公共密钥吗?

private static JSONObject getTokenizationSpecification() {
  JSONObject tokenizationSpecification = new JSONObject();
  tokenizationSpecification.put("type", "DIRECT");
  tokenizationSpecification.put(
      "parameters",
      new JSONObject()
          .put("protocolVersion", "ECv2")
          .put("publicKey", "replace with public_key"));

  return tokenizationSpecification;
}
android google-pay
1个回答
0
投票

您可以参考我为以下问题提供的答案:Where is Google pay Developer account and how to generate public key to upload in it?

向您的Google Pay开发者资料添加公钥:

公钥需要同时添加到Google Pay开发者资料中,并作为付款请求的一部分:https://developers.google.com/pay/api/android/reference/request-objects#direct

请注意,您需要向Google Pay注册才能进行DIRECT集成。

示例:

"tokenizationSpecification": {
  "type": "DIRECT",
  "parameters": {
    "protocolVersion": "ECv2",
    "publicKey": "BOdoXP1aiNp.....kh3JUhiSZKHYF2Y="
  }
}

生成公钥:

以下链接提供了有关如何使用OpenSSL生成公共密钥的详细信息:https://developers.google.com/pay/api/android/guides/resources/payment-data-cryptography#using-openssl

重要位:

# generate private key
openssl ecparam -name prime256v1 -genkey -noout -out key.pem

# generate a base64-encoded public key
openssl ec -in key.pem -pubout -text -noout 2> /dev/null | grep "pub:" -A5 | sed 1d | xxd -r -p | base64 | paste -sd "\0" -
© www.soinside.com 2019 - 2024. All rights reserved.