Commit 1172412b by 冷斌

fix bug

parent 8a5db478
<?php
class Api_Charge extends PhalApi_Api {
public function getRules() {
......@@ -47,17 +48,6 @@ class Api_Charge extends PhalApi_Api {
return $orderid;
}
protected function getWx($configpri, $configpub)
{
return Yansongda\Pay\Pay::wechat([
'appid' => $configpri['wx_appid'],
'appSecret' => $configpri['wx_appsecret'],
'mch_id' => $configpri['wx_mchid'],
'key' => $configpri['wx_key'],
'notify_url' => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx',
]);
}
/**
* 微信支付
* @desc 用于 微信支付 获取订单号
......@@ -119,87 +109,64 @@ class Api_Charge extends PhalApi_Api {
}
// $noceStr = md5(rand(100,1000).time());//获取随机字符串
// $time = time();
// $paramarr = array(
// "appid" => $configpri['wx_appid'],
// "body" => "充值{$coin}虚拟币",
// "mch_id" => $configpri['wx_mchid'],
// "nonce_str" => $noceStr,
//// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
// "notify_url" => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx',
// "out_trade_no"=> $orderid,
// "total_fee" => $money*100,
// "trade_type" => "APP"
// );
// $sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名
// $paramarr['sign'] = $sign;
// $paramXml = "<xml>";
// foreach($paramarr as $k => $v){
// $paramXml .= "<" . $k . ">" . $v . "</" . $k . ">";
// }
// $paramXml .= "</xml>";
//
// $ch = curl_init ();
// @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
// @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_RETURNTRANSFER, true);
// @curl_setopt($ch, CURLOPT_POST, 1);
// @curl_setopt($ch, CURLOPT_POSTFIELDS, $paramXml);
// @$resultXmlStr = curl_exec($ch);
// if(curl_errno($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);
// }
// 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;
require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
$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',
]
];
ini_set("display_errors", On);
ini_set("error_reporting", E_ALL);
$wx = new \Yansongda\Pay\Pay($wx_config);
$data = $wx->driver('wechat')->gateway('app')->pay([
'out_trade_no' => $orderid,
$noceStr = md5(rand(100,1000).time());//获取随机字符串
$time = time();
$paramarr = array(
"appid" => $configpri['wx_appid'],
"body" => "充值{$coin}虚拟币",
"mch_id" => $configpri['wx_mchid'],
"nonce_str" => $noceStr,
// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
"notify_url" => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx',
"out_trade_no"=> $orderid,
"total_fee" => $money*100,
"spbill_create_ip" => $_SERVER["REMOTE_ADDR"]
]);
var_dump($wx_config, $data);
die;
$rs['info'][0]=json_decode($data, true);
"trade_type" => "APP"
);
$sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名
$paramarr['sign'] = $sign;
$paramXml = "<xml>";
foreach($paramarr as $k => $v){
$paramXml .= "<" . $k . ">" . $v . "</" . $k . ">";
}
$paramXml .= "</xml>";
$ch = curl_init ();
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@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_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_POST, 1);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $paramXml);
@$resultXmlStr = curl_exec($ch);
if(curl_errno($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);
}
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;
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