init
suspend fun init(context: Context, posTerminalId: String, forageConfig: ForageConfig): ForageTerminalSDK
A method that initializes the ForageTerminalSDK.
You must call init ahead of calling any other methods on a ForageTerminalSDK instance.
Forage may perform some long running initialization operations in certain circumstances. The operations typically last less than 10 seconds and only occur infrequently.
⚠️The ForageTerminalSDK.init method is only available in the private distribution of the Forage Terminal SDK.
// Example: Initialize the Forage Terminal SDK
try {
val forageTerminalSdk = ForageTerminalSDK.init(
context = androidContext,
posTerminalId = "<id-that-uniquely-identifies-the-pos-terminal>",
forageConfig = ForageConfig(
merchantId = "123ab45c67",
sessionToken = "sandbox_ey123..."
)
)
// Use the forageTerminalSdk to call other methods
// (e.g. tokenizeCard, checkBalance, etc.)
} catch (e: Exception) {
// handle initialization error
}
Content copied to clipboard
Parameters
context
Required. The Android application context.
pos Terminal Id
Required. A string that uniquely identifies the POS Terminal used for a transaction. The max length of the string is 255 characters.
Forage Config
Required. A ForageConfig instance that specifies a merchantId
and sessionToken
.
Throws
If the initialization fails.