简体   繁体   English

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

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

I have integrated a payment gateway in my Xamarin Forms app.我在我的 Xamarin Forms 应用程序中集成了一个支付网关。 After filling the payment details I am opening the payment page in WebView to complete the payment.填写完付款详情后,我在 WebView 中打开付款页面以完成付款。 When the payment is completed it returns a URL with the payment status code.付款完成后,它会返回带有付款状态代码的 URL。 Now the question is that how can I get this return URL in my Xamarin Forms app?现在的问题是,如何在我的 Xamarin Forms 应用程序中获得此返回 URL?

First of all, I strongly recommend you to take a look if that payment system which you are using has some kind of support via SDK or API which you can use to complete that paying process, without using WebView.首先,我强烈建议您通过 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 . On the other hand, if you are already decided to use WebView for that, you can use Navigating event from Xamarin.Forms WebView .

Navigating is an event that is raised when navigation starts. Navigating是在导航开始时引发的事件。

Use it in C#:在 C# 中使用它:

yourWebView.Navigating += YourWebView_Navigating;

Or in XAML:或者在 XAML 中:

<WebView Navigating="YourWebView_Navigating" 
...

and in your code-behind you have the access to WebNavigatingEventArgs it:并且在您的代码隐藏中,您可以访问WebNavigatingEventArgs它:

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

Using it you will get access to WebNavigatingEventArgs which holds a property called Url , with that info you can check the URL value and combine that with other logic in your app, navigate the user away or whatever you intended to do after successful payment.使用它,您将可以访问WebNavigatingEventArgs ,它包含一个名为Url的属性,使用该信息您可以检查 URL 值并将其与应用程序中的其他逻辑相结合,导航用户离开或成功付款后您打算执行的任何操作。

Hope this was helpful for you, wishing you lots of luck with coding!希望这对您有所帮助,祝您编码好运!

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

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