Handle Errors
If you get a non-null APayError, then that means something went wrong during the operation. To handle the error, use the response from the ApayError API.
ApayError API
APayError aPayError = APayError.fromIntent(intent);
if (aPayError != null) {
// Get Error Type
APayError.ErrorType errorType = error.getErrorType();
}
Response Parameters
Parameter | Description |
---|---|
errorType | ErrorType |
errorCode | String |
message | String |
throwable | Throwable |
Possible Error Types
Apay Error Type | Description |
---|---|
AUTH_ERROR | Exception during the authorize phase (e.g., auth code generation failed due to invalid API key) |
BROWSING_EXPERIENCE | Exception while opening a browser or Custom Tab |
Possible Error Code
Apay Error Type | Description |
---|---|
START_BROWSING_ERROR | Exception during the start operation in browser or Custom Tab |
OPERATION_CANCELLED | User-initiated cancellation of an operation |
ExternalBrowserError | Exception while launching a URL in a browser |
CustomTabError | Exception while launching a URL in a Custom Tab |
CustomTabNoSuchMethodError | Compatibility issue: The current version of Chrome Custom Tabs used is incompatible with the SDK. Use version 25 or above. |
Sample Code to Handle Apay Errors
APayError aPayError = APayError.fromIntent(intent);
if (aPayError != null) {
// Get Error Type
APayError.ErrorType errorType = error.getErrorType();
if (errorType == APayError.ErrorType.AUTH_ERROR) {
//if the error type is auth error, get the underlaying auth exception
AuthError authError = aPayError.getAuthError();
// See the stacktrace associated with the authError (like you wouldn't other exception)
Log.e("tag","AUTH Error", authError);
}
}