1

I am trying to integrate google pay in my android app. I want to integrate google pay without any payment gateway in between (means DIRECT approach rather than PAYMENT_GATWAY token specification). I found DIRECT method integration code on official site. In that google asks for protocolVersion and publicKey as parameter and below i found that i can get my public key in my Google Pay Developer Profile. I searched for Google Pay Developer account but unable to found public key Anyone can help me to get public key for google pay DIRECT integration?

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;
}
sweet_vish
  • 141
  • 1
  • 8
  • Welcome to Stack Overflow. Please read the [help pages](https://stackoverflow.com/help), take the [SO tour](https://stackoverflow.com/tour), read about [how to ask good questions](https://stackoverflow.com/help/how-to-ask), as well as [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). Lastly learn how to create a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – gehbiszumeis Aug 14 '19 at 06:41
  • i am looking for same .. – YogiAR Oct 09 '19 at 20:43
  • have anyone got an answer for this ???? – YogiAR Oct 09 '19 at 20:43

1 Answers1

0

You can refer to an answer that I provided to the following question: Where is Google pay Developer account and how to generate public key to upload in it?

Adding a public key to your Google Pay Developer Profile:

The public key needs to be added to both the Google Pay Developer Profile and included as part of the payment request: https://developers.google.com/pay/api/android/reference/request-objects#direct

Note that you need to be registered with Google Pay for DIRECT integration.

Example:

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

Generating a public key:

The following link provides details on how to generate a public key using OpenSSL: https://developers.google.com/pay/api/android/guides/resources/payment-data-cryptography#using-openssl

Important bits:

# 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" -
Community
  • 1
  • 1
Soc
  • 7,425
  • 4
  • 13
  • 30