Register the terminal
ensureRegistered() is the recommended entry point. It registers only when needed and never reuses a challenge.
ensureRegistered() is the recommended entry point. It is a suspend function that:
- returns
trueimmediately if the terminal is already registered (no network call); - otherwise invokes your
challengeProviderto fetch a fresh challenge, then registers the terminal; - returns
falseif the challenge provider yieldsnull(for example, your backend was unreachable), so you can show a retry.
val registered = BlincPosSdk.ensureRegistered(
context = context,
terminalId = "T0001",
merchantId = "00000001"
paymentFacilitatorID = 1L,
environment = Environment.TEST // Environment.LIVE for prod
challengeProvider = {
// Your own backend call. Return the challenge string, or null on failure.
YourBackendApiClient.fetchChallenge()
}
)
if (registered) {
BlincPosSdk.startTransactionWithNFC(context = context, amount = 199900L)
} else {
// Could not register. Surface an error and let the user retry.
}| Parameter | Type | Description |
|---|---|---|
context | Context | Application or Activity context |
terminalId | String | Your unique terminal identifier |
merchantId | String | Your unique merchant identifier |
paymentFacilitatorID | Long | Provided by Blinc. Never changes. |
environment | Enum | Environment.TEST, Environment.LIVE |
challengeProvider | suspend () -> String? | Supplies a fresh challenge. Return null on failure. Invoked only when registration is missing. |
Returns: Boolean. true when the terminal is registered and ready, false when the challenge provider returned null.
The challengeProvider is your codeThe SDK never talks to your backend directly. It only decides when a challenge is needed and asks you for one. This keeps your backend integration entirely under your control.
Advanced: manual initialize
ensureRegistered() is built on top of two lower-level calls: isInitialized() and initialize(). Use them only if you have a reason to drive the registration flow yourself.
if (!BlincPosSdk.isInitialized(context)) {
val challenge = yourBackend.fetchChallenge() // off the main thread
?: return showError("Could not reach server")
BlincPosSdk.initialize(
context = context,
terminalId = "T0001",
merchantId = "00000001"
paymentFacilitatorID = 1L,
environment = Environment.TEST // Environment.LIVE for prod
challenge = challenge
)
}
BlincPosSdk.startTransactionWithNFC(context = context, amount = 199900L)Updated 1 day ago
Did this page help you?