forked from yumusb/alipay-f2fpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.php
73 lines (67 loc) · 2.58 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @Author: yumu
* @Date: 2019-08-02
* @Email: [email protected]
* @Last Modified by: yumu
* @Last Modified time: 2019-08-05
*/
/*以下是POST接收到数据的DEMO
// gmt_create=2019-08-05+10:21:45
// charset=UTF-8
// seller_email=1231xxxx1312 卖家账号
// subject=ceshi
// sign=P 签名
// buyer_id=208881 付款账户ID
// invoice_amount=0.01 可开发票金额
// notify_id=2019080
// fund_bill_list=[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]
// notify_type=trade_status_sync
// trade_status=TRADE_SUCCESS
// receipt_amount=0.01 实收金额
// buyer_pay_amount=0.01 付款金额
// app_id=20190
// sign_type=RSA2
// seller_id=208812
// gmt_payment=2019-08-05+10:21:56
// notify_time=2019-08-05+10:21:56
// version=1.0
// out_trade_no=f613aa0c955 //本地订单号
// total_amount=0.01 订单总金额
// trade_no=201908052200 //支付宝订单号。
// auth_app_id=2019080166007675
// buyer_logon_id=pay** 付款账号
// point_amount=0.00 集分宝金额
//
*/
error_reporting(0);
require_once './aop/AopClient.php';
require_once './config.php';
require_once './common.php';
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
$aop = new AopClient;
$aop->alipayrsaPublicKey = $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") {
$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 `id`= '{$no}' and `mount` = '{$mount}'");
$res = $tmp->fetch(PDO::FETCH_ASSOC)['status'];
if ($res === "nopay") {
//file_put_contents("txt.txt","UPDATE `{$table}` SET `notify_time`='{$notify_time}',`trade_no`='{$trade_no}',`buyer_logon_id`='{$buyer_logon_id}',`status`='success' WHERE `id`='{$no}',`mount`='{$mount}'");
$db->exec("UPDATE `{$table}` SET `notify_time`='{$notify_time}',`trade_no`='{$trade_no}',`buyer_logon_id`='{$buyer_logon_id}',`status`='success' WHERE `id`='{$no}' and `mount`='{$mount}'");
}
}
} else {
echo 'error';
}