|
@@ -16,9 +16,9 @@ $data=[
|
|
$statement=$pdo->prepare("insert into recharge(`user_id`,`price`,`phone`,`order_sn`,`created_at`,`updated_at`) values(?,?,?,?,?,?)");
|
|
$statement=$pdo->prepare("insert into recharge(`user_id`,`price`,`phone`,`order_sn`,`created_at`,`updated_at`) values(?,?,?,?,?,?)");
|
|
$res=$statement->execute(array_values($data));
|
|
$res=$statement->execute(array_values($data));
|
|
if(!$res)exit(json_encode(['code'=>0,"msg"=>"创建订单失败"]));
|
|
if(!$res)exit(json_encode(['code'=>0,"msg"=>"创建订单失败"]));
|
|
|
|
+$id=$pdo->lastInsertId();
|
|
$url = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
|
|
$url = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
|
|
$url .= "://" . $_SERVER['HTTP_HOST'];
|
|
$url .= "://" . $_SERVER['HTTP_HOST'];
|
|
-$url .= $_SERVER['REQUEST_URI'];
|
|
|
|
|
|
|
|
$request_data=[
|
|
$request_data=[
|
|
"mch_id"=>"tongue",
|
|
"mch_id"=>"tongue",
|
|
@@ -29,25 +29,50 @@ $request_data=[
|
|
"goods_desc"=>"测试",
|
|
"goods_desc"=>"测试",
|
|
"client_ip"=>$_SERVER['REMOTE_ADDR']??"127.0.0.1",
|
|
"client_ip"=>$_SERVER['REMOTE_ADDR']??"127.0.0.1",
|
|
"format"=>"json",
|
|
"format"=>"json",
|
|
- "notify_url"=>"http://test.com",
|
|
|
|
|
|
+ "notify_url"=>$url."/notify",
|
|
"pay_backurl"=>$url,
|
|
"pay_backurl"=>$url,
|
|
"time"=>time(),
|
|
"time"=>time(),
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+
|
|
ksort($request_data);
|
|
ksort($request_data);
|
|
$request_data['key']="37cd2d09c84f6ff7f1d28960ef82c4e533a3c047";
|
|
$request_data['key']="37cd2d09c84f6ff7f1d28960ef82c4e533a3c047";
|
|
$request_data['sign']=md5(urldecode(http_build_query($request_data)));
|
|
$request_data['sign']=md5(urldecode(http_build_query($request_data)));
|
|
|
|
|
|
-//unset($request_data['key']);
|
|
|
|
-//echo "<pre>";
|
|
|
|
-//var_dump(http_build_query($request_data));
|
|
|
|
-//var_dump($request_data);
|
|
|
|
-//echo "</pre>";
|
|
|
|
-//exit();
|
|
|
|
-$res=curl_request("http://47.236.143.199/?c=Pay",$request_data,"post",array("content-type: application/json"),false);
|
|
|
|
|
|
+unset($request_data['key']);
|
|
|
|
+echo "<pre>";
|
|
|
|
+var_dump(http_build_query($request_data));
|
|
|
|
+var_dump($request_data);
|
|
|
|
+echo "</pre>";
|
|
|
|
+exit();
|
|
|
|
+
|
|
|
|
+//正式环境打开
|
|
|
|
+/*file_put_contents(date("Y-m-d").'pay.log',date("H:i:s")."请求:".http_build_query($request_data)."\r\n",FILE_APPEND);
|
|
|
|
+$res=curl_request("http://47.236.143.199/?c=Pay&".http_build_query($request_data),array(),"get",array("content-type: text/html"),false);
|
|
$res=json_decode($res,true);
|
|
$res=json_decode($res,true);
|
|
-file_put_contents(date("Y-m-d").'pay.log',date("H:i:s").json_encode($res)."\r\n",FILE_APPEND);
|
|
|
|
|
|
+file_put_contents(date("Y-m-d").'pay.log',date("H:i:s")."响应".json_encode($res)."\r\n",FILE_APPEND);*/
|
|
|
|
+$res=json_decode('{
|
|
|
|
+"code": "1",
|
|
|
|
+"msg": "下单成功",
|
|
|
|
+"data": {
|
|
|
|
+"order_sn": "ZZHF20240126183436808",
|
|
|
|
+"ptype": "82",
|
|
|
|
+"ptype_name": "",
|
|
|
|
+"realname": null,
|
|
|
|
+"account": null,
|
|
|
|
+"money": "30",
|
|
|
|
+"bank": "",
|
|
|
|
+"branch_name": "",
|
|
|
|
+"qrcode": "https://hh5ad.hnapay.com/pay/order.shtml?orderId=2024012676093324&orderKey=e7e1e69242a234c3e766438b507b70a6f7b6cd2a"
|
|
|
|
+}
|
|
|
|
+}',true);
|
|
if($res['code']!=1)exit(json_encode(['code'=>0,"msg"=>"下单失败"]));
|
|
if($res['code']!=1)exit(json_encode(['code'=>0,"msg"=>"下单失败"]));
|
|
|
|
+$statement=$pdo->exec("update recharge set `app_order_sn`='{$res['data']['order_sn']}' where id={$id}");
|
|
|
|
+
|
|
|
|
+exit(json_encode(['code'=>1,'msg'=>'success',"data"=>['pay_url'=>$res['data']['qrcode']]]));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
//exit(json_encode(['code'=>1,"msg"=>"","data"=>[
|
|
//exit(json_encode(['code'=>1,"msg"=>"","data"=>[
|
|
// "pay_url"=>$res['']
|
|
// "pay_url"=>$res['']
|
|
//]]));
|
|
//]]));
|