Skip to main content
Version: Live

PTError

The PTError class represents errors that may occur during SDK operations. It provides a standardized error format with an error code and description.

Properties​

PropertyTypeDescription
codeErrorCodeEnum indicating the type of error
errorStringHuman-readable description of the error

Error Codes​

CodeDescription
ActionCompleteThe requested action has already been completed
ActionInProgressAn action is currently in progress, preventing a new action
AttestationFailedThe device attestation process failed
InProgressThe operation is still in progress
InvalidAPIKeyThe provided API key is invalid or not recognized
InvalidParamAn invalid parameter was provided to the SDK
NoFieldsRequired fields were not provided for the operation
NotReadyThe SDK is not in a ready state for the requested operation
NotValidThe provided data failed validation checks
SocketErrorAn error occurred with the WebSocket connection
TokenFailedToken generation or validation failed

Example Usage​

class PaymentActivity : PayTheoryMerchantActivity(), Payable {
override fun handleError(error: PTError) {
when (error.code) {
ErrorCode.InvalidAPIKey -> {
// Handle invalid API key
showError("Invalid API Key: ${error.error}")
}
ErrorCode.NotValid -> {
// Handle validation error
showError("Validation Error: ${error.error}")
}
ErrorCode.SocketError -> {
// Handle connection error
showError("Connection Error: ${error.error}")
}
else -> {
// Handle other errors
showError("Error: ${error.error}")
}
}
}
}