alipay-web.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. // 1. 手动加载入口文件
  16. include "../include.php";
  17. // 2. 准备公众号配置参数
  18. $config = include "./alipay.php";
  19. // 参考公共参数 https://docs.open.alipay.com/203/107090/
  20. $config['notify_url'] = 'https://pay.thinkadmin.top/test/alipay-notify.php';
  21. $config['return_url'] = 'https://pay.thinkadmin.top/test/alipay-success.php';
  22. try {
  23. // 实例支付对象
  24. // $pay = We::AliPayWeb($config);
  25. // $pay = new \AliPay\Web($config);
  26. $pay = \AliPay\Web::instance($config);
  27. // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.page.pay
  28. $result = $pay->apply([
  29. 'out_trade_no' => time(), // 商户订单号
  30. 'total_amount' => '1', // 支付金额
  31. 'subject' => '支付订单描述', // 支付订单描述
  32. ]);
  33. echo $result;
  34. } catch (Exception $e) {
  35. echo $e->getMessage();
  36. }