stripe-terminal-react-native: [bug] Contactless transaction failed com.stripe.core.aidIrpc.AidIRpcException: Failed to send request to AIDL server.

Describe the bug See the attached photo. Repeatably on Android, after calling collectPaymentMethod to present the Tap to Pay card reader, the reader screen dismisses and this error in thrown. The full text in the alert body is the entirety of the error message:

Contactless transaction failed com.stripe.core.aidIrpc.AidIRpcException: Failed to send request to AIDL server.

It appears this issue was introduced after updating from targetSdkVersion & compileSdkVersion 33 to 34.

It is still possible to take a contactless payment on Android, so this appears to be intermittent.

My best guess is that this is related to card read errors (“Try again” and loud beep on Android). After two or three of these, the sheet closes and the error is triggered.

In general, it seems that the Android tap to pay reader is very unreliable, and the user has to endure several “Try again” errors before successfully processing the payment. This was the case before updating the targetSdkVersion, so I am not sure if it is related.

To Reproduce Steps to reproduce the behavior:

  1. Trigger collectPaymentMethod({ paymentIntent })
  2. Observe payment sheet appears
  3. Tap a payment card in the indicated location
  4. Observe either a successful payment (if so, restart the steps here), or a loud beep and “Try again” error
  5. After 2-3 “Try again” errors, observe the payment sheet dismisses and collectPaymentMethod promise rejects with the error message in the issue title.

Expected behavior

  • Primarily, the payment sheet remains active correctly for both successful and unsuccessful card reads
  • Secondarily, the tap to pay reader is more reliable in reading the card successfully for the first time

Screenshots

IMG_6399

Stripe Terminal React Native SDK version

  • ^0.0.1-beta.19

Smartphone (please complete the following information):

  • Device: Google Pixel 6a
  • OS: Android 14

Additional context

In Expo app.json plugins:

[
				"expo-build-properties",
				{
					"android": {
						"targetSdkVersion": 34,
						"compileSdkVersion": 34,
						"minSdkVersion": 26,
						"buildToolsVersion": "34.0.0",
						"packagingOptions": {
							"exclude": [
								"org/bouncycastle/x509/CertPathReviewerMessages*"
							]
						}
					}
				}
]

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Ah yes, you are correct that this isn’t available in the React Native SDK just yet. Support for it was added recently in #964 though, and it will be available in the next release.

Despite that, you’re still able to mimic the way that API is intended to be used by simply returning early:

if ("com.tradiecore.alpha:stripetaptopay" == processName) {
    return
}

This will skip all application initialization for the Tap to Pay process, including hopefully whatever other mechanism is trying to use the WebView in your application. However, if your current solution works just fine for you already, then you can continue to use that as well 🙂

@chr-stripe have done the following as a workaround for now and it is working

override fun onCreate() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        val processName = getProcessName()
        if ("com.tradiecore.alpha:stripetaptopay" == processName) {
            WebView.setDataDirectorySuffix(processName)
        }
    }

Hi all, thanks for reporting the errors you are seeing in your integrations.

Just to give a bit of background on this, Tap to Pay on Android partly operates in an isolated background process. This particular error message is shown when the main app process fails to establish a connection with this background process, typically happens if the background process fails to initialize, crashes during initialization, or experiences memory pressure from the OS as mentioned above. Due to the nature of process isolation, this can make it difficult for the Terminal SDK to highlight exactly what went wrong to the integration, hence the “Service never connected” message.

Often, inspecting the logcat logs of your integration when initially discovering/connecting to the reader may indicate exactly what the root cause here is, if you’re able to reproduce this locally. If you are able to share those logcat logs, I’d be happy to take a look as well to see if there’s anything that sticks out, and make recommendations based on those findings.

We are also taking steps in upcoming SDK versions to improve some observability in this area, in the hopes that it will make these issues easier for both Stripe and individual developers to diagnose and resolve.

Interesting, we just updated to beta-22 and hit the same error @nabilfreeman is experiencing.

  1. Our old app, that was on beta-19 can connect and process payments fine in our prod and test environments
  2. Our new build, that is on beta-22 with no other changes (aside from a higher build sdk) can no longer connect to a “tap to pay” device in prod and test environments, and throw Contactless transaction failed com.stripe.core.aidlrpc.AidlRpcException: Service never connected error when trying to connect on android (note, this works fine on iOS)

We’ll be rolling back to 19 until this is fixed, @nazli-stripe let me know if you end up needing further details to help you debug it.

Edit: Downgrading to beta-19 has not solved the issue, I believe this is because of a change in expo’s ecosystem introduced from a dep change, somewhere.

Edit: Rollback was successful, here’s my new versus old package.json NEW

