gpt4 book ai didi

Firefox - 引用错误 : PaymentRequest is not defined

转载 作者:行者123 更新时间:2023-12-03 23:06:03 25 4
gpt4 key购买 nike

我正在尝试在网站上实现 google pay。 google pay 的外部库是从 pay.google.com 加载的。在这个 google 脚本中,他们调用浏览器 api PaymentRequest()。这个 api 内置于流行的浏览器中,如 Safari、Chrome 等。
我有 google pay 工作,但它在 Firefox 上不起作用。加载外部脚本时,它调用 PaymentRequest 并在控制台中显示以下错误:
ReferenceError: PaymentRequest 未定义
链接到谷歌支付脚本
https://pay.google.com/gp/p/js/pay.js
Mozilla Firefox 官方网页声明在安全上下文中支持 PaymentRequest。
https://developer.mozilla.org/en-US/docs/Web/API/Payment_Request_API/Using_the_Payment_Request_API
我只复制和粘贴官方来源提供的相同代码
enter image description here
在我看来,PaymentRequest 在 Firefox 中不受支持并且不起作用。我错过了什么?
查看 chrome 和 safari 的控制台。
enter image description here

最佳答案

Google Pay 在 macOS 上的 Firefox 78.0.1 上为我工作,使用以下命令:https://jsfiddle.net/fw5t6caL/
是的,它确实在控制台中的以下代码位记录了错误:

  google.payments.api.UseCanMakePaymentResultFromPayjs && (new PaymentRequest([{
supportedMethods: [
'https://google.com/pay'
]
}
], {
total: {
label: 'Estimated Total Price',
amount: {
currency: 'USD',
value: '10'
}
}
})).canMakePayment().then(function (a) {
return ef = a
}).catch (function () {
return ef = !1
});
...但它确实有效。您可以尝试使用上面链接的 JSFiddle 吗?
此外,作为仅供引用,我们最近 released a React and Web Component简化 Google Pay 集成过程。考虑使用它作为替代方案,因为它应该更容易集成。
JSFiddle 输出的屏幕截图:
enter image description here

关于Firefox - 引用错误 : PaymentRequest is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62669983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com