androidstripe-payments

Is it neccessary to use locationId for connecting reader with Stripe Termial?


I am working with Stripe terimnal with wisepad 3 reader. The reader got discovered during discovery phase but it is not getting connected. We are not using Location for now.

It is written in the documentation that : https://docs.stripe.com/terminal/quickstart?reader=wp3

To connect to a reader, your backend needs to give the SDK permission to use the reader with your Stripe account by providing it with the secret from a ConnectionToken. Your backend should only create connection tokens for clients that it trusts. ​​If you’re using Stripe Connect, you should also scope the connection token to the relevant connected accounts. ​​If using locations, you should pass a location ID when creating the connection token to control access to readers.

From documentation it seems it is optional to use location. But in the configuration of connect code it is neccessary to provide location id. I would like to know is it possible to connect reader with out using location id.

My current code for connect is :

private fun connectToReader(reader: Reader, result: MethodChannel.Result) {

    val bluetoothReaderListener = TerminalBluetoothReaderListener()

    val connectionConfig = ConnectionConfiguration.BluetoothConnectionConfiguration(
        locationId = "", 
        autoReconnectOnUnexpectedDisconnect = true,
        bluetoothReaderListener = bluetoothReaderListener
    )

    Terminal.getInstance().connectReader(reader, connectionConfig, object : ReaderCallback {
        override fun onSuccess(connectedReader: Reader) {
            Log.d("StripeTerminal", "Reader connected: ${connectedReader.serialNumber}")
            notifyFlutterReaderConnection(true)
            result.success("Reader connected successfully: ${connectedReader.serialNumber}")
        }

        override fun onFailure(e: TerminalException) {
            Log.e("StripeTerminal", "Error connecting to reader: ${e.message}")
            notifyFlutterReaderConnection(false)
            result.error("CONNECT_ERROR", "Error connecting to reader: ${e.message}", null)
        }
    })
}

Solution

  • Yes, location id is necessary. First you have to add location in your stripe account terminal dashboard. Then if the endpoint for getting location id is not implemented on your backend then your team have to implement it. https://docs.stripe.com/api/terminal/locations/retrieve After that you can get location id from your backend on frontend side by calling your backend api.

    And depending on which type of reader you are using you can register your reader by following this:

    https://docs.stripe.com/terminal/fleet/register-readers?terminal-sdk-platform=android