Utility Functions
The EdfaPayPlugin.Utils namespace provides helper methods for device identification, location services, and UI dialogs. These utilities support compliance, fraud prevention, and a polished integration experience.
Overview
Device ID
Stable unique identifier across app reinstalls
Location Services
Permission management, coordinate access, and mock detection
Message Dialog
SDK-styled alert dialogs for consistent user feedback
Data Storage
Securely store and retrieve key-value data
API Reference
Loading...Device Identification
Returns a stable, unique device identifier that persists across app reinstalls. Optionally scoped by merchant ID to support multi-merchant deployments on the same device.
| Method | Parameter | Description |
|---|---|---|
| getDeviceId(context) | Context | Returns a stable device ID |
| getDeviceId(context, merchantId) | Context, Long? | Merchant-scoped device ID |
Loading...Location Services
Location is required for compliance during transactions. The SDK provides a full set of helpers to manage permissions, retrieve coordinates, and detect fraudulent mocked locations.
Required for Transactions
Location permission must be granted before calling EdfaPayPlugin.initiate(). The SDK will prompt for permission internally, but pre-requesting it provides a better user experience.
| Method | Returns | Description |
|---|---|---|
| haveLocationPermission(context) | Boolean | true if ACCESS_FINE_LOCATION is granted |
| requestLocationPermission(activity, callback) | Unit | Launches permission dialog, result via callback |
| currentLocation(context, completion) | Unit | Returns (Location?, hasPermission) async |
| isLocationMocked(location) | Boolean | true if location appears faked (fraud guard) |
Permission Check & Request
Loading...Get Location & Detect Mocked GPS
Loading...Mock Location Detection
isLocationMocked() checks if the device is using a fake GPS app. This is used for fraud prevention — block transactions when mocked locations are detected to prevent replay attacks and location spoofing.
Message Dialog
Display SDK-themed alert dialogs that match the look and feel of the payment UI. Useful for showing success/error messages in a style consistent with the SDK.
| Parameter | Type | Description |
|---|---|---|
| activity | FragmentActivity | The host activity |
| title | String | Dialog title text |
| message | String | Dialog body text |
| onClose | (() -> Unit)? | Optional callback when user dismisses |
Loading...Data Storage
Securely store and retrieve simple key-value pairs without managing your own Shared Preferences or secure storage instance.
| Method | Description |
|---|---|
| saveData(key, value) | Save a string value securely |
| getData(key) | Retrieve a saved string value (returns null if not found) |
Loading...Complete Example
A production-ready flow combining permission checks, location validation, fraud detection, and SDK dialogs — all using EdfaPayPlugin.Utils.
Loading...Best Practice
Always validate location before initiating a transaction in high-risk environments. Mocked location detection provides an additional fraud prevention layer beyond standard NFC card validation.
On this page
Downloads
Coming SoonSample apps, release bundles, and more content will be available here soon.