天天看點

微信支付——支付簽名驗證失敗的坑

隻講幾個微信支付開發中的簽名問題!(JAVA版的公衆号支付)

第一個是擷取訂單資料時生成,然後通過這些資料生成預支付訂單(通過 統一下單 方法取得),微信官方傳回一串xml資料,告訴你是否成功。

第二個是需要把資料傳給前端調起支付頁面的,(此處注意看文檔的字段,key值也要和他的一直,sign是取得簽名後再賦給map做paySign)——我是在此處犯錯

以下是支付頁面提示簽名錯誤的解決方法:

如果你是用官方的demo,就去修改WXPay.java ,注意如果是正式環境也用md5

public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport, final boolean useSandbox) throws Exception {

        this.config = config;

        this.notifyUrl = notifyUrl;

        this.autoReport = autoReport;

        this.useSandbox = useSandbox;

        if (useSandbox) {

            this.signType = SignType.MD5; // 沙箱環境

        }

        else {

            this.signType = SignType.MD5;//!!!此處原來不是MD5

        }

        this.wxPayRequest = new WXPayRequest(config);

    },

解決方法的位址:http://bbs.csdn.net/wap/topics/391882172?from=singlemessage&isappinstalled=0   的17樓評論

還有域名最好是經過備案的,還有一個證書要驗證