Skip to content

Client token generation does not raise validation error but returns null for nonexistent customers.  #119

Open
@kmichalak

Description

@kmichalak

General information

  • SDK/Library version: 3.19.0
  • Environment: Production
  • Language, language version, and OS: Java all versions

Issue description

Hi,
Following documentation for the client token generation available at https://developer.paypal.com/braintree/docs/reference/request/client-token/generate/java#specify-a-customer-id

If the customer can't be found, it will return a validation error.

Unfortunately it looks like the SDK does not do that. When calling the code from the example in the docs

ClientTokenRequest clientTokenRequest = new ClientTokenRequest()
  .customerId(aCustomerId);
// pass clientToken to your front-end
String clientToken = gateway.clientToken().generate(clientTokenRequest);

using customerId that cannot be matched in the Vault, the gateway.clientToken().generate(clientTokenRequest) returns null value instead of the validation error.
I'm reporting this for SDK version 3.19.0, but I checked latest sources and the code is still the same

public String generate(ClientTokenRequest request) {
      NodeWrapper response = null;
      verifyOptions(request);
      response = http.post(configuration.getMerchantPath() + "/client_token", request);

      String token = response.findString("value");
      if (token != null) {
          token = StringUtils.unescapeUtf8(token);
      }
      return token;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions