Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tap to Pay: Failed to generate key pair #553

Open
Quadriy opened this issue Feb 14, 2025 · 2 comments
Open

Tap to Pay: Failed to generate key pair #553

Quadriy opened this issue Feb 14, 2025 · 2 comments

Comments

@Quadriy
Copy link

Quadriy commented Feb 14, 2025

Summary

Hello,

We recently implemented the Tap-to-pay functionality on our app and have received reports from some clients that they cannot connect to the tap-to-pay reader.

Code to reproduce

Check if tap-to-pay is supported before attempting to discover a tap-to-pay reader (This returns true on the devices experiencing this issue).

Terminal.getInstance().supportsReadersOfType(
    deviceType = DeviceType.TAP_TO_PAY_DEVICE,
    discoveryConfiguration = config // Discovery configuration for tap-to-pay readers.
).isSupported

Discover readers.

Terminal.getInstance().discoverReaders(
    config = config, // Config for the kind of reader we're trying to discover. Bluetooth, internet and tap-to-pay readers config.
    callback = callback, // Discovery callback.
    discoveryListener = object : DiscoveryListener {
        override fun onUpdateDiscoveredReaders(readers: List<StripeReader>) {
            // We use the results here to show the list of readers on UI.
        }
    }
)

Connect to a reader.

// Disconnect connected reader if there's one.
if (Terminal.getInstance().connectedReader != null) {
    suspendCancellableCoroutine {
        terminal.disconnectReader(callback = callback)
    }
}

// Connect to reader.
suspendCancellableCoroutine { continuation ->
    val readerCallback = object : ReaderCallback {
        override fun onFailure(e: TerminalException) {
            continuation.resumeWithException(e)
        }

        override fun onSuccess(reader: StripeReader) {
            continuation.resume(Unit)
        }
    }

    Terminal.getInstance().connectReader(
        reader = reader, // Reader selected on the UI.
        config = config, // Connection config for reader.
        connectionCallback = readerCallback
    )
}

Error

com.stripe.stripeterminal.external.models.TerminalException: Failed to generate key pair.
at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.checkAndThrowCotsError(SourceFile:657)
at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.onReaderActivated(SourceFile:487)
at com.stripe.stripeterminal.internal.common.adapter.ProxyAdapter.onReaderActivated(SourceFile:54)
at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession.activateReader$terminalsession_release(SourceFile:612)
at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$ConnectReaderOperation.execute(SourceFile:2162)
at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$ExternalOperation.run$terminalsession_release(SourceFile:1245)
at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession.enqueueOperation$lambda$6(SourceFile:1052)
at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession.$r8$lambda$9_FdDGpM1BaifeFRjKBBfCCLP6o(SourceFile:0)
at com.stripe.stripeterminal.internal.common.terminalsession.TerminalSession$$ExternalSyntheticLambda0.run(SourceFile:0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

Android version

12, 14

Impacted devices (Android devices or readers)

Impacted Reader: Tap-to-pay (On-device)
Impacted Device: Unitech PA768

SDK version

4.0.0, 4.1.0

Other information

Not all devices are impacted (i.e. the implementation works fine on some PA768 devices).
The check for tap-to-pay support with the help of the terminal SDK returns true.
I have confirmed the device supports RSA key algorithm.

Sample video of how we have implemented discovering and connecting to readers.
https://github.com/user-attachments/assets/11ad5d4a-76ee-4cc1-bd5e-540552d1442f

@maggiewhite-stripe
Copy link
Contributor

Hi @Quadriy, this issue looks similar to #486

Sometimes manufacturers will ship different versions of the same model number with and without GMS support (ex. the Sunmi v2s). Can you confirm that GMS and Google Play Services are enabled on the affected devices?

@Quadriy
Copy link
Author

Quadriy commented Feb 14, 2025

Hi @Quadriy, this issue looks similar to #486

Sometimes manufacturers will ship different versions of the same model number with and without GMS support (ex. the Sunmi v2s). Can you confirm that GMS and Google Play Services are enabled on the affected devices?

Hi @maggiewhite-stripe Yes, GMS and Google Play Services are enabled.

Image

And running this:

GoogleApiAvailability
    .getInstance()
    .isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS

also returns true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants