微信浏览器H5中chooseWXPay调用报错签名认证失败

公众号H5中使用微信支付报错签名认证失败

环境描述

  • 后台使用的是jsAPI支付,使用的是V2
  • 前端是将H5跟公众号(服务号)相关联,必须使用服务号,订阅号没有权限

用户授权登录H5

const appId = 'XXXXXX'; // 使用自己公众号appid
const currentUrl = window.location.href; 
const redirectUri = encodeURIComponent(currentUrl);
const authUrl =`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
window.location.replace(authUrl);// 进行重定向获取code
const code = urlParams.get('code'); // 重定向回来检查URL中的code
const res = await getUserInfo(code) // 调用后端接口获取用户的信息,最重要的是公众号的openid

进行jsAPI授权

/**
* 加载微信JSSDK
 */
loadWxJSSDK() {
    let script = document.create
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值