pay.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. /* *
  3. * 功能:支付宝手机网站支付接口(alipay.trade.wap.pay)接口调试入口页面
  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/AlipayTradeWapPayContentBuilder.php';
  13. require dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../config.php';
  14. if (!empty($_POST['WIDout_trade_no'])&& trim($_POST['WIDout_trade_no'])!=""){
  15. //商户订单号,商户网站订单系统中唯一订单号,必填
  16. $out_trade_no = $_POST['WIDout_trade_no'];
  17. //订单名称,必填
  18. $subject = $_POST['WIDsubject'];
  19. //付款金额,必填
  20. $total_amount = $_POST['WIDtotal_amount'];
  21. //商品描述,可空
  22. $body = $_POST['WIDbody'];
  23. //超时时间
  24. $timeout_express="1m";
  25. $payRequestBuilder = new AlipayTradeWapPayContentBuilder();
  26. $payRequestBuilder->setBody($body);
  27. $payRequestBuilder->setSubject($subject);
  28. $payRequestBuilder->setOutTradeNo($out_trade_no);
  29. $payRequestBuilder->setTotalAmount($total_amount);
  30. $payRequestBuilder->setTimeExpress($timeout_express);
  31. $payResponse = new AlipayTradeService($config);
  32. $result=$payResponse->wapPay($payRequestBuilder,$config['return_url'],$config['notify_url']);
  33. return ;
  34. }
  35. ?>
  36. <!DOCTYPE html>
  37. <html>
  38. <head>
  39. <title>支付宝手机网站支付接口</title>
  40. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  41. <style>
  42. *{
  43. margin:0;
  44. padding:0;
  45. }
  46. ul,ol{
  47. list-style:none;
  48. }
  49. body{
  50. font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;
  51. }
  52. .hidden{
  53. display:none;
  54. }
  55. .new-btn-login-sp{
  56. padding: 1px;
  57. display: inline-block;
  58. width: 75%;
  59. }
  60. .new-btn-login {
  61. background-color: #02aaf1;
  62. color: #FFFFFF;
  63. font-weight: bold;
  64. border: none;
  65. width: 100%;
  66. height: 30px;
  67. border-radius: 5px;
  68. font-size: 16px;
  69. }
  70. #main{
  71. width:100%;
  72. margin:0 auto;
  73. font-size:14px;
  74. }
  75. .red-star{
  76. color:#f00;
  77. width:10px;
  78. display:inline-block;
  79. }
  80. .null-star{
  81. color:#fff;
  82. }
  83. .content{
  84. margin-top:5px;
  85. }
  86. .content dt{
  87. width:100px;
  88. display:inline-block;
  89. float: left;
  90. margin-left: 20px;
  91. color: #666;
  92. font-size: 13px;
  93. margin-top: 8px;
  94. }
  95. .content dd{
  96. margin-left:120px;
  97. margin-bottom:5px;
  98. }
  99. .content dd input {
  100. width: 85%;
  101. height: 28px;
  102. border: 0;
  103. -webkit-border-radius: 0;
  104. -webkit-appearance: none;
  105. }
  106. #foot{
  107. margin-top:10px;
  108. position: absolute;
  109. bottom: 15px;
  110. width: 100%;
  111. }
  112. .foot-ul{
  113. width: 100%;
  114. }
  115. .foot-ul li {
  116. width: 100%;
  117. text-align:center;
  118. color: #666;
  119. }
  120. .note-help {
  121. color: #999999;
  122. font-size: 12px;
  123. line-height: 130%;
  124. margin-top: 5px;
  125. width: 100%;
  126. display: block;
  127. }
  128. #btn-dd{
  129. margin: 20px;
  130. text-align: center;
  131. }
  132. .foot-ul{
  133. width: 100%;
  134. }
  135. .one_line{
  136. display: block;
  137. height: 1px;
  138. border: 0;
  139. border-top: 1px solid #eeeeee;
  140. width: 100%;
  141. margin-left: 20px;
  142. }
  143. .am-header {
  144. display: -webkit-box;
  145. display: -ms-flexbox;
  146. display: box;
  147. width: 100%;
  148. position: relative;
  149. padding: 7px 0;
  150. -webkit-box-sizing: border-box;
  151. -ms-box-sizing: border-box;
  152. box-sizing: border-box;
  153. background: #1D222D;
  154. height: 50px;
  155. text-align: center;
  156. -webkit-box-pack: center;
  157. -ms-flex-pack: center;
  158. box-pack: center;
  159. -webkit-box-align: center;
  160. -ms-flex-align: center;
  161. box-align: center;
  162. }
  163. .am-header h1 {
  164. -webkit-box-flex: 1;
  165. -ms-flex: 1;
  166. box-flex: 1;
  167. line-height: 18px;
  168. text-align: center;
  169. font-size: 18px;
  170. font-weight: 300;
  171. color: #fff;
  172. }
  173. </style>
  174. </head>
  175. <body text=#000000 bgColor="#ffffff" leftMargin=0 topMargin=4>
  176. <header class="am-header">
  177. <h1>支付宝手机网站支付接口快速通道(接口名:alipay.trade.wap.pay)</h1>
  178. </header>
  179. <div id="main">
  180. <form name=alipayment action='' method=post target="_blank">
  181. <div id="body" style="clear:left">
  182. <dl class="content">
  183. <dt>商户订单号
  184. :</dt>
  185. <dd>
  186. <input id="WIDout_trade_no" name="WIDout_trade_no" />
  187. </dd>
  188. <hr class="one_line">
  189. <dt>订单名称
  190. :</dt>
  191. <dd>
  192. <input id="WIDsubject" name="WIDsubject" />
  193. </dd>
  194. <hr class="one_line">
  195. <dt>付款金额
  196. :</dt>
  197. <dd>
  198. <input id="WIDtotal_amount" name="WIDtotal_amount" />
  199. </dd>
  200. <hr class="one_line">
  201. <dt>商品描述:</dt>
  202. <dd>
  203. <input id="WIDbody" name="WIDbody" />
  204. </dd>
  205. <hr class="one_line">
  206. <dt></dt>
  207. <dd id="btn-dd">
  208. <span class="new-btn-login-sp">
  209. <button class="new-btn-login" type="submit" style="text-align:center;">确 认</button>
  210. </span>
  211. <span class="note-help">如果您点击“确认”按钮,即表示您同意该次的执行操作。</span>
  212. </dd>
  213. </dl>
  214. </div>
  215. </form>
  216. <div id="foot">
  217. <ul class="foot-ul">
  218. <li>
  219. 支付宝版权所有 2015-2018 ALIPAY.COM
  220. </li>
  221. </ul>
  222. </div>
  223. </div>
  224. </body>
  225. <script language="javascript">
  226. function GetDateNow() {
  227. var vNow = new Date();
  228. var sNow = "";
  229. sNow += String(vNow.getFullYear());
  230. sNow += String(vNow.getMonth() + 1);
  231. sNow += String(vNow.getDate());
  232. sNow += String(vNow.getHours());
  233. sNow += String(vNow.getMinutes());
  234. sNow += String(vNow.getSeconds());
  235. sNow += String(vNow.getMilliseconds());
  236. document.getElementById("WIDout_trade_no").value = sNow;
  237. document.getElementById("WIDsubject").value = "测试";
  238. document.getElementById("WIDtotal_amount").value = "0.01";
  239. document.getElementById("WIDbody").value = "购买测试商品0.01元";
  240. }
  241. GetDateNow();
  242. </script>
  243. </html>