Connect to a reader
Note
If you haven’t chosen a reader yet, compare the available Terminal readers and choose one that best suits your needs.
Bluetooth-connected readers are Bluetooth LE devices. They collect payment details, but rely on a paired mobile device for communication with Stripe.
Follow these steps to connect your app to a Terminal reader using Bluetooth:
Caution
Don’t use mobile device settings to pair with your reader. Pairing the reader through device settings makes the reader unavailable to connect to your app.
Discover readersClient-side
First, turn on the reader. Then, from your app, search for nearby Bluetooth-connected readers using the discoverReaders method.
Bluetooth proximity * BBPOS Chipper 2X BT only
Bluetooth proximity filters search results to return the closest reader. When discovered, the reader flashes multicolored lights, allowing your user to identify the discovered reader among many other readers. After the SDK discovers a reader, it won’t switch to a closer reader unless you turn off the discovered reader.
Note that when using Bluetooth proximity, the SDK returns the reader to your app’s callback twice. The first time, your app receives a Reader
object populated with only the reader’s serial number. After a short delay, your app receives the same Reader
object populated with new information, such as the reader’s battery level.
We recommend displaying the discovered reader in your app’s UI, letting the user either confirm connection to the reader or cancel if they don’t want to connect to this reader.
Bluetooth scan
Bluetooth scan searches for all nearby readers and returns a list of discovered readers to your app. As the discovery process continues, the SDK continues to invoke the DiscoveryDelegate.didUpdateDiscoveredReaders
method with the latest list of nearby readers.
With the Bluetooth scan discovery method, you can set a timeout to scan for a set period of time, which you can use for managing battery life or triggering an error message if no devices are found.
In your mobile application, we recommend displaying an auto-updating list of discovered readers, with serial numbers or labels to help users identify their reader.
Connect to a readerClient-side
To connect to a discovered reader, call the connectBluetoothReader
method from your app. As soon as the SDK connects to the reader, the reader’s status light shines solid blue.
You must register your reader to a location upon connection. To do so, create and use a BluetoothConnectionConfiguration
with the locationId
set to the relevant location ID when connecting.
For your app to run in the background and remain connected to the reader, configure your app to include the required background mode.
Don’t program your app to call disconnectReader
to conserve power. The reader efficiently handles power management using its standby mode.
Handle unexpected disconnects
Unexpected disconnects can sometimes occur between your app and the reader. For example, the reader can disconnect from your app if it’s out of range or runs out of battery. You can simulate an unexpected disconnect while testing by powering off the reader.
You can handle disconnects in two ways:
1. Handle the disconnect immediately
For this option, your app must implement the didReportUnexpectedReaderDisconnect
callback to manually handle when a reader disconnects. This is the default behavior of the SDK.
In your implementation of this callback, display a UI to notify the user that the reader disconnected.
The reader can disconnect from your app if it goes out of range or runs out of battery. To simulate an unexpected disconnect while testing, power off the reader.
2. Automatically attempt reconnection
For this option, your app must set autoReconnectOnUnexpectedDisconnect
as true on the BluetoothConnectionConfiguration
and implement the callbacks found in the ReconnectionDelegate
. You must also pass a autoReconnectionDelegate
to your BluetoothConnectionConfiguration
.
If you automatically attempt reconnection, the following occurs:
- When a disconnect occurs, the SDK automatically attempts to reconnect and notifies you through
didStartReaderReconnect
. Make sure your app announces that the connection was lost and a reconnection is in progress.- You can use the
Cancelable
object to stop the reconnection attempt at any time.
- You can use the
- If the SDK successfully reconnects to the reader, you’re notified through
didSucceedReaderReconnect
. Make sure your app announces that the connection was restored and to continue normal operations. - If the SDK can’t reconnect to the reader, you’re notified through
didFailReaderReconnect
. Make sure your app announces that an unexpected disconnect occurred.
Automatic reconnection on application start
Stripe Terminal doesn’t automatically reconnect to a reader when your application starts. Instead, you can build a reconnection flow by storing reader IDs and attempting to connect to a known reader on startup.
- When you successfully connect to a reader, save its serial number in a persistent data storage location, such as the UserDefaults API (iOS).
- When your app launches, check the persistent data storage location for a saved serial number. If one is found, call the
discoverReaders
method so your application can try to find that reader again. - If the saved serial number matches any of the discovered readers, try connecting to that reader with the matching reader object returned from the call to
discoverReaders
. If the previously connected reader isn’t found, stop the discovery process.
Display some UI during the discovery and connection process to indicate that an automatic reconnection is happening.
Update reader softwareClient-side
You must support updating the Bluetooth reader from your application. The reader can’t update itself. These updates include regional configurations that keep you up to date with card network and issuer requirements, as well as potential security updates. Required updates start installing on connection to the reader and must complete before the reader can be used.
Note
Installing updates requires that the reader’s battery is charged to more than 50%.
Required updates
If there are immediately required updates for the reader, they will be installed when connecting to it. The connection process won’t complete until the required update has been installed.
When a required update starts installing, your application’s BluetoothReaderDelegate
will receive didStartInstallingRequiredUpdate
with a ReaderSoftwareUpdate
object containing the update details. This will include an estimate of total update duration, estimatedUpdateTime
.
Your application must notify users that an update is being installed, and display the progress in your UI so it’s clear why the connection process is taking longer than normal.
You can cancel required updates using the Cancelable
object. However, this will result in a failed connection to the reader. For incremental-only updates no Cancelable
is provided as these updates can not be canceled.
Optional updates
Optional updates can be deferred, but will become required updates if not installed by a certain date. Optional updates will be announced to your BluetoothReaderDelegate
at any time the reader is connected but not performing a transaction. If an optional update is available, your application’s BluetoothReaderDelegate
will receive the didReportAvailableUpdate
callback with the ReaderSoftwareUpdate
object containing the update details. This update is also stored on the reader object as reader.availableUpdate
, and is the update that will be installed when calling Terminal.installAvailableUpdate
. The update object includes an estimate of update duration (estimatedUpdateTime
) and the future date at which the update must be installed (requiredAt
).
In your application, notify users that an update is available, and display a prompt to optionally continue with the update.
To proceed with the update, call installAvailableUpdate
, which will install the update previously reported via didReportAvailableUpdate
.
As the update proceeds, block the user from leaving the page in your app, and instruct the user to keep the reader in range and powered on until the update is complete. We recommend also providing your user with a visual indicator of the update’s progress. The BluetoothReaderDelegate
reports the updates progress via the didReportReaderSoftwareUpdateProgress
method.
When an optional update’s requiredAt
date has passed, the update won’t be installed until the reader is disconnected and reconnected.
See Testing Bluetooth reader updates to learn more about making sure your application handles the different update types that a reader can have.
Next steps
You’ve connected your application to the reader. Next, collect your first Stripe Terminal payment.
The BBPOS and Chipper™ name and logo are trademarks or registered trademarks of BBPOS Limited in the United States and/or other countries. The Verifone® name and logo are either trademarks or registered trademarks of Verifone in the United States and/or other countries. Use of the trademarks does not imply any endorsement by BBPOS or Verifone.