小程序
小游戏
企业微信
微信支付
扫描小程序码分享
测试环境沙盒支付报错 请确认请求参数是否正确param mch_id invalid
签名计算方法与正式环境一样,正式请求没问题,沙箱环境就报错。
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
以下是亲测(脱敏)信息,供参考,命令行可见:真香:一行命令即可体验「微信支付」全系接口能力
./node_modules/.bin/wxpay v2.pay.getsignkey \ -u 'https://api.mch.weixin.qq.com/sandboxnew/' \ -c.mchid 136****302 \ -c.secret 4b2b8**********************8e35d \ -c.serial any \ -c.privateKey any \ -c.certs.any \ -d.mch_id 136****302 \ -d.nonce_str 5K8264ILTKCH16CQ2502SI8ZNMTM67VS { config: { url: 'pay/getsignkey', method: 'post', data: '<xml><mch_id>136****302</mch_id><nonce_str>5K8264ILTKCH16CQ2502SI8ZNMTM67VS</nonce_str><sign>817F6C6313F5C9D9604E2A3A42F1C180</sign></xml>', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'text/xml; charset=utf-8', 'User-Agent': 'wechatpay-axios-plugin/0.5.4 axios/0.21.1 node/14.16.1 darwin/x64', 'Content-Length': 138 }, baseURL: 'https://api.mch.weixin.qq.com/sandboxnew/', transformRequest: [ [Function: signer], [Function: toXml] ], transformResponse: [ [Function: toObject], [Function: verifier] ], timeout: 0, adapter: [Function: httpAdapter], responseType: 'text', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, httpsAgent: Agent { _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object], requests: {}, sockets: {}, freeSockets: [Object], keepAliveMsecs: 1000, keepAlive: true, maxSockets: Infinity, maxFreeSockets: 256, scheduling: 'fifo', maxTotalSockets: Infinity, totalSocketCount: 0, maxCachedSessions: 100, _sessionCache: [Object], [Symbol(kCapture)]: false }, validateStatus: [Function: validateStatus], mchid: 136****302, secret: '4b2b8**********************8e35d', serial: 'any', privateKey: 'any', certs: { any: true } }, headers: { server: 'nginx', date: 'Mon, 12 Apr 2021 06:51:02 GMT', 'content-type': 'text/plain;charset=utf-8', 'content-length': '185', connection: 'keep-alive', 'keep-alive': 'timeout=8', from: 'sandbox' }, data: { return_code: 'SUCCESS', return_msg: 'ok', sandbox_signkey: '4b2b85ef1****9d728a4****d248e35d' } }
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
参考了N遍,你能不能回答点有建设性的?
请帮忙看看SIGN生成方法是否正确?
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
以下是亲测(脱敏)信息,供参考,命令行可见:真香:一行命令即可体验「微信支付」全系接口能力
./node_modules/.bin/wxpay v2.pay.getsignkey \ -u 'https://api.mch.weixin.qq.com/sandboxnew/' \ -c.mchid 136****302 \ -c.secret 4b2b8**********************8e35d \ -c.serial any \ -c.privateKey any \ -c.certs.any \ -d.mch_id 136****302 \ -d.nonce_str 5K8264ILTKCH16CQ2502SI8ZNMTM67VS { config: { url: 'pay/getsignkey', method: 'post', data: '<xml><mch_id>136****302</mch_id><nonce_str>5K8264ILTKCH16CQ2502SI8ZNMTM67VS</nonce_str><sign>817F6C6313F5C9D9604E2A3A42F1C180</sign></xml>', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'text/xml; charset=utf-8', 'User-Agent': 'wechatpay-axios-plugin/0.5.4 axios/0.21.1 node/14.16.1 darwin/x64', 'Content-Length': 138 }, baseURL: 'https://api.mch.weixin.qq.com/sandboxnew/', transformRequest: [ [Function: signer], [Function: toXml] ], transformResponse: [ [Function: toObject], [Function: verifier] ], timeout: 0, adapter: [Function: httpAdapter], responseType: 'text', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, httpsAgent: Agent { _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object], requests: {}, sockets: {}, freeSockets: [Object], keepAliveMsecs: 1000, keepAlive: true, maxSockets: Infinity, maxFreeSockets: 256, scheduling: 'fifo', maxTotalSockets: Infinity, totalSocketCount: 0, maxCachedSessions: 100, _sessionCache: [Object], [Symbol(kCapture)]: false }, validateStatus: [Function: validateStatus], mchid: 136****302, secret: '4b2b8**********************8e35d', serial: 'any', privateKey: 'any', certs: { any: true } }, headers: { server: 'nginx', date: 'Mon, 12 Apr 2021 06:51:02 GMT', 'content-type': 'text/plain;charset=utf-8', 'content-length': '185', connection: 'keep-alive', 'keep-alive': 'timeout=8', from: 'sandbox' }, data: { return_code: 'SUCCESS', return_msg: 'ok', sandbox_signkey: '4b2b85ef1****9d728a4****d248e35d' } }
sign=MD5( mch_id=XXXXX&nonce_str=XXXXX&key=商户号key) 这样对么?
另外你源码中 “data: '<xml><mch_id>136****302</mch_id><nonce_str>5K8264ILTKCH16CQ2502SI8ZNMTM67VS</nonce_str><sign>817F6C6313F5C9D9604E2A3A42F1C180</sign></xml>',”
其中sign部分为什么没有 ![CDATA?难道我这部分有问题?
参考了N遍,你能不能回答点有建设性的?
请帮忙看看SIGN生成方法是否正确?