init

@RequiresApi(value = 23)
suspend fun init(context: Context, posTerminalId: String, posForageConfig: PosForageConfig): 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>",
posForageConfig = PosForageConfig(
merchantId = "mid/123ab45c67",
sessionToken = "sandbox_ey123..."
)
)

// Use the forageTerminalSdk to call other methods
// (e.g. tokenizeCard, checkBalance, etc.)
} catch (e: Exception) {
// handle initialization error
}

Parameters

context

Required. The Android application context.

posTerminalId

Required. A string that uniquely identifies the POS Terminal used for a transaction. The max length of the string is 255 characters.

posForageConfig

Required. A PosForageConfig instance that specifies a merchantId and sessionToken.

Throws

If the initialization fails.