EdfaPay Logo

Error Handling

Learn how to properly handle errors and exceptions from the SDK to provide a smooth user experience.

Overview

The SDK uses a combination of exception classes and callback parameters to communicate errors. Understanding these patterns helps you build robust error handling.

EdfaException

SDK-specific errors with error codes

onError Callback

General error callback for all operations

Response Codes

Transaction-specific response codes

Timeout Callbacks

Specific callbacks for timeout scenarios

EdfaException

The SDK throws EdfaException for SDK-specific errors:

Loading...

EdfaError Hierarchy

The modern, type-safe error hierarchy used by the SDK. It uses a Kotlin sealed class structure organized by category, making it easier to parse specific errors exhaustively.

Initialization (1xxx)

Error TypeCodeDescription
Initialization.PluginNotInitialized1001Plugin not initialized properly
Initialization.SdkNotInitialized1002SDK not initialized
Initialization.SessionFailed1003Session creation failed
Initialization.ConfigurationMissing1004Terminal configuration missing
Initialization.ConfigurationInitFailed1005Configuration init failed
Initialization.UnsupportedSdkVersion1006Unsupported SDK version on device

Network (2xxx)

Error TypeCodeDescription
Network.Timeout2001HTTP request timeout
Network.ServerUrlInvalid2002Invalid server URL
Network.EnvironmentUndefined2003Environment not defined
Network.NonceFailure2004Nonce generation failed
Network.ServerKeyFailure2005Server key error
Network.TransactionProcessingFailure2006Transaction processing failed
Network.NullResponse2007Null response from server
Network.GeneralServerError2008General server error

Card (3xxx)

Error TypeCodeDescription
Card.NotSupported3001Card scheme not supported
Card.InvalidOrNotSupported3002Invalid or unsupported card
Card.DisconnectedWhileProcessing3003Card disconnected during processing
Card.AppletNotSelected3004Applet not selected
Card.TlvDecodingError3005TLV decoding error
Card.TlvDecodedNull3006TLV decoded to null
Card.ProcessingAidError3007AID processing error
Card.NoNfcTransceiver3008No NFC transceiver

Kernel (4xxx)

Error TypeCodeDescription
Kernel.NotImplemented4001Kernel not implemented
Kernel.VisaNotInitialized4002Visa kernel not initialized
Kernel.MastercardNotInitialized4003Mastercard kernel not initialized
Kernel.AmexNotInitialized4004Amex kernel not initialized
Kernel.DiscoverNotInitialized4005Discover kernel not initialized
Kernel.AlcineoNotInitialized4006Alcineo kernel not initialized

Terminal (5xxx)

Error TypeCodeDescription
Terminal.PreparationFailed5001Terminal preparation failed
Terminal.RegistrationFailed5002Terminal registration failed
Terminal.TsnNotFound5003TSN not found
Terminal.CounterFailed5004Transaction counter failed
Terminal.InvalidMerchantId5005Invalid merchant ID in auth code

Transaction (6xxx)

Error TypeCodeDescription
Transaction.InvalidParams6001Invalid transaction params
Transaction.MissingProcessingCode6002Missing processing code
Transaction.MissingLastApproved6003Missing last approved transaction
Transaction.NotLastTransaction6004Not the last transaction
Transaction.NotExistToReverse6005Transaction doesn't exist to reverse
Transaction.MissingIdOrRrn6006Missing transaction ID or RRN
Transaction.MissingData6007Missing transaction data

Authentication & Validation

Error TypeCodeDescription
Authentication.Failed7001Authentication failed
Authentication.LocationNotGranted7002Location permission not granted
Validation.PinLengthInvalid8001Invalid PIN length configuration
Validation.EnvValueUpdateFailed8002Environment value update failed

Security & Generic

Error TypeCodeDescription
Security.EncryptionFailed9001Encryption failed
Generic.SomethingWentWrong1Generic error
Generic.NullDataOnSuccess2Null data on success callback
Generic.Custom-1Custom error with message

Creating Custom Errors

You can easily map native throwables into custom EdfaErrors or vice-versa.

Loading...

Error Handling Pattern

Implement comprehensive error handling using type checking:

Loading...

Transaction Response Handling

Handle different transaction outcomes:

Loading...

Common Errors

ErrorCauseResolution
SESSION_EXPIREDAuthentication token expiredRe-initialize SDK with fresh credentials
INVALID_CREDENTIALSWrong auth token or credentialsVerify credentials and retry
TERMINAL_NOT_ACTIVETerminal not activatedCall activateTerminal()
NFC_NOT_AVAILABLEDevice lacks NFC or disabledPrompt user to enable NFC
LOCATION_REQUIREDLocation permission deniedRequest location permission
NETWORK_ERRORNo internet connectionCheck connectivity and retry
CARD_READ_ERRORFailed to read cardAsk user to retry tap
TRANSACTION_DECLINEDIssuer declined transactionShow decline reason to user

Debug Logging

Enable debug logging during development to see detailed error information:

EdfaPayPlugin.enableLogs = true

Filter logcat with tag: ***EdfaPay***