我试图在我的Android模拟器中运行的本地网站上测试Google的PaymentRequest api。但是,当我做的时候
var paymentRequest = window.PaymentRequest(//some object here//);
我收到以下错误
"Error: Failed to construct 'PaymentRequest': Must be in a secure context
现在,PaymentRequest将在localhost和https上运行,但是从Android模拟器上的端口运行它,其中uri为10.2.2.01:8000/myUrlHere
将失败,因为它不是localhost。有关如何解决这个问题的任何想法?
答案 0 :(得分:3)
PaymentRequest必须用于安全上下文,它是以下之一:
http:// 10.2.2.01:8000不是安全的上下文,因此您无法在那里使用PaymentRequest。请尝试以下方法之一:
答案 1 :(得分:2)
如果您拥有Android设备,则可以通过USB电缆连接设备并从localhost提供服务来测试您的网站。试试这个:
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/
如果不这样做,您可能希望使用模拟器尝试此工具:
ngrok允许您从***。ngrok.com域的localhost代理服务。