我正在尝试在WebView中使用Stripe Checkout(在Android和iOS中)。
如果我在移动设备的Google Chrome
page中运行演示结帐,则会打开一个新的网页,一切正常。
当我尝试从WebView运行演示时(我希望它以完全相似的方式运行)它不起作用并给我一个
Sorry, there was a problem loading Checkout.
If this persists, please try a different browser.
我认为这不是针对移动设备制作的,但事实并非如此,因为谷歌Chrome浏览器的效果非常好。 有什么建议让它发挥作用吗?
答案 0 :(得分:0)
这是我设法在网页浏览中使用Stripe Checkout的唯一方法(我使用了Xamarin):
试用此代码,看看结帐工作正常:
using System;
using Xamarin.Forms;
using Plugin.Share;
using Plugin.Share.Abstractions;
namespace stripewebviewtest
{
public class App : Application
{
public App ()
{
Button btn = new Button ();
btn.Text = "Click on me!";
// The root page of your application
MainPage = new ContentPage {
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
},
btn
}
}
};
btn.Clicked += (object sender, EventArgs e) => {
var url = "https://stripe.com/docs/checkout";
CrossShare.Current.OpenBrowser (url, new BrowserOptions {
ChromeShowTitle = true,
ChromeToolbarColor = new ShareColor {
A = 255,
R = 118,
G = 53,
B = 235
},
UseSafairReaderMode = false,
UseSafariWebViewController = false
});
};
}
protected override void OnStart ()
{
// Handle when your app starts
}
protected override void OnSleep ()
{
// Handle when your app sleeps
}
protected override void OnResume ()
{
// Handle when your app resumes
}
}
}
在设备上运行项目