1
votes

I'm currently developing a mobile application using React Native Expo. In order to avoid detaching I'm using the Stripe client-only checkout page in a WebView.

My question is how do I redirect a successful/cancelled payment back to a specific screen in my application from the WebView?

2
The Green Tick of Approval is the standard way of indicating a question has been resolved for the asker; no need to add "[SOLVED]" or anything like that. You could have known because no other questions have that (unless they do; then it'll be removed). - Jongware

2 Answers

4
votes

I had a similar issue - if you know what the redirect url will look like ahead of time... This is what I did... so in my case lets call my url http://google.com

   render() {
      return (
      
       <WebView
         onNavigationStateChange={ 
             (e) => { 
               if(e.url == "https://www.google.com/") this.props.navigation.navigate("NewsFeed")
             }
          }
       source={{ uri: 'https://a-url-to-load' }} style={styles.WebView} />
      )
   };
  }

Of course you should extract that function out to do more complex stuff... etc

0
votes

I think what you want to do here is use Deep Links as the return URL which should allow you to get right back into the app - and you can use the path to specify exactly where it should land.