Connect to a reader
Connect your application to a Stripe Terminal reader.
Note
If you haven’t chosen a reader yet, compare the available Terminal readers and choose one that best suits your needs.
Tap to Pay on Android (TTPA) lets users accept in-person contactless payments with compatible NFC-equipped Android devices. TTPA requires the latest version of the Terminal Android SDK. TTPA includes support for Visa, Mastercard, and American Express contactless cards and NFC-based mobile wallets (Apple Pay, Google Pay, and Samsung Pay). TTPA is an extension to the Terminal Android SDK and enables payments directly in your Android app.
Follow these steps to connect your app to the Tap to Pay reader on a supported Android device:
- Discover readers using the SDK to confirm device compatibility.
- Connect to a reader using the SDK to accept payments.
- Handle unexpected disconnects to make sure your user can continue to accept payments if the reader disconnects unexpectedly.
If your application runs on a device that doesn’t meet the supported device criteria, the SDK returns a TerminalException
that provides additional context in an onFailure
callback.
Create a locationServer-sideDashboard
Create a Location for each physical location where your readers operate. Set the display_
to represent the name of the business. Your customer sees the display_
on the device’s tap screen unless you explicitly provide the name of a business when you connect to a reader. You can edit existing locations as necessary to adjust this text.
If your business requires you to move your readers frequently, your locations can use an address that represents your primary place of business.
To create a location using the API, use the create location request.
Locations for the US require:
line1
city
state
postal_
code country
To create a location in the Dashboard, click the +New button on the Locations page.
Discover readers
Use the discoverReaders
method to determine hardware support for Tap to Pay on the Android device. discoverReaders
verifies the following requirements:
- The device contains a functioning NFC antenna and chipset.
- The device has a hardware-backed keystore.
- The device runs a current version of Android (Android 11 or above).
- For the non-simulated version of the Tap to Pay reader, the application isn’t debuggable.
Your application must be in the foreground for the Tap to Pay reader service to successfully start.
If your application runs on a device that doesn’t meet the requirements above, the onFailure
callback returns with a TerminalException
that contains a TerminalErrorCode and additional context. The failures at this stage aren’t actionable by the end user.
Using the non-simulated, production version of the Tap to Pay reader with debuggable applications isn’t supported for security and compliance reasons. To test your integration with the Tap to Pay on Android reader, set DiscoveryConfiguration.
to true during reader discovery. You must set this value to false in the release version of your application.
To check if a device meets the Tap to Pay hardware and OS requirements at runtime, use the Terminal.supportsReadersOfType function. As part of initializing the Terminal SDK, this function requires your end user to accept permission requests to access the location and bluetooth. This function takes approximately 10ms to run on most devices.
Connect to a reader
To accept Tap to Pay payments, provide the discovered reader from the previous step to the connectLocalMobileReader
method.
connectLocalMobileReader
verifies the following requirements:
- The device has a stable connection to the internet.
- The device isn’t rooted and the device bootloader is locked and unchanged.
- The device uses Google Mobile Services.
- The device runs a current version of Android (Android 11 or above).
- The application uses a supported version of the Tap to Pay SDK (currently 2.20.0 or above).
If your application runs on a device that doesn’t meet the requirements above, the onFailure
callback returns with a TerminalException
that contains a TerminalErrorCode and additional context. The end user can take action on some of the failure reasons. For example:
STRIPE_
: The user can connect to a stable internet source.API_ CONNECTION_ ERROR LOCAL_
: The user can upgrade their operating system, if an update is available from the device manufacturer.MOBILE_ UNSUPPORTED_ ANDROID_ VERSION
Handle unexpected disconnects
Unexpected disconnects might occur between your app and the reader. For example, the Tap to Pay reader might unexpectedly disconnect because:
- Android OS terminates the Tap to Pay reader service due to memory constraints.
- The device loses internet connectivity.
There are two ways you can choose to handle this:
1. Handle the disconnect manually
To handle the disconnect, you must implement the TerminalListener.
callback. This allows your app to reconnect to the Tap to Pay reader and, when appropriate, notify the user of what went wrong and how they can enable access to Tap to Pay. End users can resolve certain errors, such as internet connectivity issues.
2. Automatically attempt reconnection
Set autoReconnectOnUnexpectedDisconnect
as true
on the LocalMobileConnectionConfiguration
and a ReaderReconnectionListener
listener for reconnection events in your app.
If you automatically attempt reconnection, the following occurs:
- When a disconnect occurs, the SDK automatically attempts to reconnect and notifies you through
onReaderReconnectStarted
. 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, Stripe notifies you through
onReaderReconnectSucceeded
. Make sure your app announces that the connection was restored and to continue normal operations. - If the SDK can’t reconnect to the reader, Stripe notifies you through
onReaderReconnectFailed
. Make sure your app announces that an unexpected disconnect occurred.
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.