stripe / stripe-terminal-react-native

React Native SDK for Stripe Terminal
https://stripe.com/docs/terminal/payments/setup-integration?terminal-sdk-platform=react-native
MIT License
95 stars 47 forks source link

Expo 50 iOS crashes when calling terminal.initialize #615

Closed Noitidart closed 3 months ago

Noitidart commented 5 months ago

Describe the bug Calling initialize of terminal is returning promise that resolves with { error: undefined, reader: null }, the app freezes, then crashes.

To Reproduce Steps to reproduce the behavior:

Render provider:

import {
  StripeTerminalProvider,
  useStripeTerminal
} from '@stripe/stripe-terminal-react-native';

    <StripeTerminalProvider
      tokenProvider={fetchToken}
    >
      <StripedKioskPage kiosk={props.kiosk} />
    </StripeTerminalProvider>

This renders a <StripedKioskPage> component that calls initialize like this:


const { initialize } = useStripeTerminal();

useEffect(() => {
  initialize().then(res => console.log(res))
}, []);

Expected behavior App shouldn't crash.

Screenshots none

Stripe Terminal React Native SDK version ^0.0.1-beta.15

Smartphone (please complete the following information):

Additional context

Using Expo and have these following versions of expo and stripe terminal and stripe packages:

    "@stripe/stripe-react-native": "~0.35.1",
    "@stripe/stripe-terminal-react-native": "^0.0.1-beta.15",
    "expo": "^50.0.4",

My build config plugins entry in app.json is like this:

    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "minSdkVersion": 26,
            "compileSdkVersion": 34,
            "targetSdkVersion": 34,
            "buildToolsVersion": "34.0.0",
            "packagingOptions": {
              "pickFirst": ["org/bouncycastle/x509/CertPathReviewerMessages*"]
            }
          },
          "ios": {
            "deploymentTarget": "13.4"
          }
        }
      ],
      "expo-router",
      "sentry-expo",
      "expo-localization",
      [
        "@stripe/stripe-react-native",
        {
          "merchantIdentifier": "HIDDEN",
          "enableGooglePay": true
        }
      ],
      [
        "@stripe/stripe-terminal-react-native",
        {
          "bluetoothBackgroundMode": true,
          "locationWhenInUsePermission": "Location is needed to securely accept donations.",
          "bluetoothPeripheralPermission": "Bluetooth peripheral permission is needed to discover card readers for donations.",
          "bluetoothAlwaysUsagePermission": "Bluetooth permission is needed to stay connected to card readers for donations."
        }
      ]
    ],
Noitidart commented 5 months ago

My Sentry caught this error, I'm not sure if it's related, and Sentry just got lucky:

NSInternalInconsistencyException

Error when sending event: onFetchTokenProviderListener with body: {
}. RCTCallableJSModules is not set. This is probably because you've explicitly synthesized the RCTCallableJSModules in StripeTerminalReactNative, even though it's inherited from RCTEventEmitter.
image
Brunowilliang commented 3 months ago

hey @Noitidart Did you manage to resolve the error?

Noitidart commented 3 months ago

hey @Noitidart Did you manage to resolve the error?

I didn't :(

I downgraded to v .14 to fix it. Not sure if the latest version.16 fixes it.

One mistake I was making was I also had @stripe/stripe-react-native installed. We only need the terminal package installed. I'm not sure if Uninstalling that would fix it.

nazli-stripe commented 3 months ago

hey @Noitidart we just release v.17. Can you see if that fixed the issue?

Noitidart commented 3 months ago

Thank you very much I will try tonight and back to you within 24h please.

Brunowilliang commented 3 months ago

@nazli-stripe It's working for me, at expo 50 and with stripe v.17

Noitidart commented 3 months ago

Thanks Bruno for the verify and Nazli for the fix! I'll double verify tomorrow, should we close this for now?