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

Production Android Build Not Connect With Reader With Live_Stripe_KEY Using v0.0.1-beta.16 Version. #711

Open
abhijitCN opened this issue May 24, 2024 · 14 comments

Comments

@abhijitCN
Copy link

abhijitCN commented May 24, 2024

When we use the simulated true option, both Android and iOS work perfectly. However, when we set it to false, the reader does not connect. Calling connectLocalMobileReader() returns an error.

Below I have added my code, please review it once.

const [discoveredReader, setDiscoveredReader] = useState([]);
useEffect(() => {
  console.log("NFC capability alert start")
  async function handleDiscoverReaders() {
    const {error, readers} = await discoverReaders({
      discoveryMethod: 'localMobile',
      //simulated: true,
    });
    Alert.alert('discoverReaders() readers >>', readers);
    if (error) {
      navigation.navigate('ReaderNotConnected');
    } else {
    }
  }
  handleDiscoverReaders();
}, [discoverReaders]);
  const {discoverReaders, discoveredReaders,connectLocalMobileReader} = useStripeTerminal({
    onUpdateDiscoveredReaders: readers => {
      console.log('My Discovered Readers >> ', readers);
      setDiscoveredReader(readers[0]);
      console.log('ARRAY OF DiscoveredReaders >> ', discoveredReaders);
    },
    onDidChangeConnectionStatus: (status) => {
      console.log('Connection Status >> ', status);
    },
    onDidReportUnexpectedReaderDisconnect: (readers) => {
      Alert.alert('Reader Disconnected', 'Please try again');
    },
  });
  async function connectMobileReader() {
    const {reader, error} = await connectLocalMobileReader({
      reader: discoveredReader
      locationId: stripeLocation?.data?.id,
    });
    Alert.alert('connectLocalMobileReader() readers >>', reader);
    console.log('Reader connected successfully', reader);
    if (error) {
      console.log('connectLocalMobileReader error:', error);
      Alert.alert('Reader not connected');
      return;
    }
    Alert.alert('Reader connected successfully');
    navigation.navigate('NewPayment');
  }

Screenshot
unnamed (1)

Stripe Terminal React Native SDK version

  • ^0.0.1-beta.16

I have used the below listed devices

  • Android Device: Samsung Galaxy S10+
  • iPhone Device: iPhone 13

Additional context
{YOUR BACKEND URL}/connection_token using this ConnectionToken in index.js

return (
    <StripeTerminalProvider logLevel="verbose" tokenProvider={fetchTokenProvider}>
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
          <App />
      </PersistGate>
    </Provider>
    </StripeTerminalProvider>
  ); 

Call initialize in app.js

useEffect(() => {
    initialize({
      logLevel: 'verbose',
    });
  }, [initialize]); 

@nazli-stripe @billfinn-stripe can you please look into this and assist me.

@mikrich
Copy link

mikrich commented May 28, 2024

@abhijitCN I am also experiencing a similar issue, I'm testing out a Production build on Android and am getting an error back from stripe when attempting to connect using connectLocalMobileReader.. The message I'm seeing in the error object is No such location: <locationId>. However the location exists. Are you getting a similar message?

@abhijitCN
Copy link
Author

@mikrich Thanks for the response,

In our project, location is coming from the backend API I passed the location ID in Stripe. after that I call connectLocalMobileReader() function, and in throw the error the reader is not connecting.

Below Code where I getting error.

async function connectMobileReader() {
const {reader, error} = await connectLocalMobileReader({
reader: discoveredReader
locationId: stripeLocation?.data?.id,
});
if (error) {
console.log('connectLocalMobileReader error:', error);
Alert.alert('Reader not connected');
return;
}
}

@mikrich
Copy link

mikrich commented May 28, 2024

what message do you see when you log out console.log('connectLocalMobileReader error:', error); If you are testing on a device you will need to print it out in the alert for example Alert.alert(JSON.strigify(error))

@abhijitCN
Copy link
Author

Screenshot_20240529_182236_blink
I have attached a screenshot of my error. Have you Faced this !!

@mikrich
Copy link

mikrich commented May 29, 2024

I was facing a different issue No such location: <locationId> however it turns out the request for the token (on our backend) had been set up incorrectly which has now been fixed and it's working. I've not seem the issue you are experiencing.

@abhijitCN
Copy link
Author

@mikrich Which Stripe Terminal React Native SDK version are you using?

@mikrich
Copy link

mikrich commented May 30, 2024

@abhijitCN the latest v0.0.1-beta.18

@abhijitCN
Copy link
Author

@mikrich can you please look into this and assist me.
unnamed (2)

@mikrich
Copy link

mikrich commented May 30, 2024

@abhijitCN
Copy link
Author

Hi, @mikrich I have a query that my Screen Short Error and your error are the same?
unnamed (2)

@dshalaby
Copy link

I'm getting the same error (in test mode), and I know that:

(1) I'm the location id from the correct Stripe account/dashboard that is connected in test mode
(2) The location id is valid and entered correctly

Android stripe-terminal sdk v2.19.0

Logcat shows this:

 class=TerminalSession
 com.stripe.stripeterminal.external.models.TerminalException: No such location: 'tml_xxxxxxxxxxx'

@nazli-stripe
Copy link
Collaborator

@dshalaby are you using the Android SDK directly? the repo for that is https://github.com/stripe/stripe-terminal-android/issues

@CarlMenke
Copy link

I was facing a different issue No such location: <locationId> however it turns out the request for the token (on our backend) had been set up incorrectly which has now been fixed and it's working. I've not seem the issue you are experiencing.

Im running into this same issue, any chance you could share how you have your connection token endpoint set up in your backend?

@dshalaby
Copy link

dshalaby commented Nov 4, 2024

@nazli-stripe Yes I was thank you, sorry for the late reply.

@CarlMenke My connection token endpoint was working fine in so far as the Stripe SDK. Our issue was something internal in our application rather than anything on the Stripe side. In our case this error was coming about because of a conflict in the initial Connect OAUTH token grant and our connection token endpoint.

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

5 participants