-
Notifications
You must be signed in to change notification settings - Fork 4
/
notify.php
53 lines (51 loc) · 1.8 KB
/
notify.php
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
<?php
if(!defined('IN_PLUGIN'))exit();
require_once(PAY_ROOT."inc/yuansfer.config.php");
$url = 'https://mapi.yuansfer.com/app-data-search/v3/tran-query';
$params = array(
'merchantNo' => $alipay_config['merchantNo'],
'storeNo' => $alipay_config['storeNo'],
'reference' => TRADE_NO
);
ksort($params, SORT_STRING);
$str = '';
foreach ($params as $k => $v) {
$str .= $k . '=' . $v . '&';
}
$params['verifySign'] = md5($str . md5($alipay_config['key']));
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params),
));
$result = curl_exec($ch);
curl_exec($ch);
$result_json = json_decode($result, true);
$final_result = $result_json['result'];
if($result_json['ret_code'] == "000100")
{
if($final_result['status'] == "success")
{
$trade_no = $final_result['transactionNo'];
if($order['status']==0){
if($DB->exec("update `pre_order` set `status` ='1' where `trade_no`='".TRADE_NO."'")){
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no',`endtime` ='$date',`date`=NOW() where `trade_no`='".TRADE_NO."'");
processOrder($order);
}
}elseif(empty($order['api_trade_no'])){
$DB->exec("update `pre_order` set `api_trade_no` ='$trade_no' where `trade_no`='".TRADE_NO."'");
}
echo 'success';
}
else
{
echo 'fail';
}
}
else
{
echo 'fail';
}
?>