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 true immediately if the terminal is already registered (no network call);
  • otherwise invokes your challengeProvider to fetch a fresh challenge, then registers the terminal;
  • returns false if the challenge provider yields null (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.
}
ParameterTypeDescription
contextContextApplication or Activity context
terminalIdStringYour unique terminal identifier
merchantIdStringYour unique merchant identifier
paymentFacilitatorIDLongProvided by Blinc. Never changes.
environmentEnumEnvironment.TEST, Environment.LIVE
challengeProvidersuspend () -> 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 code

The 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)

initialize() stages a challenge in memory

Attestation runs on the next transaction. If you call initialize() yourself, you are responsible for only calling it when isInitialized() is false, and for never reusing a challenge. ensureRegistered() handles both correctly for you.


Did this page help you?