鍍金池/ 問答/PHP  網(wǎng)絡(luò)營銷  HTML/ 微信支付統(tǒng)一下單接口簽名錯誤

微信支付統(tǒng)一下單接口簽名錯誤

微信的統(tǒng)一下單接口總是報簽名錯誤!
我用微信官方的簽名驗證獲得的簽名結(jié)果是一樣的,請問有什么好方法能驗證簽名錯誤是由什么導(dǎo)致的么?

下面是我調(diào)用接口傳的xml:

<xml>
    <mch_id>1423xxxxxxx7402</mch_id>
    <nonce_str><![CDATA[5b6fc9879716a]]></nonce_str>
    <body><![CDATA[deal]]></body>
    <out_trade_no><![CDATA[SN2018081213435352966711]]></out_trade_no>
    <total_fee>20000</total_fee>
    <notify_url><![CDATA[http://xxx.com/api/payment/notify]]></notify_url>
    <trade_type><![CDATA[JSAPI]]></trade_type>
    <openid><![CDATA[oV8-KxxxxxxYuARnthpFiQec]]></openid>
    <spbill_create_ip><![CDATA[36.xx.xxx.252]]></spbill_create_ip>
    <appid><![CDATA[wxxxxxxxe73053]]></appid>
    <sign><![CDATA[0400701EF7F990D9652BBxxE5E8D8ACB]]></sign>
</xml>

{
    "mch_id": 1423xxxxxxx7402,
    "nonce_str": "5b6fc9879716a",
    "body": "deal",
    "out_trade_no": "SN2018081213435352966711",
    "total_fee": 20000,
    "notify_url": "http://xxx.com/api/payment/notify",
    "trade_type": "JSAPI",
    "openid": "oV8-KxxxxxxYuARnthpFiQec",
    "spbill_create_ip": "36.xx.xxx.252",
    "appid": "wxxxxxxxe73053",
    "sign": "0400701EF7F990D9652BBxxE5E8D8ACB"
}
回答
編輯回答
墨沫

驗證過簽名一致那么你的算法就沒錯。接下來驗證一下輸入信息。
可能出錯的地方:

  1. 一個公眾號可能對應(yīng)多個商戶號,檢查是否一致。
  2. 前后端使用的參數(shù)名大小寫是否一致,順序可以不同。
  3. 微信那邊有莫名的緩存,多刷新試試。
2017年6月17日 21:11