2

I have followed the tutorial provided HERE. Quick start demo can be found HERE.

If I choose in "tokenizationSpecification" param below method,

private static JSONObject getGatewayTokenizationSpecification() throws JSONException {
return new JSONObject(){{
  put("type", "PAYMENT_GATEWAY");
  put("parameters", new JSONObject(){{
    put("gateway", "example");
    put("gatewayMerchantId", "exampleGatewayMerchantId");
    }
  });
}};

}

It works fine but if I Choose below method,

private static JSONObject getDirectTokenizationSpecification()
        throws JSONException, RuntimeException {
    if (Constants.DIRECT_TOKENIZATION_PARAMETERS.isEmpty()
            || Constants.DIRECT_TOKENIZATION_PUBLIC_KEY.isEmpty()
            || Constants.DIRECT_TOKENIZATION_PUBLIC_KEY == null
            || Constants.DIRECT_TOKENIZATION_PUBLIC_KEY == "REPLACE_ME") {
        throw new RuntimeException(
                "Please edit the Constants.java file to add protocol version & public key.");
    }
    JSONObject tokenizationSpecification = new JSONObject();

    tokenizationSpecification.put("type", "DIRECT");
    JSONObject parameters = new JSONObject(Constants.DIRECT_TOKENIZATION_PARAMETERS);
    tokenizationSpecification.put("parameters", parameters);

    return tokenizationSpecification;
}

Its not working.[Not displaying my list of cards.]

Note:- I have performed below method to generate public key and replaced it in constants file as well.

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

Question:- -Do I must have developer profile in google pay to run the demo ?

Hardy
  • 2,576
  • 1
  • 23
  • 45
  • Anything you are getting in Logcat? – Pratik Butani Nov 29 '19 at 13:22
  • Have you checked this [Integration checklist](https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist) – Pratik Butani Nov 29 '19 at 13:29
  • @PratikButani Yes I checked it but Do i must need gPay developer profile to just run quick start demo ? – Hardy Nov 29 '19 at 13:42
  • You don't need to be registered to try out the test integration. Try the following public key which seems to work for web integration: `BOdoXP+9Aq473SnGwg3JU1aiNpsd9vH2ognq4PtDtlLGa3Kj8TPf+jaQNPyDSkh3JUhiS0KyrrlWhAgNZKHYF2Y=` (from: https://developers.google.com/pay/api/web/guides/resources/payment-data-cryptography#public-key-format) – Soc Nov 30 '19 at 07:22
  • @Soc Still getting "There are no accepted cards available for use with this merchant." I want card list as it is displaying with "gateway" option. – Hardy Nov 30 '19 at 08:52
  • Out of interest, what is the reason for choosing DIRECT integration? Are you across the additional work/obligations involved with DIRECT integration? https://stackoverflow.com/questions/57390443/google-pay-payment-integration-with-using-direct-tokenization/58863800#58863800 – Soc Dec 02 '19 at 20:11

2 Answers2

1

Country may be a factor in this case.

To eliminate this, can you try and create a new Google account for testing purposes? Create this Google account in the US and add a payment method/credit card to that account.

Test it out with the following example: https://jsfiddle.net/pxsb4jhn/ (it works for me, I am located in the US)

const allowedCardNetworks = ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"];

const tokenizationSpecification = {
  "type": "DIRECT",
  "parameters": {
    "protocolVersion": "ECv2",
    "publicKey": "BOdoXP+9Aq473SnGwg3JU1aiNpsd9vH2ognq4PtDtlLGa3Kj8TPf+jaQNPyDSkh3JUhiS0KyrrlWhAgNZKHYF2Y="
  }
};

If it works and displays the card, it is likely a problem with DIRECT integration now being available in the country of the user you were using.

It it still doesn't work, it is potentially an issue the card not supporting DIRECT integration, in which case, try with a different card (ideally from another country like the US - this may be difficult if you don't have one available).

Soc
  • 7,425
  • 4
  • 13
  • 30
  • It worked with outside india as we have different payment integration method for "indian gpay account". – Hardy Dec 03 '19 at 06:06
0

There are no accepted cards available for use with this merchant.

This message usually comes when the current Google user doesn't have any cards that are compatible with the payment options provided by the merchant. Specifically allowedCardNetworks and allowedAuthMethods.

Sreeram Nair
  • 2,369
  • 12
  • 27
  • Again, will say same demo merchant Id works with "gateway" method and not working with "direct" method. @Sreeram Nair – Hardy Dec 02 '19 at 06:16