EdfaPay Logo

Error Handling

Every EdfaPgSdk call returns a JsonObject / Map mirroring EdfaPay's gateway response. Learn the success and failure shapes, the recommended host pattern, the common exceptions, and the idempotency rules that keep you from double-charging.

Response Shape

All EdfaPgSdk.* calls return a JsonObject (Kotlin/Swift) or Map<String, dynamic> (Flutter) — JsonObject? / null for queries. The structure mirrors the gateway response; on failure the SDK builds a minimal error map when the gateway returns no data.

Loading...

Recommended Host Pattern

Wrap the call, branch on result, and handle the not-initialized exception by bootstrapping the SDK. Never treat a thrown error as a declined payment without checking the gateway first.

Loading...

Common Exceptions

The exceptions you're most likely to hit, their cause, and how to remediate.

ExceptionCauseRemediation
EdfaPgSdkIsNotInitializedExceptionCalling any SDK API before initialize / after process death.Re-call EdfaPgSdk.initialize(...) from Application.onCreate() / iOS init() / app startup.
IllegalStateException / PlatformException ("already initialized")Calling initialize twice.Use reinitialize(...) if you must rotate keys; guard the init site on Flutter hot-reload.
SerializationExceptionBackend returned an unexpected schema (custom gateway flags).Parse defensively — the response type is JsonObject / Map, not a fixed DTO.
IOException / HttpRequestTimeoutException / PlatformException (network)Network failure or backend timeout.Retry idempotent queries; never retry sale without consulting getTransactionByOrderId first.

Idempotency

sale, applePay, and recurring are not idempotent by default. Always pre-generate your orderId, and before retrying a timed-out sale call getTransactionByOrderId(orderId) to see if the gateway already booked the charge. Queries are safe to retry.

Avoid duplicate charges

A timeout does not mean the charge failed. Query by orderId before any retry of a payment-affecting call.