Vitalii Shcherbyna
Vitalii Shcherbyna

Reputation: 19

java.lang.ClassCastException: com.google.android.gms.tapandpay.firstparty.AccountInfo cannot be cast to byte[] during pushTokenize with TapAndPay API

I encountered an issue while trying to integrate Google Wallet using the TapAndPay API in my Android app. After executing the following code snippet, I was redirected to the Google Wallet app, where I received the error: "Invalid argument".

Using logcat, I found this exception:

java.lang.ClassCastException: com.google.android.gms.tapandpay.firstparty.AccountInfo cannot be cast to byte[]

Here’s the relevant code that triggers the issue:

UserAddress userAddress = UserAddress.newBuilder()
    .setName(name)
    .setAddress1(address)
    .setLocality(city)
    .setCountryCode(countryCode)
    .setPostalCode(postalCode)
    .setPhoneNumber(phoneNumber)
    .build();

PushTokenizeRequest pushTokenizeRequest = new PushTokenizeRequest.Builder()
    .setOpaquePaymentCard(opcBytes)
    .setNetwork(TapAndPay.CARD_NETWORK_VISA)
    .setTokenServiceProvider(TapAndPay.TOKEN_PROVIDER_VISA)
    .setDisplayName(displayName)
    .setLastDigits(lastDigits)
    .setUserAddress(userAddress)
    .build();

tapAndPayClient.pushTokenize(activity, pushTokenizeRequest, REQUEST_CODE_PUSH_TOKENIZE);

The exception seems to suggest a type mismatch, but I don’t directly deal with AccountInfo in my code. The opcBytes variable is expected to be a byte[] array, and it's I received the value from TSP and passed it with TapAndPay API.

Does anyone know why this exception occurs? Could it be an issue with how PushTokenizeRequest or opcBytes is being handled internally by the API? Any insights or suggestions for debugging this problem would be greatly appreciated.

I played with opcBytes value but it didn't help me. And finally at the of logcat I got this:

TapAndPayApiException: # eqej@a718171c

enter image description here

Upvotes: 0

Views: 89

Answers (0)

Related Questions