$data = [];
$data['amount'] = ['total'=>$info['money']*100,'currency'=>'CNY'];
$data['appid'] = $this->WXappid;
$data['attach'] = $info['number'];
$data['description'] = $house['name'].'('.$room['name'].') - '.$info['hours'].'小时';
$data['mchid'] = $this->mchid;
$data['notify_url'] = $this->LINK.'/api/orderReturn.html';
$data['payer'] = ['openid'=>$info['openid']];
$data['out_trade_no'] = $info['number'];
$json = json_encode($data);
$res = $this->sign_encode($json);
public function sign_encode($body = ''){
$nonce_str = $this->GetRandStr(32);
$timestamp = time();
$mchid = $this->mchid;
$serial_no = $this->serial_no;
$url = 'https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi';
$http_method = 'POST';
$url_parts = parse_url($url);
$canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
$mch_private_key = $this->getPrivateKey();
$message = $http_method."\n".$canonical_url."\n".$timestamp."\n".$nonce_str."\n".$body."\n";
openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
$sign = base64_encode($raw_sign);
$schema = 'WECHATPAY2-SHA256-RSA2048';
$token = sprintf('mchid="%s",nonce_str="%s",signature="%s",timestamp="%d",serial_no="%s"',$mchid, $nonce_str, $sign, $timestamp, $serial_no);
return $schema.' '.$token;
}
public function getPrivateKey() {
return openssl_get_privatekey(file_get_contents('./static/wechatkey/apiclient_key.pem'));
}
wx.request({
method:'POST',
url: 'https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi',
data:{
"amount":{"total":that.data.info.money*100,"currency":"CNY"},
"appid":"*****************",
"attach":that.data.info.number,
"description":that.data.house.name+"("+that.data.room.name+") - "+that.data.info.hours+"小时",
"mchid":"***********",
"notify_url":app.globalData.httpUrl+"/api/orderReturn.html",
"out_trade_no":that.data.info.number,
"payer":{"openid":that.data.userInfo.openid}
},
header: {
'content-type': 'application/json',
'Accept': 'application/json',
'Authorization': res.data.data
},
success (re) {
console.log(re);
},
error(er) {
console.log(er);
}
});
您好,您的问题建议您前往V3文档:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/index.shtml 点击右下角“技术咨询”实时寻求技术帮助。
微信支付是后台的东西,永远不会与wx.request发生任何毛钱的关系。
希望能得到回答,这个问题已经困扰我一宿了,我不想明天还被这个问题困扰