微信支付- 客户端提示签名错误!求大佬救急

微信支付- 客户端提示签名错误!


但是后台的数据,在签名工具里检验是正确的。



1前端代码第一步用户 点击获取 code 传去去后台得openid

//getQueryString方法获取url参数的值 并且提取 code值

function getQueryString(name) {

var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");

var r = window.location.search.substr(1).match(reg);

if(r != null) return unescape(r[2]);

return null;

}

var code = getQueryString("code");

//获取openid

$.ajax({

type: 'GET',

url: "",

dataType: 'json',

data: {

code: code

},

success: function(data) {},

error: function(error) {

alert("error");

}

});



2



var paySign="";

var appId="";

var timeStamp="";

var nonceStr="";

var packageStr="";

var signType="MD5";

//后台请求数据

function xmlDate(couId,WIDtotal_fee,phone){

var result =false;

//声明一些变量

$.ajax({

type: 'GET',

url: "/alipay/wxPayGzh",

dataType: 'json',

data: {

couId:couId,

WIDtotal_fee:WIDtotal_fee,

phone:phone

},

async: false,

success: function(data) {

appId=data.xmlStr.appid;

paySign=data.xmlStr.sign;

timeStamp=data.timeStamp;

nonceStr=data.xmlStr.nonce_str;

packageStr="prepay_id="+data.xmlStr.prepay_id;

signType="MD5";

result=true;

},

error: function(error) {

alert("error");

}

});

alert("aaa"+appId);

return result;

/*appId = data.xmlStr.appid;

timeStamp = data.timeStamp;

nonceStr = data.xmlStr.nonce_str;

packageStr = "prepay_id="+data.xmlStr.prepay_id;

signType = "MD5";

paySign = data.xmlStr.sign;*/

}

function onBridgeReady() {

WeixinJSBridge.invoke(

'getBrandWCPayRequest', {

"appId": appId, //公众号名称,由商户传入

"timeStamp": timeStamp, //时间戳,自1970年以来的秒数

"nonceStr": nonceStr, //随机串

"package": packageStr,

"signType": "MD5", //微信签名方式:

"paySign": paySign //微信签名

},

function(res) {

if(res.err_msg == "get_brand_wcpay_request:ok") {

alert("交易成功");

window.location.href = "success.html";

}

if(res.err_msg == "get_brand_wcpay_request:cancel") {

alert("交易取消");

window.location.href = "/index.html";

}

if(res.err_msg == "get_brand_wcpay_request:fail") {

alert("支付失败");

window.location.href = "/test/index.html";

}

}

);

}

//判断支付

function callpay() {

if(typeof WeixinJSBridge == "undefined") {

if(document.addEventListener) {

document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);

} else if(document.attachEvent) {

document.attachEvent('WeixinJSBridgeReady', onBridgeReady);

document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);

}

} else {

onBridgeReady();

}

}

你可能感兴趣的:(微信支付- 客户端提示签名错误!求大佬救急)