【问题标题】:React Native: How do you get a Moneris transaction to return to app?React Native:如何让 Moneris 事务返回到应用程序?
【发布时间】:2019-10-25 19:29:56
【问题描述】:

我正在 WebView 中的 React Native 应用程序中处理与 Moneris 的事务。我的 WebView 中的 URL 包含我的托管支付页面配置的凭据作为 URI 参数。在 Moneris 网站上创建该配置时,我需要提供托管支付页面的 URL,以便在交易完成后重定向到。当我输入https://www.google.ca/ 之类的回调作为回调时,它工作正常,但我不知道我需要输入哪个回调 URL 才能返回到我的应用程序。

我想知道的:

我需要使用什么回调 URL 才能返回到 React Native 应用程序?

【问题讨论】:

    标签: reactjs react-native webview payment-processing react-native-webview


    【解决方案1】:

    WebView 只是您应用程序中的一个组件,因此您永远不会离开您的应用程序。首先,确认页面是在 WebView 中呈现的,而不是作为单独的应用程序启动浏览器并在那里打开页面(在这种情况下,您无法以编程方式返回您的应用程序)。然后,如果您实际使用的是 WebView 组件,例如,您可以执行以下操作:将 NavigationState 侦听器添加到您的 WebView,并读取 WebView 导航到的 url 并采取相应的操作

    class MyComponent extends React.Component{
    
      onNavigationStateChange = (navState) => {
        if (navState.url === 'https://www.yoursite.com') {
          // user just got redirected to requested site
          // do something in react-native app now, for example
          // close this component and show another one
        }
      }
    
      render(){
        return <View>
          <WebView
          ...
          onNavigationStateChange={this.onNavigationStateChange}
        />
        </View>
      }
    }
    

    【讨论】:

    • 嗨,Max,太好了,谢谢。我最终找到了不同的解决方法,但我认为这解决了我最初面临的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多