商家公众号的appid 和 实际支付参数中的appid不一致,使用wx.chooseWXPay发起支付提示“支付签名验证失败”,而使用window.WeixinJSBridge.invoke("getBrandWCPayRequest") 的方式则可以支付成功。
当前公众号appid为:wxd9f240a329f856e7
// 假设支付参数为:(⚠️ 注意此处appId和当前公众号的appId不一致
const params = {
"appId": "wx0c60bf339a4c52a6",
"nonceStr": "npmtwexve67ldxodc3",
"packExpand": "prepay_id=wx161603452738710cbf7844c961dd3d0000",
"payInfoStr": "{\"timeStamp\":\"1697443425367\",\"package\":\"prepay_id=wx161603452738710cbf7844c961dd3d0000\",\"paySign\":\"28AADCF7082BE1B9DC760D18B61A72C1\",\"appId\":\"wx0c60bf339a4c52a6\",\"signType\":\"MD5\",\"nonceStr\":\"npmtwexve67ldxodc3\"}",
"paySign": "28AADCF7082BE1B9DC760D18B61A72C1",
"signType": "MD5",
"timeStamp": "1697443425367"
}
// 支付失败,因为当前公众号的appid wxd9f240a329f856e7和生成支付参数的appid wx0c60bf339a4c52a6不一致
wx.chooseWXPay({
timestamp: params['timeStamp'],
nonceStr: params['nonceStr'],
package: params['packExpand'],
signType: params['signType'],
paySign: params['paySign'],
success: function (res) {}
})
// 可以支付成功,是因为主动传入了appId参数?
window.WeixinJSBridge.invoke("getBrandWCPayRequest",{
appId: params['appId'],
timeStamp: params['timeStamp'],
nonceStr: params['nonceStr'],
package: params['packExpand'],
signType: params['signType'],
paySign: params['paySign']
} , function (res) {
//
})
请问造成这种差异的原因是什么?以及官方是否限制了生成支付参数的appid必须和当前发起支付的公众号appid一致?