Interface for Pay API.
Nested Class Summary
enum | PayClient.ProductName | Indicates what the product is called in this market | |
@interface | PayClient.RequestType | All possible request types that will be used by
callers of
PayClient.getPayApiAvailabilityStatus(int) . |
|
@interface | PayClient.SavePassesResult | Possible result codes passed back in
onActivityResult() when calling
PayClient.savePasses(String, Activity, int) or
PayClient.savePassesJwt(String, Activity, int) . |
|
@interface | PayClient.WearWalletIntentSource | Intent source for Wear Card Management Activity. |
Constant Summary
String | EXTRA_API_ERROR_MESSAGE | Debug message passed back in
onActivityResult() when calling
savePasses(String, Activity, int) or
savePassesJwt(String, Activity, int) . |
Public Method Summary
abstract Task<EmoneyReadiness> |
checkReadinessForEmoney(String
serviceProvider, String accountName)
Checks the e-money readiness for a service provider and account.
|
abstract Task<Integer> |
getPayApiAvailabilityStatus(int requestType)
Gets the
PayApiAvailabilityStatus
of the current user and device.
|
abstract Task<PendingIntent> |
getPendingIntentForWalletOnWear(String wearNodeId,
int intentSource)
Create a
PendingIntent
for the Wear Wallet activity.
|
abstract PayClient.ProductName |
getProductName()
Provides the product name in this market.
|
abstract Task<Void> | |
abstract Task<Void> |
notifyEmoneyCardStatusUpdate(String json)
Notifies Google Play services if an e-money card has been updated.
|
abstract Task<Void> |
pushEmoneyCard(String json,
ActivityResultLauncher<IntentSenderRequest> activityResultLauncher)
Saves an e-money card in JSON format.
|
abstract void |
savePasses(String json,
Activity
activity, int requestCode)
Saves one or multiple passes in a JSON format.
|
abstract void |
savePassesJwt(String jwt,
Activity
activity, int requestCode)
Saves one or multiple passes in a JWT format.
|
Constants
public static final String EXTRA_API_ERROR_MESSAGE
Debug message passed back in onActivityResult()
when calling
savePasses(String, Activity, int)
or
savePassesJwt(String, Activity, int)
.
public void onActivityResult(int requestCode, int resultCode, Intent data) {
...
if (resultCode == PayClient.SavePassesResult.SAVE_ERROR && data != null) {
String errorMessage = data.getStringExtra(PayClient.EXTRA_API_ERROR_MESSAGE);
...
}
...
}
Public Methods
public abstract Task<EmoneyReadiness> checkReadinessForEmoney (String serviceProvider, String accountName)
Checks the e-money readiness for a service provider and account.
Important: Only apps on the allowlist for the e-money feature can call this method;
otherwise, the result is a failed Task
.
Parameters
serviceProvider | The service provider to check readiness. |
---|---|
accountName | The email account to check readiness. |
Returns
- One of the possible
EmoneyReadinessStatus
.
public abstract Task<Integer> getPayApiAvailabilityStatus (int requestType)
Gets the PayApiAvailabilityStatus
of the current user and device.
Parameters
requestType | A PayClient.RequestType
for how the API will be used. |
---|
Returns
- One of the possible
PayApiAvailabilityStatus
.
public abstract Task<PendingIntent> getPendingIntentForWalletOnWear (String wearNodeId, int intentSource)
Create a PendingIntent
for the Wear Wallet activity. May return an error if pay is not supported in this
region or if the watch is not reachable.
Parameters
wearNodeId | The node id of the watch. |
---|---|
intentSource | The
PayClient.WearWalletIntentSource that launches the requested page. |
public abstract PayClient.ProductName getProductName ()
Provides the product name in this market.
public abstract Task<Void> notifyCardTapEvent (String eventJson)
Notifies Google Play services of a card tap event.
Only apps on the allowlist can call this method; otherwise, the result is a failed
Task
.
Parameters
eventJson | The event details in JSON format. |
---|
public abstract Task<Void> notifyEmoneyCardStatusUpdate (String json)
Notifies Google Play services if an e-money card has been updated.
Important: Only apps on the allowlist for the e-money feature can call this method;
otherwise, the result is a failed Task
.
Parameters
json | The e-money card status update details in JSON format. |
---|
public abstract Task<Void> pushEmoneyCard (String json, ActivityResultLauncher<IntentSenderRequest> activityResultLauncher)
Saves an e-money card in JSON format.
Important: Only apps on the allowlist for the e-money feature can call this method;
otherwise, the result is a failed Task
.
Here's an example of preparing the ActivityResultLauncher
to push an e-money card:
// Creates the activity result launcher
private ActivityResultLauncher<IntentSenderRequest> pushEmoneyCardLauncher =
registerForActivityResult(
new StartIntentSenderForResult(),
result -> {
if (result.getResultCode() == RESULT_OK) {
// Show success screen.
} else {
// Show error.
}
});
// Invokes the API and maybe handles the task failure
payClient.pushEmoneyCard(json, pushEmoneyCardLauncher)
.addOnFailureListener(e -> {});
Parameters
json | The e-money card details in JSON format. |
---|---|
activityResultLauncher | an ActivityResultLauncher
registered by caller to handle the activity results. |
public abstract void savePasses (String json, Activity activity, int requestCode)
Saves one or multiple passes in a JSON format.
Must be called from an Activity
.
Parameters
json | A JSON string request to save one or multiple passes. The JSON format is consistent with the JWT save link format. Refer to Google Pay API for Passes for an overview on how save links are generated. Only focus on how the JSON is formatted. There is no need to sign the JSON string. |
---|---|
activity | The Activity that will receive the callback result. |
requestCode | An integer request code that will be passed back in
onActivityResult() , allowing you to identify whom this result came
from. |
public abstract void savePassesJwt (String jwt, Activity activity, int requestCode)
Saves one or multiple passes in a JWT format.
Must be called from an Activity
.
Parameters
jwt | A JWT string token to save one or multiple passes. The token format is the same used in the JWT save link format. Refer to Google Pay API for Passes for an overview on how save links are generated. |
---|---|
activity | The Activity that will receive the callback result. |
requestCode | An integer request code that will be passed back in
onActivityResult() , allowing you to identify whom this result came
from. |