-
Notifications
You must be signed in to change notification settings - Fork 675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
微信小程序支付签名错误 #206
Comments
你这个签名方式是从哪里来的呢?我看微信文档并没有说明需要 http_build_query并进行替换。 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=4_3 |
我是参考 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5 编写的,http_build_query和手写foreach效果一样的,替换是因为http_build_query会把prepay_id=编码为prepay_id%3D 导致签名前的字符串有误。 |
这个与我参考的文档是一致。 |
我只用小程序支付,其它的没试过。 |
目前我这里并不能复现(不知道是否跟我用的测试账号有关系);我会持续关注这个问题 |
你好,反馈一下,最新版5.x的微信小程序支付签名算法有误。
最多5个参数,参与签名算法。我用以下代码通过测试。
//签名要自己做,集成的SDK 5.x有BUG
$param = [
'appId' => $this->wxconfig['app_id'],
'nonceStr' => $ret['nonce_str'],
'package' => 'prepay_id=' . $ret['prepay_id'],
'signType' => $this->wxconfig['sign_type'],
'timeStamp' => TIMENOW,
];
$signStr = http_build_query($param, PHP_QUERY_RFC3986, '&');
$signStr = str_replace('%3D', '=', $signStr);
$signStr .= '&key=' . $this->wxconfig['md5_key'];
$sign = strtoupper(hash_hmac('sha256', $signStr, $this->wxconfig['md5_key']));
The text was updated successfully, but these errors were encountered: