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
110 stars 50 forks source link

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

Open MoinJanjua opened 3 months ago

MoinJanjua commented 3 months ago

Describe the bug

I am trying to implement Stripe terminal sdk but i ma unable to initialize it I have below error "First initialize the Stripe Terminal SDK before performing any action at CartReaders"

To Reproduce I Create the Root,App and Payment screen After running Root and App screen and open the Payment screen to display readers than it display error even I will try with connection_token directly pass to function "First initialize the Stripe Terminal SDK before performing any action at CartReaders (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.grunq.pos:197064:26)"

Expected behavior I want it should initialize the SDK properly

Screenshots Screenshot 2024-07-04 at 3 06 21 PM Screenshot 2024-07-04 at 3 10 25 PM

Stripe Terminal React Native SDK version

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

Smartphone (please complete the following information):

Additional context

nabilfreeman commented 3 months ago

Did you wrap the application with StripeTerminalProvider and hook up the server-side connection token API endpoint properly?

MoinJanjua12 commented 3 months ago

Yes I did properly even i try with Static Token that i generated from the Postman

nabilfreeman commented 3 months ago

I didn't see the initialize func being called - Try:

const { initialize, isInitialized, discoverReaders } = useStripeTerminal();

// Call initialize on mount
useEffect(() => {
  void initialize();
}, []);

// Wait for initialization to complete before calling discoverReaders
useEffect(() => {
  if(isInitialized) {
    void discoverReaders();
  }
}, [isInitialized]);

// Remember to implement error handling etc
MoinJanjua commented 3 months ago

I tried by this way too and have the same issue here is the error "StripeTerminalProvider component is not found, has not been mounted or SDK has not been initialized properly"

I was already initialized but facing the same issue