根据接口的参数,返回的信息验签失败,这个是什么原因,怎么解决呢
array(3) { ["code"]=> string(10) "SIGN_ERROR" ["detail"]=> array(4) { ["detail"]=> array(1) { ["issue"]=> string(14) "sign not match" } ["field"]=> string(9) "signature" ["location"]=> string(13) "authorization" ["sign_information"]=> array(4) { ["method"]=> string(4) "POST" ["sign_message_length"]=> int(347) ["truncated_sign_message"]=> string(83) "POST /v3/profitsharing/orders 1717411225 cbqHWbCQwe2OYXyHfacrfzRsDlIA52Ep {"appid" " ["url"]=> string(24) "/v3/profitsharing/orders" } } ["message"]=> string(30) "错误的签名,验签失败" }
https://pay.weixin.qq.com/doc/v3/merchant/4012365336
我在这个页面的第6步复制的请求签名串
POST\n 2/v3/pay/transactions/jsapi\n 31554208460\n 4593BEC0C930BF1AFEB40B4A08C8FB242\n 5{"appid":"wxd678efh567hg6787","mchid":"1230000109","description":"Image形象店-深圳腾大-QQ公仔","out_trade_no":"1217752501201407033233368018","notify_url":"https://www.weixin.qq.com/wxpay/pay.php","amount":{"total":100,"currency":"CNY"},"payer":{"openid":"oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"}}\n 原文得到的签名是 gEuexJ547PHFV77TQ6eiE4tphVYfWfUe1Wc2dBmVnoMYU2rl/M4zhw+b3vBhuMw6AC7pteNkryLA7UWU2h+umo0OdSuuLm1++O3NckQPCSfm6dypsjn4GYm84KMqXWFrhFmyxEwIdEJDr3w1UYfxOcu55OQupfLkrt/ZzuOspnliJFrPzGQFUk7lGqMMtpz3EfbDUNxnVsHblORg3hVmuYNmbGWnS2ovU30Y2Q+iKFDxzkaXBk8LTy6HzvxizRo6Q+J4SVM7O0hKXfgo1QdI68kpzNULb3EVBXlhTyPUzhkHzzLxECL1qHl3HH2hEv8++C+4wBlsagF3j/O6PABojA==
证书是按原文提供的保存为 apiclient_test_key.pem
我得到的签名是
Ukjdr5n6tVu/TP+/cw7s5zkh4B+zL7awjq8YzKsdquJb+XlHhbwgvSdnjstP18NrKtp8JCw1JZ187D6OtXofQUbdnM2JhDI9wH9qOSAfvMY2SrU8RkLwZpfEFLAsfMZSFis59EjmzF1ByKmRyFQeFM/YJtpw3Pq32b15ITh2kPFJuYXQ+V5jbODOslGUU0OUY7vcKpfvOWYr4z8ewq+dq4ylLoO6Pzs3txflmZvKx2Ilafv8rIxXAfYgJPIKtnWyUBRuqylw/Jwy6rWOkjPDd07M+/z3w79mZ4C7/H7awdWoBE7m0N8Enu4zJ6A+p4FqXusmMGFgjswIz0443DZadA==
证书签名工具是这个页面下载的:https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay6_0.shtml
1. 使用验签工具生成签名值时,换行符
\n
在验签工具中会被识别为字符串而不是一个换行,这时需要去手动使用空格换行(这时需要去手动使用空格换行)是把/n替换为空格,还是替换为回车,或者空格加回车都试过了,都和原文提供的签名不同
看起来很简单,搞了3天啊,3天啊,3天啊,懵逼的官方教程
https://wx.yunyougongchang.com/qm.php 这个是我调试的页面,签名错误,请检查后再试,实在检查不出来啊
我是认证的服务号,想要实现在微信里打开网页进行下单,支付,哪位大神有PHP的DEMO给个
排查指引错误根据文档排查下先:https://developers.weixin.qq.com/community/develop/article/doc/0004eae4f94c981f6c101ba7e6d813配合签名验证工具https://pay.weixin.qq.com/docs/merchant/sdk-tools/signature-verification-tool.html进行排查一下
如果有使用sdk的话 会自动签名验签。签名错误的话 检查下对应的参数。注意商户号和商户api证书对应。
建议直接用sdkhttps://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay6_0.shtml