4

I am using the new Google Wallet API implementation("com.google.android.gms:play-services-pay:16.1.0") for adding passes to Google Wallet app.

Here is the sample:

import com.google.android.gms.pay.PayClient

private val walletClient: PayClient = Pay.getClient(this)
walletClient.savePassesJwt(passJwtToken, this, addToGoogleWalletRequestCode)

It works correctly, it adds the pass to Google Wallet. If it was added before, it shows a screen that the pass has already been added to Wallet.

But I can't find a way how to check if the pass has already been added to Google Wallet to show the correct text on the button. Because, in the guidelines, there are two types of buttons :

enter image description here

How to check if the pass has already been added?

from the documentation and codelab I only found how to check the pay API available status

2 Answers 2

1

I have asked Google and this is the reply I got

The devsite here outlines how to link to an existing pass for your users, but this doesn't tell you if said pass is already existing. The best way to track whether a pass is saved or not is to set up a table which references your callbacks to know if the pass with a given ID is currently saved.

5
  • Does that mean we are NOT able to check whether or not the pass has been added to Google Wallet? ONLY Google Wallet will send a corresponding post request to our endpoint when a user's adding or deleting event occurs? Commented May 26, 2023 at 7:28
  • You could also try to listen for ActivityResult developers.google.com/wallet/retail/loyalty-cards/… I dont know any other ways... Commented May 27, 2023 at 13:06
  • Thanks for your reply. Actually, I mean could we find a way to check if users have added the pass? When they open the app next time they can see the View in Google Wallet button in our app. Commented May 29, 2023 at 2:22
  • On their codelab, they have issue which is unanswered github.com/google-pay/wallet-android-codelab/issues/2. In their com.google.android.gms:play-services-pay library there is no useul APIs for this. After researching for 2-3 days I just gave up. There seems to be no way to do this on Android, it should be done via BE Commented May 30, 2023 at 15:28
  • @GeorgeShalvashvili Howdy - but what happens if the user deletes the pass from their wallet? We're probably not going to know that and therefore not have a way to give the user the ability to re-add, right? Maybe this is a strange edge case, but... Commented Aug 25 at 8:06
1

Unfortunately, the API doesn't check if the pass is currently added to the user's Wallet.

The best way to implement something like this would be to use the callback feature, storing the user ID alongside the pass ID in your data table, then polling the data table every time the button loads to see if the user has already saved their pass. This requires extra development work; however this is possible to implement. Also, please note that this would unfortunately be out of scope for our support team to assist with.

Above is the response from Google Wallet Support Team, and we need definitely to implement this via BE.

1
  • maybe try to use "com.google.android.gms:play-services-tapandpay" api
    – Or Azoulay
    Commented May 7 at 8:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.