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

Can we add @stripe/stripe-react-native package for React native web version will it support?

Open GitHubShasiKumar opened this issue 2 years ago • 5 comments

GitHubShasiKumar avatar Nov 06 '23 10:11 GitHubShasiKumar

No. At least, when it's used with:

"@stripe/stripe-react-native": "0.6.1"
"react-native": "0.68.2" 
"react-native-web": "0.17.7" 

the lib is causing error: "Cannot read properties of undefined (reading 'setGlobalHandler')

majirosstefan avatar Jan 02 '24 15:01 majirosstefan

any ideas if there are plans to support web? what is missing for it to work?

alejomendoza avatar Jan 10 '24 19:01 alejomendoza

The workaround (solution?) that I saw was add to Stripe for React JS (web SDK) to your React Native app and then write your own platform specific utilities / wrappers e.g. in a files called

  • stripe.tsx - for iOS, android, etc that uses imports from React Native SDK
  • stripe.web.tsx for web that uses imports from Stripe ReactJS (web SDK)

The bundler would pick the correct file for your platform. However, the both files need to implement the same interface or you would need to use branching in your code (e.g. if (Platform.OS == "web") {} else {})

majirosstefan avatar Jan 10 '24 21:01 majirosstefan

The workaround (solution?) that I saw was add to Stripe for React JS (web SDK) to your React Native app and then write your own platform specific utilities / wrappers e.g. in a files called

  • stripe.tsx - for iOS, android, etc that uses imports from React Native SDK
  • stripe.web.tsx for web that uses imports from Stripe ReactJS (web SDK)

The bundler would pick the correct file for your platform. However, the both files need to implement the same interface or you would need to use branching in your code (e.g. if (Platform.OS == "web") {} else {})

does this work for expo apps?

naticio avatar Mar 09 '24 18:03 naticio

Is there an example of this?

moza88 avatar Jun 27 '24 11:06 moza88