forked from yumusb/alipay-f2fpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.php
executable file
·43 lines (34 loc) · 1.4 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
43
<?php
/**
* Created by PhpStorm.
* User: airwalk
* Date: 16/5/20
* Time: 下午7:54
*/
header("Content-type: text/html; charset=utf-8");
if($_SERVER['REQUEST_METHOD']!='POST'){
exit();
}
//require_once './f2fpay/service/AlipayTradeService.php';
require_once './common.php';
$out_trade_no = trim($_POST['no']);
////获取商户订单号
/* 以下是直接使用官方接口查询订单是否完成的逻辑,不过当我们在notify中完成了订单,就可以本地查询啦。
//构造查询业务请求参数对象
$queryContentBuilder = new AlipayTradeQueryContentBuilder();
$queryContentBuilder->setOutTradeNo($out_trade_no);
//初始化类对象,调用queryTradeResult方法获取查询应答
$queryResponse = new AlipayTradeService($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));
*/
$tmp = $db->prepare("SELECT `status` FROM `{$table}` where `id` = ? limit 10");
//先prepare一下我们需要执行的SQL语句,其中需要安全处理的参数是以`?`占位的
$tmp->execute(array($out_trade_no));
//执行prepare的execute方法,并把参数以数组方式传入
$res = $tmp->fetch(PDO::FETCH_ASSOC);
exit(json_encode($res));