Hardy
Hardy

Reputation: 2606

Google Pay "quick-start-demo" not displaying card list if I choose "DIRECT" method for Paymenttokenization option

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 ?

Upvotes: 2

Views: 378

Answers (2)

Soc
Soc

Reputation: 7780

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).

Upvotes: 1

Sreeram Nair
Sreeram Nair

Reputation: 2393

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.

Upvotes: 0

Related Questions