Verifying if payment is possible

Implement the isReadyToPayRequest method to check if the Android and Google Play versions installed on the mobile device are supported by the PaymentsClient API.

Depending on the response, it will be possible to hide/show the payment button.

Excerpt from the code sample:

private fun prepareIsReadyToPayRequest(): IsReadyToPayRequest {
	val isReadyToPayRequest = getBaseRequest()
		"allowedPaymentMethods", JSONArray()
		.put(getCardPaymentMethod(null, null)))
	return IsReadyToPayRequest.fromJson(isReadyToPayRequest.toString())
PayZenPayment.isPaymentPossible(paymentsClient).addOnCompleteListener { task ->
	try {
		val result = task.getResult(
		if (result) {
			// show Google Pay as a payment option            
			payBtn.visibility = View.VISIBLE
		} else {
			payBtn.visibility = View.VISIBLE
			Toast.makeText(this, "isPaymentPossible return false", Toast.LENGTH_LONG).show()
	} catch (e: ApiException) {
		Toast.makeText(this, "isPaymentPossible exception catched", Toast.LENGTH_LONG).show()