-
Notifications
You must be signed in to change notification settings - Fork 23
/
notify.php
executable file
·48 lines (43 loc) · 1.69 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
<?php
/*
* @Author: yumusb
* @Date: 2019-08-19 17:50:15
* @LastEditors: yumusb
* @LastEditTime: 2019-08-19 17:50:18
* @Description:
*/
error_reporting(0);
require_once './f2fpay/model/builder/AopClient.php';
require_once './config.php';
if (isset($_GET['check'])) {
exit("notify is OK");
}
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
$aop = new AopClient;
$aop->alipayrsaPublicKey = $alipay_config['alipay_public_key'];
$flag = $aop->rsaCheckV1($_POST, NULL, "RSA2");
if ($flag) {
echo 'success'; //接口必须返回success 不然阿里会一直发送校验验证。
//异步SIGN验证成功, 可以进行下一步动作。例如验证订单金额 然后完成订单。之类的。。
//需要验证的就是 订单号 与 订单金额是否一致,验证成功 就可以对数据库中的订单进行操作了。
//TRADE_SUCCESS 对于当面付来说,已经到账了。详情可以看这里 https://www.cnblogs.com/tdalcn/p/5956690.html
if ($_POST['trade_status'] === "TRADE_SUCCESS") {
//订单处理模板
if (NeedTakeNote == "yes") {
$no = $_POST['out_trade_no'];
$mount = $_POST['total_amount'];
$trade_no = $_POST['trade_no'];
$notify_time = $_POST['notify_time'];
$buyer_logon_id = $_POST['buyer_logon_id'];
$tmp = $db->query("SELECT `status` FROM `{$table}` WHERE `order_no`= '{$no}' and `mount` = '{$mount}'");
$res = $tmp->fetch(PDO::FETCH_ASSOC)['status'];
if ($res == 2) {
$db->exec("UPDATE `{$table}` SET `notify_time`='{$notify_time}',`trade_no`='{$trade_no}',`buyer_logon_id`='{$buyer_logon_id}',`status`=1 WHERE `order_no`='{$no}' and `mount`='{$mount}'");
}
}
}
} else {
echo 'error';
}