Search code examples
androidgoogle-paygoogle-wallet

How to check if a pass has been added to Google Wallet?


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


Solution

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