pagepay.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>支付</title>
  6. </head>
  7. <?php
  8. require_once dirname(dirname(__FILE__)).'/config.php';
  9. require_once dirname(__FILE__).'/service/AlipayTradeService.php';
  10. require_once dirname(__FILE__).'/buildermodel/AlipayTradePagePayContentBuilder.php';
  11. //商户订单号,商户网站订单系统中唯一订单号,必填
  12. $out_trade_no = trim($_POST['WIDout_trade_no']);
  13. //订单名称,必填
  14. $subject = trim($_POST['WIDsubject']);
  15. //付款金额,必填
  16. $total_amount = trim($_POST['WIDtotal_amount']);
  17. //商品描述,可空
  18. $body = trim($_POST['WIDbody']);
  19. //构造参数
  20. $payRequestBuilder = new AlipayTradePagePayContentBuilder();
  21. $payRequestBuilder->setBody($body);
  22. $payRequestBuilder->setSubject($subject);
  23. $payRequestBuilder->setTotalAmount($total_amount);
  24. $payRequestBuilder->setOutTradeNo($out_trade_no);
  25. echo "<pre>"; print_r($payRequestBuilder); exit;
  26. $aop = new AlipayTradeService($config);
  27. /**
  28. * pagePay 电脑网站支付请求
  29. * @param $builder 业务参数,使用buildmodel中的对象生成。
  30. * @param $return_url 同步跳转地址,公网可以访问
  31. * @param $notify_url 异步通知地址,公网可以访问
  32. * @return $response 支付宝返回的信息
  33. */
  34. $response = $aop->pagePay($payRequestBuilder,$config['return_url'],$config['notify_url']);
  35. //输出表单
  36. var_dump($response);
  37. ?>
  38. </body>
  39. </html>