stripe-terminal-react-native
stripe-terminal-react-native copied to clipboard
ERROR First initialize the Stripe Terminal SDK before performing any action
### 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.
- 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);
- 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 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.
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",
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?
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!!
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