query_test.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: airwalk
  5. * Date: 16/5/20
  6. * Time: 下午7:54
  7. */
  8. header("Content-type: text/html; charset=utf-8");
  9. require_once 'service/AlipayTradeService.php';
  10. if (!empty($_POST['out_trade_no'])&& trim($_POST['out_trade_no'])!=""){
  11. ////获取商户订单号
  12. $out_trade_no = trim($_POST['out_trade_no']);
  13. //第三方应用授权令牌,商户授权系统商开发模式下使用
  14. $appAuthToken = "";//根据真实值填写
  15. //构造查询业务请求参数对象
  16. $queryContentBuilder = new AlipayTradeQueryContentBuilder();
  17. $queryContentBuilder->setOutTradeNo($out_trade_no);
  18. $queryContentBuilder->setAppAuthToken($appAuthToken);
  19. //初始化类对象,调用queryTradeResult方法获取查询应答
  20. $queryResponse = new AlipayTradeService($config);
  21. $queryResult = $queryResponse->queryTradeResult($queryContentBuilder);
  22. //根据查询返回结果状态进行业务处理
  23. switch ($queryResult->getTradeStatus()){
  24. case "SUCCESS":
  25. echo "支付宝查询交易成功:"."<br>--------------------------<br>";
  26. print_r($queryResult->getResponse());
  27. break;
  28. case "FAILED":
  29. echo "支付宝查询交易失败或者交易已关闭!!!"."<br>--------------------------<br>";
  30. if(!empty($queryResult->getResponse())){
  31. print_r($queryResult->getResponse());
  32. }
  33. break;
  34. case "UNKNOWN":
  35. echo "系统异常,订单状态未知!!!"."<br>--------------------------<br>";
  36. if(!empty($queryResult->getResponse())){
  37. print_r($queryResult->getResponse());
  38. }
  39. break;
  40. default:
  41. echo "不支持的查询状态,交易返回异常!!!";
  42. break;
  43. }
  44. return ;
  45. }
  46. ?>
  47. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  48. <html>
  49. <head>
  50. <title>支付宝当面付 消费查询</title>
  51. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  52. <style>
  53. *{
  54. margin:0;
  55. padding:0;
  56. }
  57. ul,ol{
  58. list-style:none;
  59. }
  60. .title{
  61. color: #ADADAD;
  62. font-size: 14px;
  63. font-weight: bold;
  64. padding: 8px 16px 5px 10px;
  65. }
  66. .hidden{
  67. display:none;
  68. }
  69. .new-btn-login-sp{
  70. border:1px solid #D74C00;
  71. padding:1px;
  72. display:inline-block;
  73. }
  74. .new-btn-login{
  75. background-color: transparent;
  76. background-image: url("../img/new-btn-fixed.png");
  77. border: medium none;
  78. }
  79. .new-btn-login{
  80. background-position: 0 -198px;
  81. width: 82px;
  82. color: #FFFFFF;
  83. font-weight: bold;
  84. height: 28px;
  85. line-height: 28px;
  86. padding: 0 10px 3px;
  87. }
  88. .new-btn-login:hover{
  89. background-position: 0 -167px;
  90. width: 82px;
  91. color: #FFFFFF;
  92. font-weight: bold;
  93. height: 28px;
  94. line-height: 28px;
  95. padding: 0 10px 3px;
  96. }
  97. .bank-list{
  98. overflow:hidden;
  99. margin-top:5px;
  100. }
  101. .bank-list li{
  102. float:left;
  103. width:153px;
  104. margin-bottom:5px;
  105. }
  106. #main{
  107. width:750px;
  108. margin:0 auto;
  109. font-size:14px;
  110. font-family:'宋体';
  111. }
  112. #logo{
  113. background-color: transparent;
  114. background-image: url("../img/new-btn-fixed.png");
  115. border: medium none;
  116. background-position:0 0;
  117. width:166px;
  118. height:35px;
  119. float:left;
  120. }
  121. .red-star{
  122. color:#f00;
  123. width:10px;
  124. display:inline-block;
  125. }
  126. .null-star{
  127. color:#fff;
  128. }
  129. .content{
  130. margin-top:5px;
  131. }
  132. .content dt{
  133. width:160px;
  134. display:inline-block;
  135. text-align:right;
  136. float:left;
  137. }
  138. .content dd{
  139. margin-left:100px;
  140. margin-bottom:5px;
  141. }
  142. #foot{
  143. margin-top:10px;
  144. }
  145. .foot-ul li {
  146. text-align:center;
  147. }
  148. .note-help {
  149. color: #999999;
  150. font-size: 12px;
  151. line-height: 130%;
  152. padding-left: 3px;
  153. }
  154. .cashier-nav {
  155. font-size: 14px;
  156. margin: 15px 0 10px;
  157. text-align: left;
  158. height:30px;
  159. border-bottom:solid 2px #CFD2D7;
  160. }
  161. .cashier-nav ol li {
  162. float: left;
  163. }
  164. .cashier-nav li.current {
  165. color: #AB4400;
  166. font-weight: bold;
  167. }
  168. .cashier-nav li.last {
  169. clear:right;
  170. }
  171. .alipay_link {
  172. text-align:right;
  173. }
  174. .alipay_link a:link{
  175. text-decoration:none;
  176. color:#8D8D8D;
  177. }
  178. .alipay_link a:visited{
  179. text-decoration:none;
  180. color:#8D8D8D;
  181. }
  182. </style>
  183. </head>
  184. <body text=#000000 bgColor="#ffffff" leftMargin=0 topMargin=4>
  185. <div id="main">
  186. <div id="head">
  187. <dl class="alipay_link">
  188. <a target="_blank" href="http://www.alipay.com/"><span>支付宝首页</span></a>|
  189. <a target="_blank" href="https://b.alipay.com/home.htm"><span>商家服务</span></a>|
  190. <a target="_blank" href="http://help.alipay.com/support/index_sh.htm"><span>帮助中心</span></a>
  191. </dl>
  192. <span class="title">支付宝 当面付2.0 订单查询接口</span>
  193. </div>
  194. <div class="cashier-nav">
  195. <ol>
  196. <li class="current">1、确认信息 →</li>
  197. <li>2、点击确认 →</li>
  198. <li class="last">3、确认完成</li>
  199. </ol>
  200. </div>
  201. <form name=alipayment action="" method=post target="_blank">
  202. <div id="body" style="clear:left">
  203. <dl class="content">
  204. <dt>商户订单号:</dt>
  205. <dd>
  206. <span class="null-star">*</span>
  207. <input size="30" name="out_trade_no" />
  208. <span>商户网站订单系统中唯一订单号,必填
  209. </span>
  210. </dd>
  211. <dt></dt>
  212. <dd>
  213. <span class="new-btn-login-sp">
  214. <button class="new-btn-login" type="submit" style="text-align:center;">确 认</button>
  215. </span>
  216. </dd>
  217. </dl>
  218. </div>
  219. </form>
  220. <div id="foot">
  221. <ul class="foot-ul">
  222. <li><font class="note-help">如果您点击“确认”按钮,即表示您同意该次的执行操作。 </font></li>
  223. <li>
  224. 支付宝版权所有 2011-2015 ALIPAY.COM
  225. </li>
  226. </ul>
  227. </div>
  228. </div>
  229. </body>
  230. </html>