-
Notifications
You must be signed in to change notification settings - Fork 23
/
query.php
executable file
·42 lines (37 loc) · 1.42 KB
/
query.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
<?php
/*
* @Author: yumusb
* @Date: 2019-08-19 17:49:27
* @LastEditors: yumusb
* @LastEditTime: 2019-08-19 17:50:33
* @Description:
*/
header("Content-type: text/html; charset=utf-8");
error_reporting(0);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
require_once './f2fpay/service/AlipayTradeService.php';
$out_trade_no = trim($_POST['no']);
/*记录订单信息*/
if (NeedTakeNote == "yes") {
//通过查询本地订单
$tmp = $db->prepare("SELECT `status` FROM `{$table}` where `order_no` = ? limit 10");
//先prepare一下我们需要执行的SQL语句,其中需要安全处理的参数是以`?`占位的
$tmp->execute(array($out_trade_no));
//执行prepare的execute方法,并把参数以数组方式传入
$res = $tmp->fetch(PDO::FETCH_ASSOC);
if ($res['status'] == 1) {
$res['status'] = 'success';
}
exit(json_encode($res));
} elseif (NeedTakeNote == "no") {
$queryContentBuilder = new AlipayTradeQueryContentBuilder();
$queryContentBuilder->setOutTradeNo($out_trade_no);
$queryResponse = new AlipayTradeService($alipay_config);
$queryResult = $queryResponse->queryTradeResult($queryContentBuilder);
$res['status'] = $queryResult->getTradeStatus();
$res['buyer'] = $queryResult->getResponse()->buyer_logon_id;
$res['amount'] = $queryResult->getResponse()->buyer_pay_amount;
exit(json_encode($res));
}