stripe-terminal-react-native icon indicating copy to clipboard operation
stripe-terminal-react-native copied to clipboard

ERROR First initialize the Stripe Terminal SDK before performing any action

Open abhijitCN opened this issue 10 months ago • 8 comments

### In my Root(index.js) I initialized <StripeTerminalProvider/> and API call for token and in App.js useEffect call the const { initialize } = useStripeTerminal() as per the documentation but still I get ERROR First initialize the Stripe Terminal SDK before performing any action PLEASE HELP.

  1. In my indej.js

import { StripeTerminalProvider } from '@stripe/stripe-terminal-react-native'; import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; import App from './src/App';

const ReduxAppWrapper = () => { const fetchTokenProvider = async () => { try { const response = await fetch( FetchTokenApi/stripe/tokens, { method: 'GET', headers: { 'Content-Type': 'application/json', }, }, ); const {secret} = await response.json(); console.log('fetch Token Provider secret KEY >> ', secret); return secret; } catch (error) { console.log('fetch Token Provider eror >> ', error); } };

return ( <StripeTerminalProvider logLevel="verbose" tokenProvider={fetchTokenProvider}> <App/> </StripeTerminalProvider> ); }; AppRegistry.registerComponent(appName, () => ReduxAppWrapper);

  1. In my App.js

function App() { const { initialize } = useStripeTerminal();

useEffect(() => { console.log('USE EFFECT >>initialized stripe-terminal in ROOT > '); initialize({ logLevel: 'verbose', }); }, [initialize]);

return ( <> <MainStackNavigation /> <Toast /> </> ); } export default App;

** @kevinlam92 @mihaildu @TheRusskiy @SudoPlz & ANYONE face this issue**

abhijitCN avatar Apr 05 '24 09:04 abhijitCN

@abhijitCN are you still running into this issue? initialize method returns a Promise and you'll need to wait for its completion before calling other methods.

nazli-stripe avatar Jun 11 '24 22:06 nazli-stripe

Hi ; I also have the same issue I am trying to implement card reader sdk ReactNative

"First initialize the Stripe Terminal SDK before performing any action"

SDK version "@stripe/stripe-terminal-react-native": "^0.0.1-beta.19",

MoinJanjua avatar Jul 03 '24 13:07 MoinJanjua

I have the same issue, I initialize the SDK and after I call the discoverReaders and I have the error, this is my code:

const { error, reader } = await initialize(); ... const { error: discoverReadersError } = await discoverReaders({ discoveryMethod: 'bluetoothScan', simulated: true, });

when the promise of initialize is finished the SDK shouldn't it be ready?

GabrielDuarteJr avatar Jul 15 '24 00:07 GabrielDuarteJr

I have the same issue, I initialize the SDK and after I call the discoverReaders and I have the error, this is my code:

const { error, reader } = await initialize(); ... const { error: discoverReadersError } = await discoverReaders({ discoveryMethod: 'bluetoothScan', simulated: true, });

when the promise of initialize is finished the SDK shouldn't it be ready?

@GabrielDuarteJr hello, have you got any solution for it!!

abhijitCN avatar Aug 21 '24 08:08 abhijitCN

hi, I'm also having this issue!

My root is wrapped in a stripe terminal provider (splash screen) then the home page initialises and the payment page scans for readers, but I am getting that error when my useEffect to scan for readers kicks in. Any coms / help would be appreciated, thanks

w4nd3r1ingY4k avatar Aug 26 '24 16:08 w4nd3r1ingY4k