close.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. /* *
  3. * 功能:支付宝手机网站alipay.trade.close (统一收单交易关闭接口)调试入口页面
  4. * 版本:2.0
  5. * 修改日期:2016-11-01
  6. * 说明:
  7. * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
  8. 请确保项目文件有可写权限,不然打印不了日志。
  9. */
  10. header("Content-type: text/html; charset=utf-8");
  11. require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'service/AlipayTradeService.php';
  12. require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'buildermodel/AlipayTradeCloseContentBuilder.php';
  13. require dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../config.php';
  14. if (!empty($_POST['WIDout_trade_no']) || !empty($_POST['WIDtrade_no'])){
  15. //商户订单号和支付宝交易号不能同时为空。 trade_no、 out_trade_no如果同时存在优先取trade_no
  16. //商户订单号,和支付宝交易号二选一
  17. $out_trade_no = trim($_POST['WIDout_trade_no']);
  18. //支付宝交易号,和商户订单号二选一
  19. $trade_no = trim($_POST['WIDtrade_no']);
  20. $RequestBuilder = new AlipayTradeCloseContentBuilder();
  21. $RequestBuilder->setTradeNo($trade_no);
  22. $RequestBuilder->setOutTradeNo($out_trade_no);
  23. $Response = new AlipayTradeService($config);
  24. $result=$Response->Close($RequestBuilder);
  25. return ;
  26. }
  27. ?>
  28. <!DOCTYPE html>
  29. <html>
  30. <head>
  31. <title>支付宝手机网站alipay.trade.close(统一收单交易关闭接口)</title>
  32. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  33. <style>
  34. *{
  35. margin:0;
  36. padding:0;
  37. }
  38. ul,ol{
  39. list-style:none;
  40. }
  41. body{
  42. font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;
  43. }
  44. .hidden{
  45. display:none;
  46. }
  47. .new-btn-login-sp{
  48. padding: 1px;
  49. display: inline-block;
  50. width: 75%;
  51. }
  52. .new-btn-login {
  53. background-color: #02aaf1;
  54. color: #FFFFFF;
  55. font-weight: bold;
  56. border: none;
  57. width: 100%;
  58. height: 30px;
  59. border-radius: 5px;
  60. font-size: 16px;
  61. }
  62. #main{
  63. width:100%;
  64. margin:0 auto;
  65. font-size:14px;
  66. }
  67. .red-star{
  68. color:#f00;
  69. width:10px;
  70. display:inline-block;
  71. }
  72. .null-star{
  73. color:#fff;
  74. }
  75. .content{
  76. margin-top:5px;
  77. }
  78. .content dt{
  79. width:100px;
  80. display:inline-block;
  81. float: left;
  82. margin-left: 20px;
  83. color: #666;
  84. font-size: 13px;
  85. margin-top: 8px;
  86. }
  87. .content dd{
  88. margin-left:120px;
  89. margin-bottom:5px;
  90. }
  91. .content dd input {
  92. width: 85%;
  93. height: 28px;
  94. border: 0;
  95. -webkit-border-radius: 0;
  96. -webkit-appearance: none;
  97. }
  98. #foot{
  99. margin-top:10px;
  100. position: absolute;
  101. bottom: 15px;
  102. width: 100%;
  103. }
  104. .foot-ul{
  105. width: 100%;
  106. }
  107. .foot-ul li {
  108. width: 100%;
  109. text-align:center;
  110. color: #666;
  111. }
  112. .note-help {
  113. color: #999999;
  114. font-size: 12px;
  115. line-height: 130%;
  116. margin-top: 5px;
  117. width: 100%;
  118. display: block;
  119. }
  120. #btn-dd{
  121. margin: 20px;
  122. text-align: center;
  123. }
  124. .foot-ul{
  125. width: 100%;
  126. }
  127. .one_line{
  128. display: block;
  129. height: 1px;
  130. border: 0;
  131. border-top: 1px solid #eeeeee;
  132. width: 100%;
  133. margin-left: 20px;
  134. }
  135. .am-header {
  136. display: -webkit-box;
  137. display: -ms-flexbox;
  138. display: box;
  139. width: 100%;
  140. position: relative;
  141. padding: 7px 0;
  142. -webkit-box-sizing: border-box;
  143. -ms-box-sizing: border-box;
  144. box-sizing: border-box;
  145. background: #1D222D;
  146. height: 50px;
  147. text-align: center;
  148. -webkit-box-pack: center;
  149. -ms-flex-pack: center;
  150. box-pack: center;
  151. -webkit-box-align: center;
  152. -ms-flex-align: center;
  153. box-align: center;
  154. }
  155. .am-header h1 {
  156. -webkit-box-flex: 1;
  157. -ms-flex: 1;
  158. box-flex: 1;
  159. line-height: 18px;
  160. text-align: center;
  161. font-size: 18px;
  162. font-weight: 300;
  163. color: #fff;
  164. }
  165. </style>
  166. </head>
  167. <body text=#000000 bgColor="#ffffff" leftMargin=0 topMargin=4>
  168. <header class="am-header">
  169. <h1>支付宝手机网站交易关闭接口(接口名:alipay.trade.close )</h1>
  170. </header>
  171. <div id="main">
  172. <form name=alipayment action='' method=post target="_blank">
  173. <div id="body" style="clear:left">
  174. <dl class="content">
  175. <dt>商户订单号
  176. :</dt>
  177. <dd>
  178. <input id="WIDout_trade_no" name="WIDout_trade_no" />
  179. </dd>
  180. <hr class="one_line">
  181. <dt>支付宝交易号:</dt>
  182. <dd>
  183. <input id="WIDtrade_no" name="WIDtrade_no" />
  184. </dd>
  185. <hr class="one_line">
  186. <dt></dt>
  187. <dd>
  188. <span style="line-height: 28px; color:red;">注意:商户订单号和支付宝交易号不能同时为空。 trade_no、 out_trade_no如果同时存在优先取trade_no</span>
  189. </dd>
  190. <dd id="btn-dd">
  191. <span class="new-btn-login-sp">
  192. <button class="new-btn-login" type="submit" style="text-align:center;">确 认</button>
  193. </span>
  194. <span class="note-help">如果您点击“确认”按钮,即表示您同意该次的执行操作。</span>
  195. </dd>
  196. </dl>
  197. </div>
  198. </form>
  199. <div id="foot">
  200. <ul class="foot-ul">
  201. <li>
  202. 支付宝版权所有 2015-2018 ALIPAY.COM
  203. </li>
  204. </ul>
  205. </div>
  206. </div>
  207. </body>
  208. </html>