无需 SDK 即可响应本机支付网关

Ano*_*shi 1 payment payment-gateway react-native

我正在使用 react native 做一个电子商务应用程序。我们需要集成一个支付网关,它似乎没有用于反应本机(ADCB)的 SDK。我应该如何处理这个问题?

我可以继续使用自定义选项卡吗?如果是这样,付款完成后如何关闭自定义选项卡?


url = 'https://www.example.com/newsagepay/newtest.php?&customerSage='+isuerID+'&checkSage=1';

CustomTabs.openURL(url,{ toolbarColor: '#607D8B',enableUrlBarHiding: true, showPageTitle: true, enableDefaultShare: true, 
animations: ANIMATIONS_SLIDE}).then((launched: boolean) => {                                                        
    console.log(`Launched custom tabs: ${launched}`);
}).catch(err => {
    console.error(err)
});  
Run Code Online (Sandbox Code Playgroud)

ram*_*mar 5

我想建议你<WebView />,你可以使用 webView 的一个属性,称为onNavigationStateChange={}传递一个函数给它。监控 URLwebview并根据成功或失败进行处理。

例如。 假设支付成功 URL 是http://payment.sucess

<WebView 
onNavigationStateChange={(webViewState)=>{
console.log(webViewState.url)
if(webViewState.url==="http://payment.sucess"){
//navigate or close webview
}}
javaScriptEnabled = {true}
domStorageEnabled = {true}
/>
Run Code Online (Sandbox Code Playgroud)

  • @AnoopJoshi你没有正确阅读文档,webview现在是https://github.com/react-native-community/react-native-webview,onNavigationStateChange事件也适用于它,请参阅https://github.com/ react-native-community/react-native-webview/blob/master/docs/Reference.md#onnavigationstatechange (2认同)