EdfaPay Logo

Error Handling

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

Overview

The EdfaPay SDK uses a sealed class hierarchy (EdfaError) and typed exception (EdfaException) to provide structured, actionable error information.

EdfaException

Typed exception thrown in catch blocks

EdfaError

Sealed class hierarchy for structured errors

Response Codes

Server response codes for transaction results

Custom Errors

Plugin-level error categories

EdfaException

The SDK throws EdfaException for SDK-specific errors. It wraps an EdfaError with a typed error category and optional cause.

PropertyTypeDescription
errorEdfaErrorThe typed error object with code and message
messageString?Human-readable error description
causeThrowable?Underlying cause, if available

EdfaError Hierarchy

The modern, type-safe error hierarchy used by the SDK. Each subtype carries a numeric code in a specific range.

EdfaError SubtypeCode RangeCategory
EdfaError.InitializationError1xxxSDK setup and auth failures
EdfaError.NetworkError2xxxConnectivity and server communication issues
EdfaError.CardError3xxxCard reading and NFC issues
EdfaError.KernelError4xxxEMV kernel processing failures
EdfaError.TerminalError5xxxTerminal configuration and binding problems
EdfaError.TransactionError6xxxTransaction processing failures
EdfaError.AuthenticationError7xxxAuth token or credential issues
EdfaError.ValidationError8xxxInput/parameter validation failures
EdfaError.SecurityError9xxxSecurity policy violations

Error Handling Pattern

Use when-expression (Kotlin) or instanceof (Java) to handle each error category precisely.

Loading...

Debug Logging

Enable debug logging during development: EdfaPayPlugin.enableLogs(true)

Transaction Response Handling

Handle different transaction outcomes using the TxnResponse callback.

Loading...

Common Errors

Frequently encountered error codes with causes and resolution guidance.

CodeCategoryMeaningResolution
1001InitializationInvalid auth credentialsCheck your authToken or email/password
1002InitializationSDK not initializedCall EdfaPayPlugin.initiate() first
1003InitializationNo terminal boundComplete terminal binding in onTerminalBindingTask
2001NetworkNetwork connection timeoutCheck device internet/network connection
2002NetworkServer unreachableVerify API endpoint and network access
3001CardCard read timeoutAsk user to tap card again within timeout window
3002CardUnsupported card typeOnly NFC-capable payment cards supported
3003CardCard communication errorClean card/device NFC area and retry
4001KernelEMV processing failureSync terminal to update EMV parameters
5001TerminalTerminal not activatedCall activateTerminal() first
5002TerminalTerminal binding requiredSelect terminal in onTerminalBindingTask callback
6001TransactionTransaction declinedCard declined by issuer — do not retry
6002TransactionInsufficient fundsCustomer should use different card
6003TransactionTransaction already reversedCannot reverse same transaction twice
7001AuthenticationSession expiredCall initiate() again to create new session
9001SecurityLocation validation failedEnable real device location, disable mock locations
9002SecurityCertificate pinning failureCheck certificate validity and network proxy