I am trying to create an application like this to save my ticket passes in google wallet https://codelabs.developers.google.com/add-to-wallet-android#0. I have done all steps but I couldn't get the result. Google pay button is not visible
Actually, I have a google pay on my mobile but it shows "Unfortunately google pay is not available on this phone" and the google pay button is not visible in the application. so I have manually enabled the google pay button. and when I click that it shows an error "An unexpected error has occurred. Please try again later. [OR_BIBED_07]. how to fix this error.
and this is my code
*that made google pay visible
private fun setGooglePayAvailable(available: Boolean) {
if (available) {
googlePayButton.visibility = View.VISIBLE
} else {
Toast.makeText(
this,
R.string.google_pay_status_unavailable,
Toast.LENGTH_LONG).show()
googlePayButton.visibility = View.VISIBLE
}
}
*onClick google pay button
private fun requestPayment() {
// Disables the button to prevent multiple clicks.
googlePayButton.isClickable = false
// The price provided to the API should include taxes and shipping.
// This price is not displayed to the user.
val dummyPriceCents = 100L
val shippingCostCents = 900L
val task = model.getLoadPaymentDataTask(dummyPriceCents + shippingCostCents)
task.addOnCompleteListener { completedTask ->
if (completedTask.isSuccessful) {
completedTask.result.let(::handlePaymentSuccess)
} else {
when (val exception = completedTask.exception) {
is ResolvableApiException -> {
resolvePaymentForResult.launch(
IntentSenderRequest.Builder(exception.resolution).build()
)
}
is ApiException -> {
handleError(exception.statusCode, exception.message)
}
else -> {
handleError(
CommonStatusCodes.INTERNAL_ERROR, "Unexpected non API" +
" exception when trying to deliver the task result to an activity!"
)
}
}
}
// Re-enables the Google Pay payment button.
googlePayButton.isClickable = true
}
}
*my google wallet button
private fun setAddToGoogleWalletAvailable(available: Boolean) {
if (available) {
layout.passContainer.visibility = View.VISIBLE
} else {
Toast.makeText(
this,
R.string.google_wallet_status_unavailable,
Toast.LENGTH_LONG).show()
}
}
In the same way, when I enabled the google wallet button. when I click that it's not even responding. it should actually save my passes in google wallet
*OnClick wallet button
private fun requestSavePass() {
// Disables the button to prevent multiple clicks.
addToGoogleWalletButton.isClickable = false
model.savePassesJwt(model.genericObjectJwt, this, addToGoogleWalletRequestCode)
}
Json object I send
private val issuerEmail = "irfan*********@gmail.com"
private val issuerId = "338800000002212****"
private val passClass = "338800000002212****.e7504e23-****-4852-b8e4-9345684a2e06"
private val passId = UUID.randomUUID().toString()
private val newObjectJson = """
{
"iss": "$issuerEmail",
"aud": "google",
"typ": "savetowallet",
"iat": ${Date().time / 1000L},
"origins": [],
"payload": {
"genericObjects": [
{
"id": "$issuerId.$passId",
"classId": "$passClass",
"genericType": "GENERIC_TYPE_UNSPECIFIED",
"hexBackgroundColor": "#4285f4",
"logo": {
"sourceUri": {
"uri": "https://storage.googleapis.com/wallet-lab-tools-codelab-artifacts-public/pass_google_logo.jpg"
}
},
"cardTitle": {
"defaultValue": {
"language": "en",
"value": "Google I/O '22 [DEMO ONLY]"
}
},
"subheader": {
"defaultValue": {
"language": "en",
"value": "Attendee"
}
},
"header": {
"defaultValue": {
"language": "en",
"value": "Alex McJacobs"
}
},
"barcode": {
"type": "QR_CODE",
"value": "$passId"
},
"heroImage": {
"sourceUri": {
"uri": "https://storage.googleapis.com/wallet-lab-tools-codelab-artifacts-public/google-io-hero-demo-only.jpg"
}
},
"textModulesData": [
{
"header": "POINTS",
"body": "${Random.nextInt(0, 9999)}",
"id": "points"
},
{
"header": "CONTACTS",
"body": "${Random.nextInt(1, 99)}",
"id": "contacts"
}
]
}
]
}
}
"""
Due to the fact that I am in India, is it not working for me?
Google Wallet is currently not available in India as you suggested which is the reason why you are running into this issue.
Would love to know if you found a workaround for testing the API though!