stripe / stripe-terminal-android

Stripe Terminal Android SDK
https://stripe.dev/stripe-terminal-android/
Other
84 stars 44 forks source link

Unexpected Reader Disconnect - Visibility #328

Closed alejoecoffee closed 3 months ago

alejoecoffee commented 1 year ago

Summary

When the card reader is disconnected and the Unexpected Reader Disconnect listener is called, there is no way to determine the reason for that disconnection, for example you don't know if it is an error or simply the user decided to turn off the reader with the power button, or The USB cable just got disconnected.

Code to reproduce

Here we cannot determine the reason, if it was an SDK error or simply the user decided to turn off the reader, this is very important to be able to provide support and have visibility of the reader's performance override fun onUnexpectedReaderDisconnect(reader: Reader) { logStatus("Unexpected Reader Disconnect", hasError = true) }

Android version

Android 12+

Impacted devices (Android devices or readers)

SDK version

2.20.1

Other information

Having this information will help a lot to determine the reason for these unexpected disconnections since stripe does not provide customer service for these types of problems.

Is there a way to determine or some listeners to determine user actions such as turning off the reader, disconnecting it from its USB cable?

Regards. Joe Coffee Team.

justinadkins commented 1 year ago

Unexpected Reader Disconnect also surfaces when there is a daily PCI compliance reader reboot. I'd love to see a reason surfaced as well.

chr-stripe commented 1 year ago

When it comes to unexpected disconnects, we do not know the reason most of the time. For example, a reader being powered down, a USB cable being removed (for USB-based connections), or a Bluetooth device going out of range (for Bluetooth-based connections), are all currently indistinguishable from one another by the SDK. As an aside, I'd recommend enabling auto-reconnections from the SDK for USB or Bluetooth connections to limit the amount of work needed on your part.

As for unexpected disconnects as a result of the daily PCI compliance reader reboot, we may be able to do something here. We'll look into this.

chr-stripe commented 3 months ago

In version 3.3.0 we added a new onDisconnect() callback for our Bluetooth/USB readers that will be invoked whenever the reader is disconnected, whether it was explicitly requested or unexpected.

There are a few DisconnectReasons that are currently supported. Turning the reader off and the daily PCI compliance reader reboot are both recognized use cases right now, among a few others. Removing the USB cable is not a recognized disconnect reason, however it will still invoke the disconnect callback with an UNKNOWN disconnect reason.