1
votes

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;
}
1
Welcome to Stack Overflow. Please read the help pages, take the SO tour, read about how to ask good questions, as well as this question checklist. Lastly learn how to create a Minimal, Complete, and Verifiable examplegehbiszumeis
i am looking for same ..YogiAR
have anyone got an answer for this ????YogiAR

1 Answers

0
votes

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" -