alipay-wap.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. // 1. 手动加载入口文件
  14. include "../include.php";
  15. // 2. 准备公众号配置参数
  16. $config = include "./alipay.php";
  17. // 参考公共参数 https://docs.open.alipay.com/203/107090/
  18. $config['notify_url'] = 'http://pay.thinkadmin.top/test/alipay-notify.php';
  19. $config['return_url'] = 'http://pay.thinkadmin.top/test/alipay-success.php';
  20. try {
  21. // 实例支付对象
  22. // $pay = We::AliPayWap($config);
  23. // $pay = new \AliPay\Wap($config);
  24. $pay = \AliPay\Wap::instance($config);
  25. // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.wap.pay
  26. $result = $pay->apply([
  27. 'out_trade_no' => time(), // 商户订单号
  28. 'total_amount' => '1', // 支付金额
  29. 'subject' => '支付订单描述', // 支付订单描述
  30. ]);
  31. echo $result;
  32. } catch (Exception $e) {
  33. echo $e->getMessage();
  34. }