TaskResultContracts.GetPaymentData

public static final class TaskResultContracts.GetPaymentData extends UnpackApiTaskResult<PaymentData>

A simple contract that returns a PaymentData object.

This contract resolves a Task created by the Google Pay API that returns a PaymentData object or null if there is an error.

Below is an example that uses this contract to return a PaymentData result from a completed Task object created by the PaymentsClient.loadPaymentData(PaymentDataRequest) method:

// Use the contract to create an activity result launcher
 val paymentDataLauncher = registerForActivityResult(GetPaymentData()) {
   // Do something with the result (it: PaymentData?)
 }

 // Start the task operation and associate it with the activity launcher
 val paymentDataTask: Task<PaymentData> = paymentsClient.loadPaymentData(request)
 paymentDataTask.addOnCompleteListener(context, paymentDataLauncher::launch)
 

Public Constructor Summary

Public Method Summary

PaymentData
parseResult(int resultCode, Intent intent)

Inherited Method Summary

Public Constructors

public GetPaymentData ()

Public Methods

public PaymentData parseResult (int resultCode, Intent intent)