Registering an event handler for user gesture

Define a OnClickListener for your "Pay" button in order to trigger the creation of a PaymentDataRequest object. Use the resolveTask method of the AutoResolveHelper with the PaymentDataRequest in order to show the Google Pay Bottom Sheet.

The result will then be transmitted to your onActivityResult() method.

Excerpt from the sample code:

fun onPayClick(view: View) {
	progressBar.visibility = View.VISIBLE

	val paymentDataRequest = preparePaymentDataRequest()
	AutoResolveHelper.resolveTask(
		paymentsClient.loadPaymentData(paymentDataRequest), 
		this, 
		GooglePayManagement.GOOGLE_PAYMENT_CODE_RESULT
	)
}