Initializing the SDK
Initializing the SDK
Declare and initialize the SDK in your Activity or Fragment:
What Initialising an SDK Does
1
Loads Core Components
It sets up the SDK’s internal modules, such as communication protocols, transaction handlers, and device interfaces, so they’re ready for use.
2
Establishes Configuration
It applies configuration parameters like merchant credentials, environment settings (e.g. test vs production), terminal capabilities, and feature flags (e.g. tipping, cashback).
3
Registers Context
The SDK links itself to the app’s context (e.g. Android Context or iOS UIApplication) to access system resources, lifecycle events, and UI elements.
4
Prepares Communication Channels
It opens secure channels for interacting with payment gateways, card readers, or external APIs—essential for real-time transaction processing.
5
Validates Dependencies
It checks for required permissions, hardware availability (e.g. NFC, Bluetooth), and compatibility with the host app and OS version.
6
Enables Logging and Error Handling
It activates diagnostic tools for debugging, logging, and capturing runtime errors or transaction failures.
In short, SDK initialisation is the first step in enabling your client app to securely and reliably interact with card terminals and payment services
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class MainActivity : ComponentActivity() {
private lateinit var sdk: PaymentSdk
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialize SDK
sdk = PaymentSdk(this)
sdk.bindAidlRequestService(
onConnected = { Log.d("SDK", "Connected to payment service") },
onError = { Log.e("SDK", "Connection failed", it) }
)
}
override fun onDestroy() {
super.onDestroy()
sdk.release()
}
}