Commit 2fdca42c by 冷斌

fix bug

parent 2a761bff
...@@ -93,24 +93,6 @@ class Api_Charge extends PhalApi_Api { ...@@ -93,24 +93,6 @@ class Api_Charge extends PhalApi_Api {
$rs['msg'] = '微信未配置'; $rs['msg'] = '微信未配置';
return $rs; return $rs;
} }
$wx_config = [
'appid' => 'wxa6bcebff7f4c5a3f',
'appSecret' => '4b7d6cd67fc566659fd1d9bd399dbcba',
'mch_id' => '1582052881',
'key' => 'XCthxXszMdXiybUZnJBxyVgyVnV4zPuQ',
'notify_url' => 'http://www.seals-live.com/index.php?g=Appapi&m=pay&a=notify_wx',
'log' => [ // optional
'file' => dirname(dirname(dirname(__DIR__))) . '/wechat.log',
'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
'type' => 'single', // optional, 可选 daily.
'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
],
];
// require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
$wx = \Yansongda\Pay\Pay::wechat($wx_config);
var_dump($wx_config, $wx);
die;
$orderinfo=array( $orderinfo=array(
"uid"=>$uid, "uid"=>$uid,
...@@ -137,64 +119,79 @@ class Api_Charge extends PhalApi_Api { ...@@ -137,64 +119,79 @@ class Api_Charge extends PhalApi_Api {
} }
$noceStr = md5(rand(100,1000).time());//获取随机字符串 // $noceStr = md5(rand(100,1000).time());//获取随机字符串
$time = time(); // $time = time();
// $paramarr = array(
$paramarr = array( // "appid" => $configpri['wx_appid'],
"appid" => $configpri['wx_appid'], // "body" => "充值{$coin}虚拟币",
"body" => "充值{$coin}虚拟币", // "mch_id" => $configpri['wx_mchid'],
"mch_id" => $configpri['wx_mchid'], // "nonce_str" => $noceStr,
"nonce_str" => $noceStr, //// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx', // "notify_url" => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx',
"notify_url" => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx', // "out_trade_no"=> $orderid,
"out_trade_no"=> $orderid, // "total_fee" => $money*100,
"total_fee" => $money*100, // "trade_type" => "APP"
"trade_type" => "APP" // );
); // $sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名
$sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名 // $paramarr['sign'] = $sign;
$paramarr['sign'] = $sign; // $paramXml = "<xml>";
$paramXml = "<xml>"; // foreach($paramarr as $k => $v){
foreach($paramarr as $k => $v){ // $paramXml .= "<" . $k . ">" . $v . "</" . $k . ">";
$paramXml .= "<" . $k . ">" . $v . "</" . $k . ">"; // }
} // $paramXml .= "</xml>";
$paramXml .= "</xml>"; //
// $ch = curl_init ();
$ch = curl_init (); // @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 // @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在 // @curl_setopt($ch, CURLOPT_URL, "https://api.mch.weixin.qq.com/pay/unifiedorder");
@curl_setopt($ch, CURLOPT_URL, "https://api.mch.weixin.qq.com/pay/unifiedorder"); // @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // @curl_setopt($ch, CURLOPT_POST, 1);
@curl_setopt($ch, CURLOPT_POST, 1); // @curl_setopt($ch, CURLOPT_POSTFIELDS, $paramXml);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $paramXml); // @$resultXmlStr = curl_exec($ch);
@$resultXmlStr = curl_exec($ch); // if(curl_errno($ch)){
if(curl_errno($ch)){ // //print curl_error($ch);
//print curl_error($ch); // file_put_contents('./wxpay.txt',date('y-m-d H:i:s').' 提交参数信息 ch:'.json_encode(curl_error($ch))."\r\n",FILE_APPEND);
file_put_contents('./wxpay.txt',date('y-m-d H:i:s').' 提交参数信息 ch:'.json_encode(curl_error($ch))."\r\n",FILE_APPEND); // }
} // curl_close($ch);
curl_close($ch); //
// $result2 = $this->xmlToArray($resultXmlStr);
//
// if($result2['return_code']=='FAIL'){
// $rs['code']=1005;
// $rs['msg']=$result2['return_msg'];
// return $rs;
// }
// $time2 = time();
// $prepayid = $result2['prepay_id'];
// $sign = "";
// $noceStr = md5(rand(100,1000).time());//获取随机字符串
// $paramarr2 = array(
// "appid" => $configpri['wx_appid'],
// "noncestr" => $noceStr,
// "package" => "Sign=WXPay",
// "partnerid" => $configpri['wx_mchid'],
// "prepayid" => $prepayid,
// "timestamp" => $time2
// );
// $paramarr2["sign"] = $this -> sign($paramarr2,$configpri['wx_key']);//生成签名
// $rs['info'][0]=$paramarr2;
$result2 = $this->xmlToArray($resultXmlStr); $wx_config = [
'wechat' => [
'appid' => 'wxa6bcebff7f4c5a3f',
'appSecret' => '4b7d6cd67fc566659fd1d9bd399dbcba',
'mch_id' => '1582052881',
'key' => 'XCthxXszMdXiybUZnJBxyVgyVnV4zPuQ',
'notify_url' => 'http://www.seals-live.com/index.php?g=Appapi&m=pay&a=notify_wx',
]
];
if($result2['return_code']=='FAIL'){ require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
$rs['code']=1005; $wx = new \Yansongda\Pay\Pay($wx_config);
$rs['msg']=$result2['return_msg'];
return $rs;
}
$time2 = time();
$prepayid = $result2['prepay_id'];
$sign = "";
$noceStr = md5(rand(100,1000).time());//获取随机字符串
$paramarr2 = array(
"appid" => $configpri['wx_appid'],
"noncestr" => $noceStr,
"package" => "Sign=WXPay",
"partnerid" => $configpri['wx_mchid'],
"prepayid" => $prepayid,
"timestamp" => $time2
);
$paramarr2["sign"] = $this -> sign($paramarr2,$configpri['wx_key']);//生成签名
$rs['info'][0]=$paramarr2; $data = $wx->app($orderid);
$rs['info'][0]=json_decode($data, true);
return $rs; return $rs;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment