Utility Functions
EdfaPayPlugin.Utils provides helper functions for device identification, location services, secure storage, and UI dialogs. EdfaPayPlugin.Extension provides advanced low-level API access.
Overview
The EdfaPayPlugin.Utils namespace provides helper methods for device identification, location services, secure storage, and UI dialogs. In Java, use EdfaPayPluginJ.getUtils() and EdfaPayPluginJ.getExtension().
Device ID
Get unique device identifier for fraud detection and compliance
Location Services
Check and request location permissions; detect GPS mocking
Message Dialog
Show native alert dialogs from the SDK context
Data Storage
Secure key-value storage for SDK data
Device Identification
Get a device identifier. It stays the same across reinstalls of an app signed with the same key, and changes after a factory reset. Optionally scope the ID to a specific merchant.
Loading...Location Services
Check and request location permissions, retrieve the current device location, and detect GPS mocking. requestLocationPermission and currentLocation report their result in a callback. In Flutter and React Native, check the result of a request with haveLocationPermission().
Loading...Location Required
Payments need location permission (ACCESS_FINE_LOCATION). Without it, a payment ends in onError with "Location permission required to pay". Request the permission before the first payment.
Message Dialog
Display a native alert dialog using the SDK's context. Useful for showing payment results or error messages to the user. In Kotlin and Java, onClose is an optional callback that runs when the user closes the dialog.
Loading...Data Storage
Keep string values in the SDK's data store for the current session. Call these after initiate() has succeeded. In Kotlin and Java the key is an androidx DataStore key, for example stringPreferencesKey("my_key"); in Flutter and React Native it is a string.
| Method | Description |
|---|---|
| saveData(key: Preferences.Key<String>, value: String, onSuccess: (Boolean) -> Unit, onError) | Stores the value; onSuccess receives true when it was written |
| getData(key: Preferences.Key<String>, onError): String? | Returns the stored value, or null if there is none |
Device ReadinessNew in v1.0.7
Helpers for making background reconciliation reliable: check and request notification permission (Android 13+), exact-alarm permission (Android 12+), unrestricted battery usage, and OEM autostart allowlisting. Each area has a have/can check, an open-settings helper, and a request method. For the exact-alarm, battery and autostart requests, callback(true) means already granted or not needed on this device; false means the user declined or was sent to the settings screen, so check again with the matching can/is method when your activity resumes.
| Method | Description |
|---|---|
| haveNotificationPermission(context) | Returns true if POST_NOTIFICATIONS is granted (Android 13+) and notifications are enabled |
| requestNotificationPermission(activity, callback) | Requests notification permission; callback receives true if granted |
| canScheduleExactAlarms(context) | Returns true if the app can schedule exact alarms (always true below Android 12) |
| openExactAlarmSettings(context): Boolean / requestExactAlarmPermission(activity, callback) | Opens the exact-alarm settings screen / shows an explanation, then opens the settings if the user agrees |
| isBatteryUnrestricted(context) | Returns true if the app is exempt from battery optimizations (Doze) |
| openBatteryUnrestrictedSettings(context): Boolean / requestBatteryUnrestricted(activity, callback) | Opens the battery settings screen / shows an explanation, then opens the settings if the user agrees. On a build without REQUEST_IGNORE_BATTERY_OPTIMIZATIONS both open nothing (see Google Play Permissions) |
| deviceNeedsAutostart() | Returns true if this OEM requires an autostart allowlist entry |
| openAutostartSettings(context): Boolean / requestAutostartPermission(activity, callback) | Opens the OEM autostart screen / shows an explanation, then opens it if the user agrees (no-op on stock Android) |
Loading...Why These Matter
Scheduled (background) reconciliation depends on the OS letting the SDK wake up and notify. On aggressive OEMs (Xiaomi, Huawei, etc.) also request autostart; deviceNeedsAutostart() tells you whether the current device requires it — the autostart helpers are no-ops on stock Android.
Extension API (EdfaPayPlugin.Extension)
Low-level API for advanced integration. Access via EdfaPayPlugin.Extension (Java: EdfaPayPluginJ.getExtension()). Provides custom authentication, OTP, and terminal registration. Extension calls work after initiate() has succeeded, or after EdfaPayPlugin.Extension.init(activity, onError, onSuccess); otherwise onError receives "EdfaPayPlugin.Extension not initiated...". onError receives an EdfaException. loginWithToken needs the device location as a Location(lat, lng) from com.edfapay.paymentcard.model.responses.
Loading...Advanced Use Only
Extension API methods bypass standard initialization flow. Use only if instructed by EdfaPay technical support.
Online ReceiptsNew in v1.0.7
Generate a hosted online receipt URL for a transaction or reconciliation, or open it directly in the device browser. Available under EdfaPayPlugin.Extension, after initiate() has succeeded. The receipt kind is selected with the ReceiptType enum (TRANSACTION or RECONCILIATION; in Kotlin and Java it is PluginExtension.ReceiptType); pass the transaction id or reconciliation id accordingly. The URL arrives in onSuccess. In Kotlin and Java, openOnlineReceipt also takes a context.
Loading...Transaction & Init WebhooksNew in v1.0.8
Register HTTPS endpoints the SDK POSTs to after each transaction and after initialization. Build the config with the chainable Hook builder — call transaction(url, headers?) and/or initiate(url, headers?) — then pass it to EdfaPayPlugin.configureHook() together with an encryptor. It is safe to call before initiate(). On native Android, Hook is com.edfapay.paymentcard.utils.Hook (Java: Hook.INSTANCE, and pass the headers map in every call).
On docs.edfapay.com
EdfaPay's server can also post SoftPOS transactions to your back office: Webhook events, SoftPOS webhook payload. The SDK hook posts from the device; for back-office records, use the server webhook.
Loading...How delivery works
Delivery is background (WorkManager), internet-gated, with up to 5 attempts 1 minute apart. Each request is a POST with body {"data":"<payload>"}, your configured headers, plus auto X-Device-Id and X-Device-Time headers. The encryptor receives the base64 payload and returns what is sent as data (for example an encrypted form); to send the payload unchanged, return it as it is. On native Android the encryptor either returns the value ((String) -> String) or passes it to a callback ((payload, done) -> Unit). In Flutter and React Native, headers are shared by both endpoints.
On this page
Downloads
Coming SoonSample apps, release bundles, and more content will be available here soon.