chengkun
2025-04-30 6ab292fb7415be124651e312ec4f21c594568f17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
ini_set('date.timezone','Asia/Shanghai');
//error_reporting(E_ERROR);
 
require("Autoloader.php");
require_once(dirname(dirname(dirname(__FILE__)))."/global.php");
 
require_once(dirname(dirname(dirname(__FILE__)))."/api/baiduPay/baiduPay.php");
 
$dingdan           =  $_POST['tpOrderId'];        //获取百度传递过来的订单号
$totalMoney        =  $_POST['totalMoney'];        //获取百度传递过来的总价格
 
// 生成签名时不需要rsaSign参数,验证签名时需要sign参数(验证签名需要将传过来的rsaSign和生成的签名进行对比验证)
$requestParamsArr  =  $_POST;
unset($requestParamsArr['rsaSign']);
$requestParamsArr['sign'] = $_POST['rsaSign'];
//验证签名
$checkSignRes = checkSign($requestParamsArr);
 
if ($checkSignRes){
    
    if ($_POST['status'] == 2){
        
        require_once(APP_PATH.'app/public/common.php');
        require_once(LIB_PATH.'ApiPay.class.php');
        
        $apiPay = new apipay($phpyun,$db,$db_config['def'],'index');
        
        $payType = 'baidu';
        
        if ($_POST['payType'] == '1087'){
            $payType = 'alipay';
        }elseif ($_POST['payType'] == '1117'){
            $payType = 'wxpay';
        }elseif ($_POST['payType'] == '10004'){
            $payType = 'baidu';
        }
        
        $return = $apiPay->payAll($dingdan,$totalMoney,$payType);
        if ($return == 2){
            
            $result  =  array('errno'=>0,'msg'=>'success','data'=>array('isConsumed'=>2));
            echo json_encode($result);die;
        }
    }
}
 
$result  =  array('errno'=>1,'msg'=>'fail');
echo json_encode($result);
 
 
 
// $string = ArrayToString($_POST);
 
// $receiveFile  =  dirname(dirname(dirname(__FILE__)))."/data/api/baidu/notify.txt";
// $fp = @fopen($receiveFile, "a");
 
// flock($fp, LOCK_EX);
// fputs($fp, $string.'||'.$qm."\r\n");
// fclose($fp);
?>