EdfaPay Logo

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

Example.kt
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.

MethodParameterDescription
getDeviceId(context)ContextReturns 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.

MethodReturnsDescription
haveLocationPermission(context)Booleantrue if ACCESS_FINE_LOCATION is granted
requestLocationPermission(activity, callback)UnitLaunches permission dialog, result via callback
currentLocation(context, completion)UnitReturns (Location?, hasPermission) async
isLocationMocked(location)Booleantrue 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.

ParameterTypeDescription
activityFragmentActivityThe host activity
titleStringDialog title text
messageStringDialog 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.

MethodDescription
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.