Google Pay 对接可能遇到的问题
问题集
如何实现在商户网站就判断当前浏览器是否支持googlepay
目前googlepay支持在多种浏览器端进行支付,具体可以用Googlepay的js来判断一下
https://developers.google.cn/pay/api/web/guides/tutorial?hl=zh-cn
/**
* Initialize Google PaymentsClient after Google-hosted JavaScript has loaded
*
* Display a Google Pay payment button after confirmation of the viewer's
* ability to pay.
*/
function onGooglePayLoaded() {
const paymentsClient = getGooglePaymentsClient();
paymentsClient.isReadyToPay(getGoogleIsReadyToPayRequest())
.then(function(response) {
if (response.result) {
// 这里改造成是否显示googlepay button
addGooglePayButton();
// @todo prefetch payment data to improve performance after confirming site functionality
// prefetchGooglePaymentData();
}
})
.catch(function(err) {
// show error in developer console for debugging
console.error(err);
});
}
最后修改时间: 7 个月前