$orderNumber = time() . mt_rand(10000, 99999);
header("Content-type:text/html;charset=utf-8"); //此处进行字符集初始化,
$data = array(
'appid' => "wxc93a417e631993c6",
'body' => "电动车协会",
'mch_id' => "1638940549",
'nonce_str' => $orderNumber, //随机字符串
'notify_url' => "https://ps.qijizhixin.com/api/Pay/notify", //异步回调地址
'openid' => $openid, //用户登录时获取的code中含有的值
'out_trade_no' => $orderNumber, //商家订单号
'spbill_create_ip' => $_SERVER["REMOTE_ADDR"], //APP和网页支付提交用户端ip
'total_fee' => "1", //订单总额
'attach' => 'order', //确定是哪个商家进行的支付
'trade_type' => 'JSAPI',
'sign_type'=>'MD5' //交易类型
);
//将数组转化为Xml
$data['sign'] = $this->makeSign($data);
$abc_xml = $this->arrayToXml($data);
//统一下单接口prepay_id
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
$xml = $this->execute($url, $abc_xml, 1);
//将XMl转化为数组
$info = $this->xml2array($xml);
if (!isset($info['prepay_id'])) {
return $info;
}
$params = array(
'appId' => 'wxc93a417e631993c6',
'nonceStr' => $data['nonce_str'],
'package' => 'prepay_id=' . $info['prepay_id'],
'signType' => 'MD5',
'timeStamp' => '' . time(),
);
$_info['paySign'] = $this->makeSign($params);
$_info['timeStamp'] = "" . $params['timeStamp'];
$_info['nonceStr'] = $params['nonceStr'];
$_info['package'] = $params['package'];
$_info['signType'] = $params['signType'];
所以你在哪个地方报错的?调起支付?
掉起支付的时候,签名的时候多加一个换行就可以解决签名错误。
prepay_id 都能获取到。之前都是这么使用都能支付,现在不能支付了。