遇到了同样的问题 楼主解决了吗
微信小程序虚拟支付对接报签名错误?参考文档:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html 调用接口: https://api.weixin.qq.com/xpay/query_user_balance?access_token=71_n_O9fO__O0bLuVr-kjIgNXmxHmsOU7fURFSpfTTRvYp7tReFzt4bDrGEqNgGFpCZfnbaZMAaOneDFfTOh_Il9QtRkpOlZxmGNlgWjSnSbdmNb0nX8Wwx27LLfYoYMGcABANBV&pay_sig=ef671bb980a4de54f6f6a93f54165701aad5ba4835b4d117f52381d6ca07df4f&signature=96fb3d84dc5d09a7accb2df460a8cb934ed5ad863d99c37f83907e8065989608 请求参数: {"openid":"oSOB25Id4x-dMBmicDnvEPycdMnM","user_ip":"127.0.0.1","env":1} php生成签名的方法(对标上面文档中提供的python脚本改写): /** * pay_sig签名算法计算示例 * @param $uri * @param $postBody * @param $appKey * @return string */ public function calcPaySig($uri, $postBody, $appKey): string { $needSignMsg = $uri . '&' . $postBody; return bin2hex(hash_hmac('sha256', $needSignMsg, $appKey, true)); } /** * 用户登录态signature签名算法 * @param $postBody * @param $sessionKey * @return string */ public function calcSignature($postBody, $sessionKey) { return bin2hex(hash_hmac('sha256', $postBody, $sessionKey, true)); } 返回错误: {"errcode":268490003,"errmsg":"签名校验失败 rid: 64ca5e2f-6884c3cf-184aa397"}
2023-08-16