With the SDK initialized in your app, the next step is connecting your app to a reader.
Connecting is important. Readers have some basic functionality on their own, but the connection to the Stripe SDK in your app is what enables readers to accept payments for your business.
The way you handle the connection workflow in your app is also important. Users of your point of sale (e.g., your onsite employees or connected accounts) must be able to connect to a reader from your app easily. For example, if you ship two readers directly to a store location, your app’s UI should include options to discover readers nearby, select the one they want to use, and connect to it.
How connecting works
Connecting your app to the reader takes two steps: discovery and connection.
First, your app calls the
discoverReaders function and, depending on your reader type, searches for:
- readers over Bluetooth (BBPOS)
- readers registered to your Stripe account (Verifone P400)
It’s up to you to handle the returned list of readers in your application’s UI. Your in-store employees should be able to use your application to discover and select the correct reader easily (e.g., by its serial number or label).
After receiving user input, your app calls the
connectReader function with the selected reader. This establishes the reader-to-app communication necessary for taking in-person payments. If necessary,
connectReader also fetches a connection token to connect to Stripe and enable payment collection.
Stripe Terminal does not 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 localStorage API (web), the UserDefaults API (iOS), or the Shared Preferences API (Android).
- When your app launches, check that persistent store for a saved serial number. If one is found, call the
discoverReadersmethod 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 is not found, stop the discovery process.
Note that you might want to display some UI during the discovery and connection process indicating that an automatic reconnection is taking place.
To see a working example of the steps above, you can refer to the Rocket Rides Pilot App sample code on Github. The Rocket Rides Pilot App is a full sample iOS app that demonstrates a checkout flow with Stripe Terminal, and implements automatic reader reconnection using this method.
Connect your reader now
See the guide for your reader type to get connected.
Was this page helpful?