【问题标题】:How to get public key in Google pay integration with Direct token specification approach如何通过直接令牌规范方法在 Google Pay 集成中获取公钥
【发布时间】:2019-12-20 16:41:38
【问题描述】:

我正在尝试将 google pay 集成到我的 Android 应用程序中。我想在没有任何支付网关的情况下集成谷歌支付(意味着直接方法而不是 PAYMENT_GATWAY 令牌规范)。我在官方网站上找到了 DIRECT 方法集成代码。在那个谷歌要求protocolVersion和publicKey作为参数,下面我发现我可以在我的谷歌支付开发者资料中获取我的公钥。我搜索了 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】:

您可以参考我为以下问题提供的答案: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" -

【讨论】:

    猜你喜欢
    • 2019-07-01
    • 2020-08-12
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2019-04-19
    • 2014-12-20
    • 2019-12-14
    • 1970-01-01
    相关资源
    最近更新 更多