"dependencies": {
    "@expo-google-fonts/open-sans": "^0.2.3",
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-community/datetimepicker": "8.0.1",
    "@react-native-community/netinfo": "11.3.1",
    "@react-native-google-signin/google-signin": "^11.0.0",
    "@react-navigation/drawer": "^6.6.15",
    "@react-navigation/native": "6.1.17",
    "@react-navigation/stack": "6.3.29",
    "@reduxjs/toolkit": "^1.9.5",
    "@shopify/react-native-skia": "1.2.3",
    "@stripe/stripe-terminal-react-native": "^0.0.1-beta.19",
    "async-mutex": "^0.4.0",
    "expo": "^51.0.38",
    "expo-apple-authentication": "~6.4.2",
    "expo-application": "~5.9.1",
    "expo-build-properties": "~0.12.5",
    "expo-checkbox": "~3.0.0",
    "expo-crypto": "~13.0.2",
    "expo-dev-client": "~4.0.28",
    "expo-font": "~12.0.4",
    "expo-location": "~17.0.1",
    "expo-secure-store": "~13.0.2",
    "expo-splash-screen": "~0.27.6",
    "expo-status-bar": "~1.12.1",
    "expo-updates": "~0.25.27",
    "expo-web-browser": "^13.0.3",
    "install": "^0.13.0",
    "luxon": "^3.4.2",
    "npm": "^10.8.1",
    "patch-package": "^8.0.0",
    "react": "18.2.0",
    "react-native": "0.74.5",
    "react-native-app-intro-slider": "^4.0.4",
    "react-native-dropdown-picker": "^5.4.7-beta.1",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.31.1",
    "react-native-toast-notifications": "^3.4.0",
    "react-navigation-header-buttons": "^11.0.0",
    "react-redux": "^8.1.2",
    "expo-device": "~6.0.2"
  },
  "devDependencies": {
    "@babel/core": "^7.24.0",
    "@types/luxon": "^3.3.1",
    "@types/react": "~18.2.79",
    "@typescript-eslint/eslint-plugin": "^5.43.0",
    "@typescript-eslint/parser": "^5.43.0",
    "eslint": "^8.32.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-import": "^2.28.1",
    "eslint-plugin-n": "^16.0.1",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-react": "^7.33.2",
    "prettier": "^2.8.8",
    "prettier-eslint": "^16.1.2",
    "typescript": "^5.2.2"
  },

Old (Pre Rollback)

  "dependencies": {
    "@expo-google-fonts/open-sans": "^0.2.3",
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-community/datetimepicker": "8.2.0",
    "@react-native-community/netinfo": "11.4.1",
    "@react-native-google-signin/google-signin": "^11.0.0",
    "@react-navigation/drawer": "^6.6.15",
    "@react-navigation/native": "6.1.17",
    "@react-navigation/stack": "6.3.29",
    "@reduxjs/toolkit": "^1.9.5",
    "@shopify/react-native-skia": "1.5.0",
    "@stripe/stripe-terminal-react-native": "^0.0.1-beta.22",
    "async-mutex": "^0.4.0",
    "expo": "^52.0.6",
    "expo-apple-authentication": "~7.1.0",
    "expo-application": "~6.0.1",
    "expo-build-properties": "~0.13.1",
    "expo-checkbox": "~4.0.0",
    "expo-crypto": "~14.0.1",
    "expo-dev-client": "~5.0.1",
    "expo-device": "~7.0.1",
    "expo-font": "~13.0.1",
    "expo-location": "~18.0.1",
    "expo-secure-store": "~14.0.0",
    "expo-splash-screen": "~0.29.9",
    "expo-status-bar": "~2.0.0",
    "expo-updates": "~0.26.7",
    "expo-web-browser": "~14.0.1",
    "install": "^0.13.0",
    "luxon": "^3.4.2",
    "npm": "^10.8.1",
    "patch-package": "^8.0.0",
    "react": "18.3.1",
    "react-native": "^0.76.2",
    "react-native-app-intro-slider": "^4.0.4",
    "react-native-dropdown-picker": "^5.4.7-beta.1",
    "react-native-gesture-handler": "~2.20.2",
    "react-native-reanimated": "~3.16.1",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "~4.0.0",
    "react-native-toast-notifications": "^3.4.0",
    "react-navigation-header-buttons": "^11.0.0",
    "react-redux": "^8.1.2"
  },
  "devDependencies": {
    "@babel/core": "^7.24.0",
    "@types/luxon": "^3.3.1",
    "@types/react": "~18.3.12",
    "@typescript-eslint/eslint-plugin": "^5.43.0",
    "@typescript-eslint/parser": "^5.43.0",
    "eslint": "^8.32.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-import": "^2.28.1",
    "eslint-plugin-n": "^16.0.1",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-react": "^7.33.2",
    "prettier": "^2.8.8",
    "prettier-eslint": "^16.1.2",
    "typescript": "^5.2.2"
  },

@nabilfreeman Just fyi, we’re running the rollbacked build on these build targets and it is working fine.

android: {
    minSdkVersion: 26,
    compileSdkVersion: 34,
    targetSdkVersion: 34,
    buildToolsVersion: '34.0.0',
    packagingOptions: {
      pickFirst: ['org/bouncycastle/x509/CertPathReviewerMessages*'],
    }
  }

I think there is an issue here, somewhere. Probably with an expo or react update?

hey @nabilfreeman thanks for reporting this issue. We are internally looking into this and will update once we know more or if we need more information.