繁体   English   中英

在Xamarin.Z6450242531912981C668A3应用程序支付成功后,如何从WebView获得退货URL?

[英]How to get return URL from WebView after successful payment in Xamarin.Forms app?

我在我的 Xamarin Forms 应用程序中集成了一个支付网关。 填写完付款详情后,我在 WebView 中打开付款页面以完成付款。 付款完成后,它会返回带有付款状态代码的 URL。 现在的问题是,如何在我的 Xamarin Forms 应用程序中获得此返回 URL?

首先,我强烈建议您通过 SDK 或 API 查看您正在使用的支付系统是否有某种支持,您可以使用它们来完成支付过程,而无需使用 Z3E7D16622A52391BD7BF69CAEZEF6。

On the other hand, if you are already decided to use WebView for that, you can use Navigating event from Xamarin.Forms WebView .

Navigating是在导航开始时引发的事件。

在 C# 中使用它:

yourWebView.Navigating += YourWebView_Navigating;

或者在 XAML 中:

<WebView Navigating="YourWebView_Navigating" 
...

并且在您的代码隐藏中,您可以访问WebNavigatingEventArgs它:

void YourWebView_Navigating(object sender, WebNavigatingEventArgs e)
{
    if (e.Url // check the value of it
    // other code logic.

使用它,您将可以访问WebNavigatingEventArgs ,它包含一个名为Url的属性,使用该信息您可以检查 URL 值并将其与应用程序中的其他逻辑相结合,导航用户离开或成功付款后您打算执行的任何操作。

希望这对您有所帮助,祝您编码好运!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM