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 supports 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:
- Initialize the SDK for TTPA.
- 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.
Initialize the SDK
TTPA operates in a dedicated process to make transactions more secure. In this process, a second instance of your Application
is created. To avoid any unexpected errors caused by running your code in this process, you can skip initialization in your Application
in this process by checking TapToPay.
.
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 TapToPayDiscoveryConfiguration.
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 10 milliseconds 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 connectReader
method.
connectReader
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 TAP_
: The user can upgrade their operating system, if an update is available from the device manufacturer.TO_ PAY_ UNSUPPORTED_ ANDROID_ VERSION
You must register your reader to a location upon connection. To do so, create and use a TapToPayConnectionConfiguration
with the locationId
set to the relevant location ID when connecting.
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 handle this:
Automatically attempt reconnection
Stripe automatically attempts reconnection by default when an unexpected disconnect occurs. Set up TapToPayReaderListener
for auto reconnect callbacks in your app.
When the SDK automatically attempts 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 both
onReaderReconnectFailed
andTapToPayReaderListener.
. Make sure your app announces that an unexpected disconnect occurred.onDisconnect
Handle the disconnect manually
To handle reader disconnects yourself, you can set autoReconnectOnUnexpectedDisconnect
as false
and implement the TapToPayReaderListener.
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.
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.