getsafepay / safepay-node

Safepay node.js client
MIT License
7 stars 3 forks source link

React native support #4

Open Osamasomy opened 4 years ago

Osamasomy commented 4 years ago

how can i use this with react native

Hashir-Khan777 commented 2 years ago

What do you mean about react-native support?. It is for node js backend and react-native is for mobile frontend.

jamilAbbas commented 2 months ago

@Osamasomy You can add it via Webview

  1. Generate the checkout url in the backend, make sure you have added the source as "mobile" in the checkout function.
  2. load the url in a webview
  3. In navigationStateChange function redirect user based on the success or failure e.g const onNavigationStateChange = (event) => { const url = event.url; if (url.indexOf('/mobile') === -1) { return; } const params = url.split('?')[1]; const parsed = queryString.parse(params); if (parsed.action === 'cancelled') { navigation.goBack(); } if (parsed.action === 'complete' && !paymentVerified.current) { paymentVerified.current = true; verifyPayment(routes.rideId, parsed.order_id); } };