stripe-terminal-android icon indicating copy to clipboard operation
stripe-terminal-android copied to clipboard

[BUG] Collect Payment Method failed with "NFC is disabled" after turned off then turned on device's screen on Sunmi Device

Open dwiyasko opened this issue 1 year ago • 5 comments

Summary

Using Tap to Pay Android feature deps:

  • com.stripe:stripeterminal:2.20.0
  • com.stripe:stripeterminal-localmobile:2.20.0

When the device's screen is turned off without leaving the app and then turned on, sometimes get failed when collectPaymentMethod with the message "NFC is disabled", even I check NFC adapter right after the device is turned on its returns true or enabled.

Code to reproduce

When the device screen is turned off by pressing the power button without leaving the app, network Listener is triggered with Unknown state. Then, when turned on the screen again, will trigger network listener with Online state.

So, I check NFC adapter right after, and it says NFC is enabled.

if (viewModel.networkStatus == Unknown && status == Online) {
            val enabled = isNFCEnabled() // this will resulting true (enabled)
}

But when starts payment and reaches collectPaymentMethod(), will fail with NFC is disabled error message and errorCode: error_code_reader_error_local_mobile_nfc_disabled

paymentCancelable = Terminal.getInstance()
            .collectPaymentMethod(originIntent, object : PaymentIntentCallback {
                override fun onFailure(e: TerminalException) {
                    // Sometime will goes here with NFC is disabled
                }

                override fun onSuccess(paymentIntent: PaymentIntent) {
                    // expected to go here, because NFC is enabled
                }
            }, collectConfig)

This issue is intermittent but happens quite often, 6 occurrences out of 20 are quite big. Happen on Sunmi v2s Pro device Android 11, not sure about other devices.

dwiyasko avatar May 24 '23 04:05 dwiyasko

@dwiyasko Do you see this issue this frequently on all Sunmi v2s devices, or is it particularly bad on this one device?

maggiewhite-stripe avatar May 26 '23 21:05 maggiewhite-stripe

@maggiewhite-stripe it's frequently happened on all Sunmi v2s devices.

dwiyasko avatar May 31 '23 04:05 dwiyasko

@dwiyasko Sorry for the delay in my update. I'm having trouble reproducing this issue on my Sunmi V2s.

  1. What are you using to determine if NFC is enabled in your isNFCEnabled() function?
  2. How long does the screen have to be turned off to reproduce this issue?
  3. Does this issue reproduce if the device is plugged in or charging?
  4. Did you see this issue on older versions of the SDK, or is it new with 2.20.0?

maggiewhite-stripe avatar Jun 21 '23 01:06 maggiewhite-stripe

Hi @maggiewhite-stripe Sorry for the delay, we are facing another issue related to Wisepad BT reader.

Regarding your question:

  1. It's just a simple check using Android SDK to check whether NFC is enabled or not.
private fun isNFCAvailable(): Boolean {
        val adapter = (getSystemService(NFC_SERVICE) as NfcManager).defaultAdapter
        return adapter != null
    }
  1. There is no exact time, sometimes within a minute or longer.
  2. No, this issue will not be reproducible when the device is charging or USB is plugged in, so we will not facing such issue by debugging with a cable. To verify this issue, we put a log to our server to see the errorMessage. Then we see error_code_reader_error_local_mobile_nfc_disabled
  3. Never try the older version before, should we check?

For now, we solve the issue with a 1-second retry mechanism, the pattern is, the first try of collection will say NFC disabled, then the next try will work as expected.

Any insight would be very helpful.

dwiyasko avatar Jul 10 '23 15:07 dwiyasko

Hi @dwiyasko -- I realize that we haven't responded to this issue for quite some time (sorry!), but can you upgrade to the latest version and check if it's still an issue? We've been actively developing TTP, so it would be helpful if we could get clear reproducible steps on the latest version of the SDK (3.5.0).

billfinn-stripe avatar Apr 10 '24 00:04 billfinn-stripe